mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Remove user id from frintend api call
This commit is contained in:
@@ -17,27 +17,27 @@ const apiCall = async (url, options = {}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const fetchLastWorkspaceId = async () => {
|
export const fetchLastWorkspaceId = async () => {
|
||||||
const response = await apiCall(`${API_BASE_URL}/users/1/workspaces/last`);
|
const response = await apiCall(`${API_BASE_URL}/workspaces/last`);
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchFileList = async (workspaceId) => {
|
export const fetchFileList = async (workspaceId) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files`
|
`${API_BASE_URL}/workspaces/${workspaceId}/files`
|
||||||
);
|
);
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchFileContent = async (workspaceId, filePath) => {
|
export const fetchFileContent = async (workspaceId, filePath) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/${filePath}`
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/${filePath}`
|
||||||
);
|
);
|
||||||
return response.text();
|
return response.text();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const saveFileContent = async (workspaceId, filePath, content) => {
|
export const saveFileContent = async (workspaceId, filePath, content) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/${filePath}`,
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/${filePath}`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -51,7 +51,7 @@ export const saveFileContent = async (workspaceId, filePath, content) => {
|
|||||||
|
|
||||||
export const deleteFile = async (workspaceId, filePath) => {
|
export const deleteFile = async (workspaceId, filePath) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/${filePath}`,
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/${filePath}`,
|
||||||
{
|
{
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
}
|
}
|
||||||
@@ -60,30 +60,25 @@ export const deleteFile = async (workspaceId, filePath) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getWorkspace = async (workspaceId) => {
|
export const getWorkspace = async (workspaceId) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(`${API_BASE_URL}/workspaces/${workspaceId}`);
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}`
|
|
||||||
);
|
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combined function to update workspace data including settings
|
// Combined function to update workspace data including settings
|
||||||
export const updateWorkspace = async (workspaceId, workspaceData) => {
|
export const updateWorkspace = async (workspaceId, workspaceData) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(`${API_BASE_URL}/workspaces/${workspaceId}`, {
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}`,
|
method: 'PUT',
|
||||||
{
|
headers: {
|
||||||
method: 'PUT',
|
'Content-Type': 'application/json',
|
||||||
headers: {
|
},
|
||||||
'Content-Type': 'application/json',
|
body: JSON.stringify(workspaceData),
|
||||||
},
|
});
|
||||||
body: JSON.stringify(workspaceData),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pullChanges = async (workspaceId) => {
|
export const pullChanges = async (workspaceId) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/git/pull`,
|
`${API_BASE_URL}/workspaces/${workspaceId}/git/pull`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
}
|
}
|
||||||
@@ -93,7 +88,7 @@ export const pullChanges = async (workspaceId) => {
|
|||||||
|
|
||||||
export const commitAndPush = async (workspaceId, message) => {
|
export const commitAndPush = async (workspaceId, message) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/git/commit`,
|
`${API_BASE_URL}/workspaces/${workspaceId}/git/commit`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -106,12 +101,12 @@ export const commitAndPush = async (workspaceId, message) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getFileUrl = (workspaceId, filePath) => {
|
export const getFileUrl = (workspaceId, filePath) => {
|
||||||
return `${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/${filePath}`;
|
return `${API_BASE_URL}/workspaces/${workspaceId}/files/${filePath}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const lookupFileByName = async (workspaceId, filename) => {
|
export const lookupFileByName = async (workspaceId, filename) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/lookup?filename=${encodeURIComponent(
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/lookup?filename=${encodeURIComponent(
|
||||||
filename
|
filename
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -121,7 +116,7 @@ export const lookupFileByName = async (workspaceId, filename) => {
|
|||||||
|
|
||||||
export const updateLastOpenedFile = async (workspaceId, filePath) => {
|
export const updateLastOpenedFile = async (workspaceId, filePath) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/last`,
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/last`,
|
||||||
{
|
{
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -135,18 +130,18 @@ export const updateLastOpenedFile = async (workspaceId, filePath) => {
|
|||||||
|
|
||||||
export const getLastOpenedFile = async (workspaceId) => {
|
export const getLastOpenedFile = async (workspaceId) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}/files/last`
|
`${API_BASE_URL}/workspaces/${workspaceId}/files/last`
|
||||||
);
|
);
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listWorkspaces = async () => {
|
export const listWorkspaces = async () => {
|
||||||
const response = await apiCall(`${API_BASE_URL}/users/1/workspaces`);
|
const response = await apiCall(`${API_BASE_URL}/workspaces`);
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createWorkspace = async (name) => {
|
export const createWorkspace = async (name) => {
|
||||||
const response = await apiCall(`${API_BASE_URL}/users/1/workspaces`, {
|
const response = await apiCall(`${API_BASE_URL}/workspaces`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -157,17 +152,14 @@ export const createWorkspace = async (name) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteWorkspace = async (workspaceId) => {
|
export const deleteWorkspace = async (workspaceId) => {
|
||||||
const response = await apiCall(
|
const response = await apiCall(`${API_BASE_URL}/workspaces/${workspaceId}`, {
|
||||||
`${API_BASE_URL}/users/1/workspaces/${workspaceId}`,
|
method: 'DELETE',
|
||||||
{
|
});
|
||||||
method: 'DELETE',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateLastWorkspace = async (workspaceId) => {
|
export const updateLastWorkspace = async (workspaceId) => {
|
||||||
const response = await apiCall(`${API_BASE_URL}/users/1/workspaces/last`, {
|
const response = await apiCall(`${API_BASE_URL}/workspaces/last`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
Reference in New Issue
Block a user