added fields page data api call
This commit is contained in:
parent
96958c12a0
commit
3567190c3a
3 changed files with 37 additions and 4 deletions
|
|
@ -18,13 +18,21 @@ export interface IFieldAPIContext {
|
|||
otherTeam?: string,
|
||||
asRoot?: boolean
|
||||
) => Promise<AxiosResponse<pond.ListFieldsResponse>>;
|
||||
fieldsPageData: (
|
||||
limit: number,
|
||||
offset: number,
|
||||
order?: "asc" | "desc",
|
||||
orderBy?: string,
|
||||
search?: string,
|
||||
otherTeam?: string,
|
||||
) => Promise<AxiosResponse<pond.ListFieldsPageDataResponse>>
|
||||
removeField: (key: string, otherTeam?: string) => Promise<AxiosResponse<pond.RemoveFieldResponse>>;
|
||||
updateField: (
|
||||
key: string,
|
||||
field: pond.FieldSettings,
|
||||
asRoot?: true,
|
||||
otherTeam?: string
|
||||
) => Promise<AxiosResponse<pond.UpdateSiteResponse>>;
|
||||
) => Promise<AxiosResponse<pond.UpdateFieldResponse>>;
|
||||
}
|
||||
|
||||
export const FieldAPIContext = createContext<IFieldAPIContext>({} as IFieldAPIContext);
|
||||
|
|
@ -80,6 +88,30 @@ export default function FieldProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const fieldsPageData = (
|
||||
limit: number,
|
||||
offset: number,
|
||||
order?: "asc" | "desc",
|
||||
orderBy?: string,
|
||||
search?: string,
|
||||
otherTeam?: string,
|
||||
) => {
|
||||
const view = otherTeam ? otherTeam : as
|
||||
return get<pond.ListFieldsPageDataResponse>(
|
||||
pondURL(
|
||||
"/fieldsPage" +
|
||||
"?limit=" +
|
||||
limit +
|
||||
"&offset=" +
|
||||
offset +
|
||||
("&order=" + or(order, "asc")) +
|
||||
("&by=" + or(orderBy, "key")) +
|
||||
(view ? "&as=" + view : "") +
|
||||
(search ? "&search=" + search : "")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const updateField = (key: string, field: pond.FieldSettings, asRoot?: boolean, otherTeam?: string) => {
|
||||
const view = otherTeam ? otherTeam : as
|
||||
if (view)
|
||||
|
|
@ -100,7 +132,8 @@ export default function FieldProvider(props: PropsWithChildren<Props>) {
|
|||
getField,
|
||||
listFields,
|
||||
removeField,
|
||||
updateField
|
||||
updateField,
|
||||
fieldsPageData
|
||||
}}>
|
||||
{children}
|
||||
</FieldAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue