[#328] Corrections (#3)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled

| 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:
2026-02-17 08:01:25 +00:00
committed by Autin
parent 2a9b047913
commit 69e8d74f4d
11 changed files with 203 additions and 35 deletions

View File

@@ -2,4 +2,5 @@ export type Site = {
id: number
name: string
color: string
displayOrder?: number
}

View File

@@ -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}`, {}, {