chore: run prettier
This commit is contained in:
parent
9cdbbc3a00
commit
155d7bb876
76 changed files with 788 additions and 550 deletions
|
@ -13,9 +13,14 @@ export const Context = createContext<Filters>();
|
|||
|
||||
const createRole = (name: string, description: string | null, include: string[] = []): Promise<UserRole> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/roles', {
|
||||
name, description,
|
||||
}, { params: { include: include.join(',') } })
|
||||
http.post(
|
||||
'/api/application/roles',
|
||||
{
|
||||
name,
|
||||
description,
|
||||
},
|
||||
{ params: { include: include.join(',') } },
|
||||
)
|
||||
.then(({ data }) => resolve(Transformers.toUserRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
@ -48,18 +53,26 @@ const searchRoles = (filters?: { name?: string }): Promise<UserRole[]> => {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get('/api/application/roles', { params })
|
||||
.then(response => resolve(
|
||||
(response.data.data || []).map(Transformers.toUserRole)
|
||||
))
|
||||
.then(response => resolve((response.data.data || []).map(Transformers.toUserRole)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
const updateRole = (id: number, name: string, description: string | null, include: string[] = []): Promise<UserRole> => {
|
||||
const updateRole = (
|
||||
id: number,
|
||||
name: string,
|
||||
description: string | null,
|
||||
include: string[] = [],
|
||||
): Promise<UserRole> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.patch(`/api/application/roles/${id}`, {
|
||||
name, description,
|
||||
}, { params: { include: include.join(',') } })
|
||||
http.patch(
|
||||
`/api/application/roles/${id}`,
|
||||
{
|
||||
name,
|
||||
description,
|
||||
},
|
||||
{ params: { include: include.join(',') } },
|
||||
)
|
||||
.then(({ data }) => resolve(Transformers.toUserRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
@ -83,21 +96,16 @@ const getRoles = (include: string[] = []) => {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
return useSWR<PaginatedResult<UserRole>>([ 'roles', page, filters, sort, sortDirection ], async () => {
|
||||
const { data } = await http.get('/api/application/roles', { params: { include: include.join(','), page, ...params } });
|
||||
return useSWR<PaginatedResult<UserRole>>(['roles', page, filters, sort, sortDirection], async () => {
|
||||
const { data } = await http.get('/api/application/roles', {
|
||||
params: { include: include.join(','), page, ...params },
|
||||
});
|
||||
|
||||
return ({
|
||||
return {
|
||||
items: (data.data || []).map(Transformers.toUserRole),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
createRole,
|
||||
deleteRole,
|
||||
getRole,
|
||||
searchRoles,
|
||||
updateRole,
|
||||
getRoles,
|
||||
};
|
||||
export { createRole, deleteRole, getRole, searchRoles, updateRole, getRoles };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue