adding sum helper
This commit is contained in:
parent
588061d732
commit
02564d8710
|
|
@ -1,10 +1,12 @@
|
||||||
export { FieldLoading } from "@/comps/ui/field-loading";
|
export { FieldLoading } from "@/comps/ui/field-loading";
|
||||||
import { lazify, lazifyMany } from "@/utils/lazify";
|
import { lazify, lazifyMany } from "@/utils/lazify";
|
||||||
import __get from "lodash.get";
|
import __get from "lodash.get";
|
||||||
|
import { sum } from "./utils/sum";
|
||||||
export { guessLabel } from "./utils/guess-label";
|
export { guessLabel } from "./utils/guess-label";
|
||||||
export { fetchLinkParams } from "./comps/form/field/type/TypeLink";
|
export { fetchLinkParams } from "./comps/form/field/type/TypeLink";
|
||||||
export { prasi_gen } from "./gen/prasi_gen";
|
export { prasi_gen } from "./gen/prasi_gen";
|
||||||
|
|
||||||
|
export const _sum = sum;
|
||||||
export const _get = __get;
|
export const _get = __get;
|
||||||
|
|
||||||
export const Accordion = lazify(
|
export const Accordion = lazify(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import get from "lodash.get";
|
||||||
|
|
||||||
|
export const sum = (items: any[], keyName: string) => {
|
||||||
|
return items.reduce(function (a, b) {
|
||||||
|
return (Number(a) || 0) + (Number(get(b, keyName)) || 0);
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue