update as in the harvest plan api

This commit is contained in:
csawatzky 2025-04-21 16:02:31 -06:00
parent 0d3f7fa8a6
commit a99ab8b8b5
3 changed files with 16 additions and 13 deletions

View file

@ -7,8 +7,8 @@ import { or } from "utils";
import { pondURL } from "./pond";
export interface IHarvestPlanAPIContext {
addHarvestPlan: (harvestPlan: pond.HarvestPlanSettings) => Promise<any>;
getHarvestPlan: (harvestPlanId: string) => Promise<any>;
addHarvestPlan: (harvestPlan: pond.HarvestPlanSettings, as?: string) => Promise<any>;
getHarvestPlan: (harvestPlanId: string, as?: string) => Promise<any>;
listHarvestPlans: (
limit: number,
offset: number,
@ -24,12 +24,14 @@ export interface IHarvestPlanAPIContext {
offset: number
) => Promise<AxiosResponse<pond.ListHarvestPlanHistoryResponse>>;
removeHarvestPlan: (
harvestPlanId: string
harvestPlanId: string,
as?: string
) => Promise<AxiosResponse<pond.RemoveHarvestPlanResponse>>;
updateHarvestPlan: (
key: string,
harvestPlan: pond.HarvestPlanSettings,
asRoot?: true
asRoot?: true,
as?: string
) => Promise<AxiosResponse<pond.UpdateHarvestPlanResponse>>;
}
@ -42,19 +44,19 @@ interface Props {}
export default function HarvestPlanProvider(props: PropsWithChildren<Props>) {
const { children } = props;
const { get, del, post, put } = useHTTP();
const [{ as }] = useGlobalState();
//const [{ as }] = useGlobalState();
const addHarvestPlan = (harvestPlan: pond.HarvestPlanSettings) => {
const addHarvestPlan = (harvestPlan: pond.HarvestPlanSettings, as?: string) => {
if (as) return post(pondURL("/harvestPlans?as=" + as), harvestPlan);
return post(pondURL("/harvestPlans"), harvestPlan);
};
const getHarvestPlan = (harvestPlanId: string) => {
const getHarvestPlan = (harvestPlanId: string, as?: string) => {
if (as) return get(pondURL("/harvestPlans/" + harvestPlanId + "?as=" + as));
return get(pondURL("/harvestPlans/" + harvestPlanId));
};
const removeHarvestPlan = (key: string) => {
const removeHarvestPlan = (key: string, as?: string) => {
if (as)
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key + "?as=" + as));
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key));
@ -94,7 +96,8 @@ export default function HarvestPlanProvider(props: PropsWithChildren<Props>) {
const updateHarvestPlan = (
key: string,
harvestPlan: pond.HarvestPlanSettings,
asRoot?: boolean
asRoot?: boolean,
as?: string
) => {
if (as)
return put<pond.UpdateHarvestPlanResponse>(