added fields page data api call

This commit is contained in:
csawatzky 2025-08-22 09:39:20 -06:00
parent 96958c12a0
commit 3567190c3a
3 changed files with 37 additions and 4 deletions

View file

@ -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>