mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-11 22:06:29 +02:00
Add custom db read support
This commit is contained in:
@@ -147,5 +147,26 @@ export default function getServiceAccessors<
|
||||
}
|
||||
}
|
||||
|
||||
return { listGet, get, set, add }
|
||||
function countGet(): () => Promise<{
|
||||
data?: number
|
||||
error?: Error
|
||||
}> {
|
||||
interface ElementCountGetResponse {
|
||||
data?: number
|
||||
error?: Error
|
||||
}
|
||||
return async (): Promise<ElementCountGetResponse> => {
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
`${config.API_URL}/${elementName}CountGet`,
|
||||
axiosConfig
|
||||
)
|
||||
return { data }
|
||||
} catch (error) {
|
||||
return { error: error as Error }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { listGet, get, set, add, countGet }
|
||||
}
|
||||
|
@@ -30,12 +30,13 @@ const elementName = "PreVolunteer"
|
||||
|
||||
export type PreVolunteerWithoutId = Omit<PreVolunteer, "id">
|
||||
|
||||
const { listGet, get, set, add } = getServiceAccessors<PreVolunteerWithoutId, PreVolunteer>(
|
||||
elementName,
|
||||
translationPreVolunteer
|
||||
)
|
||||
const { listGet, get, set, add, countGet } = getServiceAccessors<
|
||||
PreVolunteerWithoutId,
|
||||
PreVolunteer
|
||||
>(elementName, translationPreVolunteer)
|
||||
|
||||
export const preVolunteerListGet = listGet()
|
||||
export const preVolunteerGet = get()
|
||||
export const preVolunteerAdd = add()
|
||||
export const preVolunteerSet = set()
|
||||
export const preVolunteerCountGet = countGet()
|
||||
|
Reference in New Issue
Block a user