finished implementing the custom grain functionality on the grains page and the basic desktop view, and also am now using permissions to disable the buttons ro add/update/remove

This commit is contained in:
csawatzky 2025-12-31 13:58:38 -06:00
parent 2f8897d8ed
commit 586c971795
4 changed files with 244 additions and 21 deletions

View file

@ -22,6 +22,7 @@ export interface IGrainInterface {
types?: string[],
otherTeam?: string,
) => Promise<AxiosResponse<pond.ListGrainsResponse>>;
updateGrain: (key: string, settings: pond.GrainSettings, otherTeam?: string) => Promise<AxiosResponse<pond.UpdateGrainResponse>>
removeGrain: (key: string, otherTeam?: string) => Promise<AxiosResponse<pond.RemoveGrainResponse>>;
}
@ -31,7 +32,7 @@ interface Props {}
export default function GrainProvider(props: PropsWithChildren<Props>) {
const { children } = props;
const { get, del, post } = useHTTP();
const { get, del, post, put } = useHTTP();
const [{ as }] = useGlobalState();
//add
@ -79,7 +80,6 @@ export default function GrainProvider(props: PropsWithChildren<Props>) {
get<pond.ListGrainsResponse>(
pondURL(
"/grains?limit=" +
"?limit=" +
limit +
"&offset=" +
offset +
@ -98,6 +98,19 @@ export default function GrainProvider(props: PropsWithChildren<Props>) {
})
})
};
//update
const updateGrain = (key: string, settings: pond.GrainSettings, otherTeam?: string) => {
const view = otherTeam ? otherTeam : as
if (view) {
return put<pond.UpdateGrainResponse>(
pondURL("/grains/"+ key + "?&as=" + view),
settings
);
}
return put<pond.UpdateGrainResponse>(pondURL("/grains/" + key), settings);
}
//remove
const removeGrain = (key: string, otherTeam?: string) => {
const view = otherTeam ? otherTeam : as
@ -113,6 +126,7 @@ export default function GrainProvider(props: PropsWithChildren<Props>) {
addGrain,
getGrain,
listGrains,
updateGrain,
removeGrain
}}>
{children}