generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83ab5b2
commit 09c7357
Showing
8 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import axios from 'axios'; | ||
import { useToast } from 'vue-toastification' | ||
|
||
const toast = useToast() | ||
|
||
const API_URL = 'http://localhost:8000/api/workers'; | ||
|
||
|
||
export const getAdminProfileData = async (userData) => { | ||
try{ | ||
const response = await axios.get(`${API_URL}/${localStorage.getItem('id')}/private`); | ||
return response.data | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
}; | ||
|
||
export const updateAdminProfileData = async (profileData) => { | ||
try{ | ||
const response = await axios.patch(`${API_URL}/${localStorage.getItem('id')}`, profileData, { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
toast.success("Данные успешно обновлены!") | ||
return "SUCCESS" | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
} | ||
|
||
export const changeAdminPassword = async (formData) => { | ||
try{ | ||
const response = await axios.patch(`${API_URL}/${localStorage.getItem('id')}/password`, formData, { | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
toast.success("Пароль успешно обновлен!") | ||
return "SUCCESS" | ||
} catch (error) { | ||
const errorMessage = error.response | ||
? error.response.data.message // Если есть ответ от сервера | ||
: error.message || 'Ошибка соединения'; | ||
toast.error(errorMessage) | ||
return "ERROR" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters