| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [x] Pas de régression - [ ] TU/TI/TF rédigée - [x] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #3 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #3.
This commit is contained in:
@@ -2,4 +2,5 @@ export type Site = {
|
||||
id: number
|
||||
name: string
|
||||
color: string
|
||||
displayOrder?: number
|
||||
}
|
||||
|
||||
@@ -8,10 +8,15 @@ export const listSites = async () => {
|
||||
{},
|
||||
{ toast: false }
|
||||
)
|
||||
return extractItems<Site>(data)
|
||||
return extractItems<Site>(data).sort((siteA, siteB) => {
|
||||
const orderA = siteA.displayOrder ?? 0
|
||||
const orderB = siteB.displayOrder ?? 0
|
||||
if (orderA !== orderB) return orderA - orderB
|
||||
return siteA.name.localeCompare(siteB.name, 'fr')
|
||||
})
|
||||
}
|
||||
|
||||
export const createSite = async (payload: Pick<Site, 'name' | 'color'>) => {
|
||||
export const createSite = async (payload: Pick<Site, 'name' | 'color'> & { displayOrder?: number }) => {
|
||||
const api = useApi()
|
||||
return api.post<Site>('/sites', payload, {
|
||||
toastSuccessKey: 'success.site.create',
|
||||
@@ -19,7 +24,10 @@ export const createSite = async (payload: Pick<Site, 'name' | 'color'>) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const updateSite = async (id: number, payload: Pick<Site, 'name' | 'color'>) => {
|
||||
export const updateSite = async (
|
||||
id: number,
|
||||
payload: Pick<Site, 'name' | 'color'> & { displayOrder?: number }
|
||||
) => {
|
||||
const api = useApi()
|
||||
return api.patch<Site>(`/sites/${id}`, payload, {
|
||||
toastSuccessKey: 'success.site.update',
|
||||
@@ -27,6 +35,15 @@ export const updateSite = async (id: number, payload: Pick<Site, 'name' | 'color
|
||||
})
|
||||
}
|
||||
|
||||
export const updateSiteOrder = async (id: number, displayOrder: number) => {
|
||||
const api = useApi()
|
||||
return api.patch<Site>(`/sites/${id}`, {
|
||||
displayOrder
|
||||
}, {
|
||||
toast: false
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteSite = async (id: number) => {
|
||||
const api = useApi()
|
||||
return api.delete(`/sites/${id}`, {}, {
|
||||
|
||||
Reference in New Issue
Block a user