finished designing the list and mobile view of the field list
This commit is contained in:
parent
3567190c3a
commit
4db21a3d0c
9 changed files with 287 additions and 113 deletions
|
|
@ -5,6 +5,7 @@ import { useGlobalState } from "providers";
|
|||
import React, { createContext, PropsWithChildren, useContext } from "react";
|
||||
import { or } from "utils";
|
||||
import { pondURL } from "./pond";
|
||||
import { permissionToString } from "pbHelpers/Permission";
|
||||
|
||||
export interface IFieldAPIContext {
|
||||
addField: (field: pond.FieldSettings, otherTeam?: string) => Promise<any>;
|
||||
|
|
@ -18,14 +19,6 @@ 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,
|
||||
|
|
@ -33,6 +26,14 @@ export interface IFieldAPIContext {
|
|||
asRoot?: true,
|
||||
otherTeam?: string
|
||||
) => Promise<AxiosResponse<pond.UpdateFieldResponse>>;
|
||||
shareAll: (
|
||||
email: string,
|
||||
permissions: pond.Permission[],
|
||||
) => Promise<AxiosResponse<any>>
|
||||
shareAllByKey: (
|
||||
key: string,
|
||||
permissions: pond.Permission[]
|
||||
) => Promise<AxiosResponse<any>>
|
||||
}
|
||||
|
||||
export const FieldAPIContext = createContext<IFieldAPIContext>({} as IFieldAPIContext);
|
||||
|
|
@ -88,30 +89,6 @@ 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)
|
||||
|
|
@ -125,6 +102,36 @@ const view = otherTeam ? otherTeam : as
|
|||
);
|
||||
};
|
||||
|
||||
const shareAll = (email: string, permissions: pond.Permission[]) => {
|
||||
let url = pondURL("/fields/shareAll")
|
||||
if (as) url = url + "?as=" + as
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
post(url, {
|
||||
email: email,
|
||||
permissions: permissions.map(permission => permissionToString(permission))
|
||||
}).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const shareAllByKey = (key: string, permissions: pond.Permission[]) => {
|
||||
let url = pondURL("/fields/shareAllByKey")
|
||||
if (as) url = url + "?as=" + as
|
||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||
post(url, {
|
||||
key: key,
|
||||
permissions: permissions.map(permission => permissionToString(permission))
|
||||
}).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldAPIContext.Provider
|
||||
value={{
|
||||
|
|
@ -133,7 +140,8 @@ const view = otherTeam ? otherTeam : as
|
|||
listFields,
|
||||
removeField,
|
||||
updateField,
|
||||
fieldsPageData
|
||||
shareAll,
|
||||
shareAllByKey
|
||||
}}>
|
||||
{children}
|
||||
</FieldAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue