update as in the harvest plan api
This commit is contained in:
parent
0d3f7fa8a6
commit
a99ab8b8b5
3 changed files with 16 additions and 13 deletions
|
|
@ -48,7 +48,7 @@ export default function DuplicateHarvestPlan(props: Props) {
|
||||||
if (title !== "") {
|
if (title !== "") {
|
||||||
planSettings.title = title;
|
planSettings.title = title;
|
||||||
}
|
}
|
||||||
harvestPlanAPI.addHarvestPlan(planSettings).then(resp => {
|
harvestPlanAPI.addHarvestPlan(planSettings, as).then(resp => {
|
||||||
let tasks = planTasks;
|
let tasks = planTasks;
|
||||||
tasks.forEach(task => {
|
tasks.forEach(task => {
|
||||||
task.settings.objectKey = resp.data.harvestPlan;
|
task.settings.objectKey = resp.data.harvestPlan;
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ export default function HarvestSettings(props: Props) {
|
||||||
});
|
});
|
||||||
setNewPlan(HarvestPlan.create(pond.HarvestPlan.fromObject({ settings: newPlanSettings })));
|
setNewPlan(HarvestPlan.create(pond.HarvestPlan.fromObject({ settings: newPlanSettings })));
|
||||||
|
|
||||||
harvestPlanAPI.addHarvestPlan(newPlanSettings).then(resp => {
|
harvestPlanAPI.addHarvestPlan(newPlanSettings, as).then(resp => {
|
||||||
setPlanKey(resp.data.harvestPlan);
|
setPlanKey(resp.data.harvestPlan);
|
||||||
openSnack("Plan Created");
|
openSnack("Plan Created");
|
||||||
});
|
});
|
||||||
|
|
@ -373,7 +373,7 @@ export default function HarvestSettings(props: Props) {
|
||||||
tempPlan.settings.fallEquipment = fallEqCost;
|
tempPlan.settings.fallEquipment = fallEqCost;
|
||||||
if (planKey) {
|
if (planKey) {
|
||||||
harvestPlanAPI
|
harvestPlanAPI
|
||||||
.updateHarvestPlan(planKey, tempPlan.settings)
|
.updateHarvestPlan(planKey, tempPlan.settings, undefined, as)
|
||||||
.then(resp => openSnack("Plan Updated"));
|
.then(resp => openSnack("Plan Updated"));
|
||||||
}
|
}
|
||||||
closeDialog(true, tempPlan);
|
closeDialog(true, tempPlan);
|
||||||
|
|
@ -381,7 +381,7 @@ export default function HarvestSettings(props: Props) {
|
||||||
|
|
||||||
const deletePlan = () => {
|
const deletePlan = () => {
|
||||||
if (planKey) {
|
if (planKey) {
|
||||||
harvestPlanAPI.removeHarvestPlan(planKey).then(resp => {
|
harvestPlanAPI.removeHarvestPlan(planKey, as).then(resp => {
|
||||||
openSnack("Plan Deleted");
|
openSnack("Plan Deleted");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import { or } from "utils";
|
||||||
import { pondURL } from "./pond";
|
import { pondURL } from "./pond";
|
||||||
|
|
||||||
export interface IHarvestPlanAPIContext {
|
export interface IHarvestPlanAPIContext {
|
||||||
addHarvestPlan: (harvestPlan: pond.HarvestPlanSettings) => Promise<any>;
|
addHarvestPlan: (harvestPlan: pond.HarvestPlanSettings, as?: string) => Promise<any>;
|
||||||
getHarvestPlan: (harvestPlanId: string) => Promise<any>;
|
getHarvestPlan: (harvestPlanId: string, as?: string) => Promise<any>;
|
||||||
listHarvestPlans: (
|
listHarvestPlans: (
|
||||||
limit: number,
|
limit: number,
|
||||||
offset: number,
|
offset: number,
|
||||||
|
|
@ -24,12 +24,14 @@ export interface IHarvestPlanAPIContext {
|
||||||
offset: number
|
offset: number
|
||||||
) => Promise<AxiosResponse<pond.ListHarvestPlanHistoryResponse>>;
|
) => Promise<AxiosResponse<pond.ListHarvestPlanHistoryResponse>>;
|
||||||
removeHarvestPlan: (
|
removeHarvestPlan: (
|
||||||
harvestPlanId: string
|
harvestPlanId: string,
|
||||||
|
as?: string
|
||||||
) => Promise<AxiosResponse<pond.RemoveHarvestPlanResponse>>;
|
) => Promise<AxiosResponse<pond.RemoveHarvestPlanResponse>>;
|
||||||
updateHarvestPlan: (
|
updateHarvestPlan: (
|
||||||
key: string,
|
key: string,
|
||||||
harvestPlan: pond.HarvestPlanSettings,
|
harvestPlan: pond.HarvestPlanSettings,
|
||||||
asRoot?: true
|
asRoot?: true,
|
||||||
|
as?: string
|
||||||
) => Promise<AxiosResponse<pond.UpdateHarvestPlanResponse>>;
|
) => Promise<AxiosResponse<pond.UpdateHarvestPlanResponse>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,19 +44,19 @@ interface Props {}
|
||||||
export default function HarvestPlanProvider(props: PropsWithChildren<Props>) {
|
export default function HarvestPlanProvider(props: PropsWithChildren<Props>) {
|
||||||
const { children } = props;
|
const { children } = props;
|
||||||
const { get, del, post, put } = useHTTP();
|
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);
|
if (as) return post(pondURL("/harvestPlans?as=" + as), harvestPlan);
|
||||||
return post(pondURL("/harvestPlans"), 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));
|
if (as) return get(pondURL("/harvestPlans/" + harvestPlanId + "?as=" + as));
|
||||||
return get(pondURL("/harvestPlans/" + harvestPlanId));
|
return get(pondURL("/harvestPlans/" + harvestPlanId));
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeHarvestPlan = (key: string) => {
|
const removeHarvestPlan = (key: string, as?: string) => {
|
||||||
if (as)
|
if (as)
|
||||||
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key + "?as=" + as));
|
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key + "?as=" + as));
|
||||||
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key));
|
return del<pond.RemoveHarvestPlanResponse>(pondURL("/harvestPlans/" + key));
|
||||||
|
|
@ -94,7 +96,8 @@ export default function HarvestPlanProvider(props: PropsWithChildren<Props>) {
|
||||||
const updateHarvestPlan = (
|
const updateHarvestPlan = (
|
||||||
key: string,
|
key: string,
|
||||||
harvestPlan: pond.HarvestPlanSettings,
|
harvestPlan: pond.HarvestPlanSettings,
|
||||||
asRoot?: boolean
|
asRoot?: boolean,
|
||||||
|
as?: string
|
||||||
) => {
|
) => {
|
||||||
if (as)
|
if (as)
|
||||||
return put<pond.UpdateHarvestPlanResponse>(
|
return put<pond.UpdateHarvestPlanResponse>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue