mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-07 08:24:27 +00:00
Add git api calls on frontend
This commit is contained in:
@@ -42,6 +42,21 @@ export const saveFileContent = async (filePath, content) => {
|
||||
return await response.text();
|
||||
};
|
||||
|
||||
export const deleteFile = async (filePath) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/files/${filePath}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to delete file');
|
||||
}
|
||||
return await response.text();
|
||||
} catch (error) {
|
||||
console.error('Error deleting file:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const fetchUserSettings = async (userId) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/settings?userId=${userId}`);
|
||||
@@ -75,4 +90,38 @@ export const saveUserSettings = async (settings) => {
|
||||
console.error('Error saving user settings:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const pullChanges = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/git/pull`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to pull changes');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error pulling changes:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const commitAndPush = async (message) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/git/commit`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ message }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to commit and push changes');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error committing and pushing changes:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user