update as in the grain bag api
This commit is contained in:
parent
9b9f4cdf63
commit
1acbfe36b0
9 changed files with 42 additions and 33 deletions
|
|
@ -9,7 +9,8 @@ import { GrainBag } from "models/GrainBag";
|
|||
export interface IGrainBagInterface {
|
||||
addGrainBag: (
|
||||
name: string,
|
||||
settings: pond.GrainBagSettings
|
||||
settings: pond.GrainBagSettings,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.AddGrainBagResponse>>;
|
||||
listGrainBags: (
|
||||
limit: number,
|
||||
|
|
@ -20,24 +21,28 @@ export interface IGrainBagInterface {
|
|||
keys?: string[],
|
||||
types?: string[],
|
||||
numerical?: boolean,
|
||||
specificUser?: string
|
||||
specificUser?: string,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.ListGrainBagsResponse>>;
|
||||
updateGrainBag: (
|
||||
key: string,
|
||||
name: string,
|
||||
settings: pond.GrainBagSettings
|
||||
settings: pond.GrainBagSettings,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.UpdateGrainBagResponse>>;
|
||||
bulkUpdateGrainBags: (
|
||||
bags: pond.GrainBag[]
|
||||
bags: pond.GrainBag[],
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.BulkGrainBagUpdateResponse>>;
|
||||
getGrainBag: (key: string) => Promise<AxiosResponse<pond.GetGrainBagResponse>>;
|
||||
removeGrainBag: (key: string) => Promise<AxiosResponse<pond.RemoveGrainBagResponse>>;
|
||||
getGrainBag: (key: string, as?: string) => Promise<AxiosResponse<pond.GetGrainBagResponse>>;
|
||||
removeGrainBag: (key: string, as?: string) => Promise<AxiosResponse<pond.RemoveGrainBagResponse>>;
|
||||
listHistory: (
|
||||
id: string,
|
||||
limit: number,
|
||||
offset: number,
|
||||
start?: string,
|
||||
end?: string
|
||||
end?: string,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.ListGrainBagHistoryResponse>>;
|
||||
}
|
||||
|
||||
|
|
@ -48,9 +53,9 @@ interface Props {}
|
|||
export default function GrainBagProvider(props: PropsWithChildren<Props>) {
|
||||
const { children } = props;
|
||||
const { get, del, post, put } = useHTTP();
|
||||
const [{ as }] = useGlobalState();
|
||||
//const [{ as }] = useGlobalState();
|
||||
|
||||
const addGrainBag = (name: string, settings: pond.GrainBagSettings) => {
|
||||
const addGrainBag = (name: string, settings: pond.GrainBagSettings, as?: string) => {
|
||||
if (as) {
|
||||
return post<pond.AddGrainBagResponse>(
|
||||
pondURL("/grainbags?name=" + name + "&as=" + as),
|
||||
|
|
@ -69,7 +74,8 @@ export default function GrainBagProvider(props: PropsWithChildren<Props>) {
|
|||
keys?: string[],
|
||||
types?: string[],
|
||||
numerical?: boolean,
|
||||
specificUser?: string
|
||||
specificUser?: string,
|
||||
as?: string
|
||||
) => {
|
||||
let asText = "";
|
||||
if (as) asText = "&as=" + as;
|
||||
|
|
@ -91,7 +97,7 @@ export default function GrainBagProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const updateGrainBag = (key: string, name: string, settings: pond.GrainBagSettings) => {
|
||||
const updateGrainBag = (key: string, name: string, settings: pond.GrainBagSettings, as?: string) => {
|
||||
if (as) {
|
||||
return put<pond.UpdateGrainBagResponse>(
|
||||
pondURL("/grainbags/" + key + "?as=" + as + "&name=" + name),
|
||||
|
|
@ -104,7 +110,7 @@ export default function GrainBagProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const bulkUpdateGrainBags = (bags: pond.GrainBag[]) => {
|
||||
const bulkUpdateGrainBags = (bags: pond.GrainBag[], as?: string) => {
|
||||
if (as)
|
||||
return put<pond.BulkGrainBagUpdateResponse>(pondURL("/bulkGrainBags/update?as=" + as), {
|
||||
bags: bags
|
||||
|
|
@ -112,21 +118,21 @@ export default function GrainBagProvider(props: PropsWithChildren<Props>) {
|
|||
return put<pond.BulkGrainBagUpdateResponse>(pondURL("/bulkGrainBags/update"), { bags: bags });
|
||||
};
|
||||
|
||||
const removeGrainBag = (key: string) => {
|
||||
const removeGrainBag = (key: string, as?: string) => {
|
||||
if (as) {
|
||||
return del<pond.RemoveGrainBagResponse>(pondURL("/grainbags/" + key + "?as=" + as));
|
||||
}
|
||||
return del<pond.RemoveGrainBagResponse>(pondURL("/grainbags/" + key + "?as=" + as));
|
||||
};
|
||||
|
||||
const getGrainBag = (key: string) => {
|
||||
const getGrainBag = (key: string, as?: string) => {
|
||||
if (as) {
|
||||
return get<pond.GetGrainBagResponse>(pondURL("/grainbags/" + key + "?as=" + as));
|
||||
}
|
||||
return get<pond.GetGrainBagResponse>(pondURL("/grainbags/" + key));
|
||||
};
|
||||
|
||||
const listHistory = (id: string, limit: number, offset: number, start?: string, end?: string) => {
|
||||
const listHistory = (id: string, limit: number, offset: number, start?: string, end?: string, as?: string) => {
|
||||
let url = pondURL(
|
||||
"/grainbags/" +
|
||||
id +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue