mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
admin(ui-api): add 'include' parameter to all requests
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import http from '@/api/http';
|
||||
import { Nest, rawDataToNest } from '@/api/admin/nests/getNests';
|
||||
|
||||
export default (name: string, description?: string): Promise<Nest> => {
|
||||
export default (name: string, description: string | null, include: string[] = []): Promise<Nest> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/nests', {
|
||||
name, description,
|
||||
})
|
||||
}, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToNest(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
||||
@@ -38,11 +38,11 @@ interface ctx {
|
||||
|
||||
export const Context = createContext<ctx>({ page: 1, setPage: () => 1 });
|
||||
|
||||
export default () => {
|
||||
export default (include: string[] = []) => {
|
||||
const { page } = useContext(Context);
|
||||
|
||||
return useSWR<PaginatedResult<Nest>>([ 'nests', page ], async () => {
|
||||
const { data } = await http.get('/api/application/nests', { params: { page } });
|
||||
const { data } = await http.get('/api/application/nests', { params: { include: include.join(','), page } });
|
||||
|
||||
return ({
|
||||
items: (data.data || []).map(rawDataToNest),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import http from '@/api/http';
|
||||
import { Nest, rawDataToNest } from '@/api/admin/nests/getNests';
|
||||
|
||||
export default (id: number, name: string, description?: string): Promise<Nest> => {
|
||||
export default (id: number, name: string, description: string | null, include: string[] = []): Promise<Nest> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.patch(`/api/application/nests/${id}`, {
|
||||
name, description,
|
||||
})
|
||||
}, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToNest(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user