feat/ajout-de-fonctionnalites (#1)
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Reviewed-on: #1 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #1.
This commit is contained in:
36
frontend/services/environments.ts
Normal file
36
frontend/services/environments.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Environment, EnvironmentWrite } from './dto/application'
|
||||
|
||||
export function createEnvironment(appSlug: string, data: EnvironmentWrite): Promise<Environment> {
|
||||
return useApi().post<Environment>(`/applications/${appSlug}/environments`, data, {
|
||||
toastSuccessKey: 'success.environments.create',
|
||||
toastErrorKey: 'errors.environments.create',
|
||||
})
|
||||
}
|
||||
|
||||
export function updateEnvironment(id: number, data: Partial<EnvironmentWrite>): Promise<Environment> {
|
||||
return useApi().patch<Environment>(`/environments/${id}`, data, {
|
||||
toastSuccessKey: 'success.environments.update',
|
||||
toastErrorKey: 'errors.environments.update',
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteEnvironment(id: number): Promise<void> {
|
||||
return useApi().delete<void>(`/environments/${id}`, undefined, {
|
||||
toastSuccessKey: 'success.environments.delete',
|
||||
toastErrorKey: 'errors.environments.delete',
|
||||
})
|
||||
}
|
||||
|
||||
export function toggleMaintenance(id: number, maintenance: boolean): Promise<Environment> {
|
||||
const successKey = maintenance
|
||||
? 'success.environments.activateMaintenance'
|
||||
: 'success.environments.deactivateMaintenance'
|
||||
const errorKey = maintenance
|
||||
? 'errors.environments.activateMaintenance'
|
||||
: 'errors.environments.deactivateMaintenance'
|
||||
|
||||
return useApi().post<Environment>(`/environments/${id}/maintenance`, { maintenance }, {
|
||||
toastSuccessKey: successKey,
|
||||
toastErrorKey: errorKey,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user