@layerfi/components 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/dist/esm/index.js +2073 -892
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +426 -51
- package/dist/index.js +2139 -968
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +908 -120
- package/dist/styles/index.css.map +3 -3
- package/index.d.ts +1309 -0
- package/package.json +1 -1
- package/dist/index.css +0 -106
- package/dist/index.css.map +0 -7
- package/dist/index.esm.css +0 -106
- package/dist/index.esm.css.map +0 -7
- package/dist/index.esm.js +0 -252
- package/dist/index.esm.js.map +0 -7
package/dist/esm/index.js
CHANGED
|
@@ -249,11 +249,14 @@ var getBankTransactions = get(
|
|
|
249
249
|
businessId,
|
|
250
250
|
sortBy = "date",
|
|
251
251
|
sortOrder = "DESC"
|
|
252
|
-
}) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}`
|
|
252
|
+
}) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
|
|
253
253
|
);
|
|
254
254
|
var categorizeBankTransaction = put(
|
|
255
255
|
({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
|
|
256
256
|
);
|
|
257
|
+
var matchBankTransaction = put(
|
|
258
|
+
({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/match`
|
|
259
|
+
);
|
|
257
260
|
|
|
258
261
|
// src/api/layer/categories.ts
|
|
259
262
|
var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
|
|
@@ -268,13 +271,14 @@ var createAccount = post(
|
|
|
268
271
|
|
|
269
272
|
// src/api/layer/profit_and_loss.ts
|
|
270
273
|
var getProfitAndLoss = get(
|
|
271
|
-
({ businessId, startDate, endDate }) => `/v1/businesses/${businessId}/reports/profit-and-loss?start_date=${startDate ? encodeURIComponent(startDate) : ""}&end_date=${endDate ? encodeURIComponent(endDate) : ""}`
|
|
274
|
+
({ businessId, startDate, endDate, tagKey, tagValues, reportingBasis }) => `/v1/businesses/${businessId}/reports/profit-and-loss?start_date=${startDate ? encodeURIComponent(startDate) : ""}&end_date=${endDate ? encodeURIComponent(endDate) : ""}${reportingBasis ? `&reporting_basis=${reportingBasis}` : ""}${tagKey ? `&tag_key=${tagKey}` : ""}${tagValues ? `&tag_values=${tagValues}` : ""}`
|
|
272
275
|
);
|
|
273
276
|
|
|
274
277
|
// src/api/layer.ts
|
|
275
278
|
var Layer = {
|
|
276
279
|
authenticate,
|
|
277
280
|
categorizeBankTransaction,
|
|
281
|
+
matchBankTransaction,
|
|
278
282
|
createAccount,
|
|
279
283
|
getBalanceSheet,
|
|
280
284
|
getBankTransactions,
|
|
@@ -299,7 +303,9 @@ var LayerContext = createContext({
|
|
|
299
303
|
categories: [],
|
|
300
304
|
apiUrl: "",
|
|
301
305
|
theme: void 0,
|
|
302
|
-
|
|
306
|
+
colors: {},
|
|
307
|
+
setTheme: () => void 0,
|
|
308
|
+
getColor: (_shade) => void 0
|
|
303
309
|
});
|
|
304
310
|
|
|
305
311
|
// src/hooks/useLayerContext/useLayerContext.tsx
|
|
@@ -557,7 +563,10 @@ var BalanceSheet = () => {
|
|
|
557
563
|
};
|
|
558
564
|
|
|
559
565
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
560
|
-
import
|
|
566
|
+
import React50, { useState as useState9, useMemo as useMemo2 } from "react";
|
|
567
|
+
|
|
568
|
+
// src/config/general.ts
|
|
569
|
+
var DATE_FORMAT = "LLL d, yyyy";
|
|
561
570
|
|
|
562
571
|
// src/hooks/useBankTransactions/useBankTransactions.tsx
|
|
563
572
|
import useSWR2 from "swr";
|
|
@@ -610,6 +619,40 @@ var useBankTransactions = () => {
|
|
|
610
619
|
}
|
|
611
620
|
});
|
|
612
621
|
};
|
|
622
|
+
const match = (id, matchId) => {
|
|
623
|
+
const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
|
|
624
|
+
if (foundBT) {
|
|
625
|
+
updateOneLocal({ ...foundBT, processing: true, error: void 0 });
|
|
626
|
+
}
|
|
627
|
+
return Layer.matchBankTransaction(apiUrl, auth.access_token, {
|
|
628
|
+
params: { businessId, bankTransactionId: id },
|
|
629
|
+
body: { match_id: matchId, type: "Confirm_Match" /* CONFIRM_MATCH */ }
|
|
630
|
+
}).then(({ data: bt, errors }) => {
|
|
631
|
+
const newBT = data?.find(
|
|
632
|
+
(x) => x.business_id === businessId && x.id === id
|
|
633
|
+
);
|
|
634
|
+
if (newBT) {
|
|
635
|
+
newBT.recently_categorized = true;
|
|
636
|
+
newBT.match = bt;
|
|
637
|
+
updateOneLocal(newBT);
|
|
638
|
+
}
|
|
639
|
+
if (errors) {
|
|
640
|
+
console.error(errors);
|
|
641
|
+
throw errors;
|
|
642
|
+
}
|
|
643
|
+
}).catch((err) => {
|
|
644
|
+
const newBT = data?.find(
|
|
645
|
+
(x) => x.business_id === businessId && x.id === id
|
|
646
|
+
);
|
|
647
|
+
if (newBT) {
|
|
648
|
+
updateOneLocal({
|
|
649
|
+
...newBT,
|
|
650
|
+
error: err.message,
|
|
651
|
+
processing: false
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
};
|
|
613
656
|
const updateOneLocal = (newBankTransaction) => {
|
|
614
657
|
const updatedData = data?.map(
|
|
615
658
|
(bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
|
|
@@ -627,6 +670,7 @@ var useBankTransactions = () => {
|
|
|
627
670
|
refetch,
|
|
628
671
|
error: responseError || error,
|
|
629
672
|
categorize,
|
|
673
|
+
match,
|
|
630
674
|
updateOneLocal
|
|
631
675
|
};
|
|
632
676
|
};
|
|
@@ -654,11 +698,185 @@ var useElementSize = (callback) => {
|
|
|
654
698
|
return ref;
|
|
655
699
|
};
|
|
656
700
|
|
|
701
|
+
// src/types/categories.ts
|
|
702
|
+
function hasSuggestions(categorization) {
|
|
703
|
+
return categorization.suggestions !== void 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
657
706
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
658
|
-
import
|
|
707
|
+
import React40, { useRef as useRef11, useState as useState8 } from "react";
|
|
708
|
+
|
|
709
|
+
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
710
|
+
import React38, { useRef as useRef10, useState as useState7 } from "react";
|
|
711
|
+
|
|
712
|
+
// src/icons/Scissors.tsx
|
|
713
|
+
import * as React8 from "react";
|
|
714
|
+
var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React8.createElement(
|
|
715
|
+
"svg",
|
|
716
|
+
{
|
|
717
|
+
viewBox: "0 0 11 11",
|
|
718
|
+
fill: "none",
|
|
719
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
720
|
+
...props,
|
|
721
|
+
width: size,
|
|
722
|
+
height: size
|
|
723
|
+
},
|
|
724
|
+
/* @__PURE__ */ React8.createElement(
|
|
725
|
+
"path",
|
|
726
|
+
{
|
|
727
|
+
d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
728
|
+
stroke: "currentColor",
|
|
729
|
+
strokeLinecap: "round",
|
|
730
|
+
strokeLinejoin: "round"
|
|
731
|
+
},
|
|
732
|
+
/* @__PURE__ */ React8.createElement(
|
|
733
|
+
"animate",
|
|
734
|
+
{
|
|
735
|
+
attributeName: "d",
|
|
736
|
+
className: "animateOnHover",
|
|
737
|
+
values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
738
|
+
begin: "indefinite",
|
|
739
|
+
dur: "400ms",
|
|
740
|
+
repeatCount: "1",
|
|
741
|
+
fill: "freeze",
|
|
742
|
+
calcMode: "linear",
|
|
743
|
+
keyTimes: "0;0.5;1"
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
),
|
|
747
|
+
/* @__PURE__ */ React8.createElement(
|
|
748
|
+
"path",
|
|
749
|
+
{
|
|
750
|
+
d: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
|
|
751
|
+
stroke: "currentColor",
|
|
752
|
+
strokeLinecap: "round",
|
|
753
|
+
strokeLinejoin: "round"
|
|
754
|
+
},
|
|
755
|
+
/* @__PURE__ */ React8.createElement(
|
|
756
|
+
"animate",
|
|
757
|
+
{
|
|
758
|
+
attributeName: "d",
|
|
759
|
+
className: "animateOnHover",
|
|
760
|
+
values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
|
|
761
|
+
begin: "indefinite",
|
|
762
|
+
dur: "400ms",
|
|
763
|
+
repeatCount: "1",
|
|
764
|
+
fill: "freeze",
|
|
765
|
+
calcMode: "linear",
|
|
766
|
+
keyTimes: "0;0.5;1"
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
),
|
|
770
|
+
/* @__PURE__ */ React8.createElement(
|
|
771
|
+
"path",
|
|
772
|
+
{
|
|
773
|
+
d: "M9.16668 1.83325L3.72168 7.27825",
|
|
774
|
+
stroke: "currentColor",
|
|
775
|
+
strokeLinecap: "round",
|
|
776
|
+
strokeLinejoin: "round"
|
|
777
|
+
},
|
|
778
|
+
/* @__PURE__ */ React8.createElement(
|
|
779
|
+
"animate",
|
|
780
|
+
{
|
|
781
|
+
attributeName: "d",
|
|
782
|
+
className: "animateOnHover",
|
|
783
|
+
values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
|
|
784
|
+
begin: "indefinite",
|
|
785
|
+
dur: "400ms",
|
|
786
|
+
repeatCount: "1",
|
|
787
|
+
fill: "freeze",
|
|
788
|
+
calcMode: "linear",
|
|
789
|
+
keyTimes: "0;0.5;1"
|
|
790
|
+
}
|
|
791
|
+
)
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ React8.createElement(
|
|
794
|
+
"path",
|
|
795
|
+
{
|
|
796
|
+
d: "M6.63232 6.63672L9.16691 9.16672",
|
|
797
|
+
stroke: "currentColor",
|
|
798
|
+
strokeLinecap: "round",
|
|
799
|
+
strokeLinejoin: "round"
|
|
800
|
+
},
|
|
801
|
+
/* @__PURE__ */ React8.createElement(
|
|
802
|
+
"animate",
|
|
803
|
+
{
|
|
804
|
+
attributeName: "d",
|
|
805
|
+
className: "animateOnHover",
|
|
806
|
+
values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
|
|
807
|
+
begin: "indefinite",
|
|
808
|
+
dur: "400ms",
|
|
809
|
+
repeatCount: "1",
|
|
810
|
+
fill: "freeze",
|
|
811
|
+
calcMode: "linear",
|
|
812
|
+
keyTimes: "0;0.5;1"
|
|
813
|
+
}
|
|
814
|
+
)
|
|
815
|
+
),
|
|
816
|
+
/* @__PURE__ */ React8.createElement(
|
|
817
|
+
"path",
|
|
818
|
+
{
|
|
819
|
+
d: "M3.72168 3.72168L5.50001 5.50001",
|
|
820
|
+
stroke: "currentColor",
|
|
821
|
+
strokeLinecap: "round",
|
|
822
|
+
strokeLinejoin: "round"
|
|
823
|
+
},
|
|
824
|
+
/* @__PURE__ */ React8.createElement(
|
|
825
|
+
"animate",
|
|
826
|
+
{
|
|
827
|
+
attributeName: "d",
|
|
828
|
+
className: "animateOnHover",
|
|
829
|
+
values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
|
|
830
|
+
begin: "indefinite",
|
|
831
|
+
dur: "400ms",
|
|
832
|
+
repeatCount: "1",
|
|
833
|
+
fill: "freeze",
|
|
834
|
+
calcMode: "linear",
|
|
835
|
+
keyTimes: "0;0.5;1"
|
|
836
|
+
}
|
|
837
|
+
)
|
|
838
|
+
)
|
|
839
|
+
);
|
|
840
|
+
var Scissors_default = Scissors;
|
|
841
|
+
|
|
842
|
+
// src/icons/X.tsx
|
|
843
|
+
import * as React9 from "react";
|
|
844
|
+
var X = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElement(
|
|
845
|
+
"svg",
|
|
846
|
+
{
|
|
847
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
848
|
+
viewBox: "0 0 18 18",
|
|
849
|
+
fill: "none",
|
|
850
|
+
...props,
|
|
851
|
+
width: size,
|
|
852
|
+
height: size
|
|
853
|
+
},
|
|
854
|
+
/* @__PURE__ */ React9.createElement(
|
|
855
|
+
"path",
|
|
856
|
+
{
|
|
857
|
+
d: "M13.5 4.5L4.5 13.5",
|
|
858
|
+
stroke: "currentColor",
|
|
859
|
+
strokeLinecap: "round",
|
|
860
|
+
strokeLinejoin: "round"
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
/* @__PURE__ */ React9.createElement(
|
|
864
|
+
"path",
|
|
865
|
+
{
|
|
866
|
+
d: "M4.5 4.5L13.5 13.5",
|
|
867
|
+
stroke: "currentColor",
|
|
868
|
+
strokeLinecap: "round",
|
|
869
|
+
strokeLinejoin: "round"
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
);
|
|
873
|
+
var X_default = X;
|
|
874
|
+
|
|
875
|
+
// src/components/Badge/Badge.tsx
|
|
876
|
+
import React21 from "react";
|
|
659
877
|
|
|
660
878
|
// src/components/Button/Button.tsx
|
|
661
|
-
import
|
|
879
|
+
import React10, { useRef as useRef3 } from "react";
|
|
662
880
|
import classNames from "classnames";
|
|
663
881
|
var Button = ({
|
|
664
882
|
className,
|
|
@@ -667,6 +885,7 @@ var Button = ({
|
|
|
667
885
|
leftIcon,
|
|
668
886
|
rightIcon,
|
|
669
887
|
iconOnly,
|
|
888
|
+
iconAsPrimary = false,
|
|
670
889
|
...props
|
|
671
890
|
}) => {
|
|
672
891
|
const buttonRef = useRef3(null);
|
|
@@ -682,6 +901,7 @@ var Button = ({
|
|
|
682
901
|
"Layer__btn",
|
|
683
902
|
`Layer__btn--${variant}`,
|
|
684
903
|
iconOnly ? "Layer__btn--icon-only" : "",
|
|
904
|
+
iconAsPrimary && "Layer__btn--with-primary-icon",
|
|
685
905
|
className
|
|
686
906
|
);
|
|
687
907
|
const startAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
@@ -690,7 +910,7 @@ var Button = ({
|
|
|
690
910
|
const stopAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
691
911
|
(el) => el.endElement()
|
|
692
912
|
);
|
|
693
|
-
return /* @__PURE__ */
|
|
913
|
+
return /* @__PURE__ */ React10.createElement(
|
|
694
914
|
"button",
|
|
695
915
|
{
|
|
696
916
|
...props,
|
|
@@ -699,16 +919,34 @@ var Button = ({
|
|
|
699
919
|
onMouseLeave: stopAnimation,
|
|
700
920
|
ref: buttonRef
|
|
701
921
|
},
|
|
702
|
-
/* @__PURE__ */
|
|
922
|
+
/* @__PURE__ */ React10.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ React10.createElement(
|
|
923
|
+
"span",
|
|
924
|
+
{
|
|
925
|
+
className: classNames(
|
|
926
|
+
"Layer__btn-icon Layer__btn-icon--left",
|
|
927
|
+
iconAsPrimary && "Layer__btn-icon--primary"
|
|
928
|
+
)
|
|
929
|
+
},
|
|
930
|
+
leftIcon
|
|
931
|
+
), !iconOnly && /* @__PURE__ */ React10.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ React10.createElement(
|
|
932
|
+
"span",
|
|
933
|
+
{
|
|
934
|
+
className: classNames(
|
|
935
|
+
"Layer__btn-icon Layer__btn-icon--right",
|
|
936
|
+
iconAsPrimary && "Layer__btn-icon--primary"
|
|
937
|
+
)
|
|
938
|
+
},
|
|
939
|
+
rightIcon
|
|
940
|
+
))
|
|
703
941
|
);
|
|
704
942
|
};
|
|
705
943
|
|
|
706
944
|
// src/components/Button/SubmitButton.tsx
|
|
707
|
-
import
|
|
945
|
+
import React18 from "react";
|
|
708
946
|
|
|
709
947
|
// src/icons/AlertCircle.tsx
|
|
710
|
-
import * as
|
|
711
|
-
var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
948
|
+
import * as React11 from "react";
|
|
949
|
+
var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createElement(
|
|
712
950
|
"svg",
|
|
713
951
|
{
|
|
714
952
|
viewBox: "0 0 18 18",
|
|
@@ -718,7 +956,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
718
956
|
width: size,
|
|
719
957
|
height: size
|
|
720
958
|
},
|
|
721
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ React11.createElement(
|
|
722
960
|
"path",
|
|
723
961
|
{
|
|
724
962
|
d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
|
|
@@ -727,7 +965,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
727
965
|
strokeLinejoin: "round"
|
|
728
966
|
}
|
|
729
967
|
),
|
|
730
|
-
/* @__PURE__ */
|
|
968
|
+
/* @__PURE__ */ React11.createElement(
|
|
731
969
|
"path",
|
|
732
970
|
{
|
|
733
971
|
d: "M9 6V9",
|
|
@@ -736,7 +974,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
736
974
|
strokeLinejoin: "round"
|
|
737
975
|
}
|
|
738
976
|
),
|
|
739
|
-
/* @__PURE__ */
|
|
977
|
+
/* @__PURE__ */ React11.createElement(
|
|
740
978
|
"path",
|
|
741
979
|
{
|
|
742
980
|
d: "M9 12H9.0075",
|
|
@@ -749,8 +987,8 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
749
987
|
var AlertCircle_default = AlertCircle;
|
|
750
988
|
|
|
751
989
|
// src/icons/Check.tsx
|
|
752
|
-
import * as
|
|
753
|
-
var Check = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
990
|
+
import * as React12 from "react";
|
|
991
|
+
var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
754
992
|
"svg",
|
|
755
993
|
{
|
|
756
994
|
viewBox: "0 0 18 18",
|
|
@@ -760,7 +998,7 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
|
|
|
760
998
|
width: size,
|
|
761
999
|
height: size
|
|
762
1000
|
},
|
|
763
|
-
/* @__PURE__ */
|
|
1001
|
+
/* @__PURE__ */ React12.createElement(
|
|
764
1002
|
"path",
|
|
765
1003
|
{
|
|
766
1004
|
d: "M15 4.5L6.75 12.75L3 9",
|
|
@@ -773,8 +1011,8 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
|
|
|
773
1011
|
var Check_default = Check;
|
|
774
1012
|
|
|
775
1013
|
// src/icons/CheckCircle.tsx
|
|
776
|
-
import * as
|
|
777
|
-
var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1014
|
+
import * as React13 from "react";
|
|
1015
|
+
var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React13.createElement(
|
|
778
1016
|
"svg",
|
|
779
1017
|
{
|
|
780
1018
|
viewBox: "0 0 18 18",
|
|
@@ -784,7 +1022,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
784
1022
|
width: size,
|
|
785
1023
|
height: size
|
|
786
1024
|
},
|
|
787
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ React13.createElement(
|
|
788
1026
|
"path",
|
|
789
1027
|
{
|
|
790
1028
|
d: "M16.5 8.30999V8.99999C16.4991 10.6173 15.9754 12.191 15.007 13.4864C14.0386 14.7817 12.6775 15.7293 11.1265 16.1879C9.57557 16.6465 7.91794 16.5914 6.40085 16.0309C4.88375 15.4704 3.58848 14.4346 2.70821 13.0778C1.82794 11.721 1.40984 10.116 1.51625 8.50223C1.62266 6.88841 2.2479 5.35223 3.2987 4.12279C4.34951 2.89335 5.76958 2.03653 7.34713 1.6801C8.92469 1.32367 10.5752 1.48674 12.0525 2.14499",
|
|
@@ -793,7 +1031,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
793
1031
|
strokeLinejoin: "round"
|
|
794
1032
|
}
|
|
795
1033
|
),
|
|
796
|
-
/* @__PURE__ */
|
|
1034
|
+
/* @__PURE__ */ React13.createElement(
|
|
797
1035
|
"path",
|
|
798
1036
|
{
|
|
799
1037
|
d: "M16.5 3L9 10.5075L6.75 8.2575",
|
|
@@ -806,8 +1044,8 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
806
1044
|
var CheckCircle_default = CheckCircle;
|
|
807
1045
|
|
|
808
1046
|
// src/icons/Loader.tsx
|
|
809
|
-
import * as
|
|
810
|
-
var Loader = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1047
|
+
import * as React14 from "react";
|
|
1048
|
+
var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React14.createElement(
|
|
811
1049
|
"svg",
|
|
812
1050
|
{
|
|
813
1051
|
viewBox: "0 0 18 18",
|
|
@@ -817,7 +1055,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
817
1055
|
width: size,
|
|
818
1056
|
height: size
|
|
819
1057
|
},
|
|
820
|
-
/* @__PURE__ */
|
|
1058
|
+
/* @__PURE__ */ React14.createElement(
|
|
821
1059
|
"path",
|
|
822
1060
|
{
|
|
823
1061
|
d: "M9 1.5V4.5",
|
|
@@ -826,7 +1064,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
826
1064
|
strokeLinejoin: "round"
|
|
827
1065
|
}
|
|
828
1066
|
),
|
|
829
|
-
/* @__PURE__ */
|
|
1067
|
+
/* @__PURE__ */ React14.createElement(
|
|
830
1068
|
"path",
|
|
831
1069
|
{
|
|
832
1070
|
d: "M9 13.5V16.5",
|
|
@@ -835,7 +1073,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
835
1073
|
strokeLinejoin: "round"
|
|
836
1074
|
}
|
|
837
1075
|
),
|
|
838
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ React14.createElement(
|
|
839
1077
|
"path",
|
|
840
1078
|
{
|
|
841
1079
|
d: "M3.6975 3.6975L5.82 5.82",
|
|
@@ -844,7 +1082,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
844
1082
|
strokeLinejoin: "round"
|
|
845
1083
|
}
|
|
846
1084
|
),
|
|
847
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ React14.createElement(
|
|
848
1086
|
"path",
|
|
849
1087
|
{
|
|
850
1088
|
d: "M12.18 12.18L14.3025 14.3025",
|
|
@@ -853,7 +1091,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
853
1091
|
strokeLinejoin: "round"
|
|
854
1092
|
}
|
|
855
1093
|
),
|
|
856
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ React14.createElement(
|
|
857
1095
|
"path",
|
|
858
1096
|
{
|
|
859
1097
|
d: "M1.5 9H4.5",
|
|
@@ -862,7 +1100,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
862
1100
|
strokeLinejoin: "round"
|
|
863
1101
|
}
|
|
864
1102
|
),
|
|
865
|
-
/* @__PURE__ */
|
|
1103
|
+
/* @__PURE__ */ React14.createElement(
|
|
866
1104
|
"path",
|
|
867
1105
|
{
|
|
868
1106
|
d: "M13.5 9H16.5",
|
|
@@ -871,7 +1109,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
871
1109
|
strokeLinejoin: "round"
|
|
872
1110
|
}
|
|
873
1111
|
),
|
|
874
|
-
/* @__PURE__ */
|
|
1112
|
+
/* @__PURE__ */ React14.createElement(
|
|
875
1113
|
"path",
|
|
876
1114
|
{
|
|
877
1115
|
d: "M3.6975 14.3025L5.82 12.18",
|
|
@@ -880,7 +1118,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
880
1118
|
strokeLinejoin: "round"
|
|
881
1119
|
}
|
|
882
1120
|
),
|
|
883
|
-
/* @__PURE__ */
|
|
1121
|
+
/* @__PURE__ */ React14.createElement(
|
|
884
1122
|
"path",
|
|
885
1123
|
{
|
|
886
1124
|
d: "M12.18 5.82L14.3025 3.6975",
|
|
@@ -892,15 +1130,57 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
892
1130
|
);
|
|
893
1131
|
var Loader_default = Loader;
|
|
894
1132
|
|
|
1133
|
+
// src/icons/Save.tsx
|
|
1134
|
+
import * as React15 from "react";
|
|
1135
|
+
var Save = ({ size = 18, ...props }) => /* @__PURE__ */ React15.createElement(
|
|
1136
|
+
"svg",
|
|
1137
|
+
{
|
|
1138
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1139
|
+
viewBox: "0 0 18 18",
|
|
1140
|
+
fill: "none",
|
|
1141
|
+
...props,
|
|
1142
|
+
width: size,
|
|
1143
|
+
height: size
|
|
1144
|
+
},
|
|
1145
|
+
/* @__PURE__ */ React15.createElement(
|
|
1146
|
+
"path",
|
|
1147
|
+
{
|
|
1148
|
+
d: "M14.25 15.75H3.75C3.35218 15.75 2.97064 15.592 2.68934 15.3107C2.40804 15.0294 2.25 14.6478 2.25 14.25V3.75C2.25 3.35218 2.40804 2.97064 2.68934 2.68934C2.97064 2.40804 3.35218 2.25 3.75 2.25H12L15.75 6V14.25C15.75 14.6478 15.592 15.0294 15.3107 15.3107C15.0294 15.592 14.6478 15.75 14.25 15.75Z",
|
|
1149
|
+
stroke: "currentColor",
|
|
1150
|
+
strokeLinecap: "round",
|
|
1151
|
+
strokeLinejoin: "round"
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ React15.createElement(
|
|
1155
|
+
"path",
|
|
1156
|
+
{
|
|
1157
|
+
d: "M12.75 15.75V9.75H5.25V15.75",
|
|
1158
|
+
stroke: "currentColor",
|
|
1159
|
+
strokeLinecap: "round",
|
|
1160
|
+
strokeLinejoin: "round"
|
|
1161
|
+
}
|
|
1162
|
+
),
|
|
1163
|
+
/* @__PURE__ */ React15.createElement(
|
|
1164
|
+
"path",
|
|
1165
|
+
{
|
|
1166
|
+
d: "M5.25 2.25V6H11.25",
|
|
1167
|
+
stroke: "currentColor",
|
|
1168
|
+
strokeLinecap: "round",
|
|
1169
|
+
strokeLinejoin: "round"
|
|
1170
|
+
}
|
|
1171
|
+
)
|
|
1172
|
+
);
|
|
1173
|
+
var Save_default = Save;
|
|
1174
|
+
|
|
895
1175
|
// src/components/Tooltip/Tooltip.tsx
|
|
896
|
-
import
|
|
1176
|
+
import React17, {
|
|
897
1177
|
forwardRef,
|
|
898
1178
|
isValidElement,
|
|
899
1179
|
cloneElement
|
|
900
1180
|
} from "react";
|
|
901
1181
|
|
|
902
1182
|
// src/components/Tooltip/useTooltip.ts
|
|
903
|
-
import
|
|
1183
|
+
import React16, { useState as useState3 } from "react";
|
|
904
1184
|
import {
|
|
905
1185
|
useFloating,
|
|
906
1186
|
autoUpdate,
|
|
@@ -914,9 +1194,9 @@ import {
|
|
|
914
1194
|
useInteractions,
|
|
915
1195
|
useTransitionStyles
|
|
916
1196
|
} from "@floating-ui/react";
|
|
917
|
-
var TooltipContext =
|
|
1197
|
+
var TooltipContext = React16.createContext(null);
|
|
918
1198
|
var useTooltipContext = () => {
|
|
919
|
-
const context =
|
|
1199
|
+
const context = React16.useContext(TooltipContext);
|
|
920
1200
|
if (context == null) {
|
|
921
1201
|
throw new Error("Tooltip components must be wrapped in <Tooltip />");
|
|
922
1202
|
}
|
|
@@ -962,11 +1242,13 @@ var useTooltip = ({
|
|
|
962
1242
|
const interactions = useInteractions([hover, focus, dismiss, role]);
|
|
963
1243
|
const { isMounted, styles } = useTransitionStyles(context, {
|
|
964
1244
|
initial: {
|
|
965
|
-
opacity: 0
|
|
1245
|
+
opacity: 0,
|
|
1246
|
+
transform: "scale(0.7)",
|
|
1247
|
+
color: "transparent"
|
|
966
1248
|
},
|
|
967
|
-
duration:
|
|
1249
|
+
duration: 300
|
|
968
1250
|
});
|
|
969
|
-
return
|
|
1251
|
+
return React16.useMemo(
|
|
970
1252
|
() => ({
|
|
971
1253
|
open,
|
|
972
1254
|
setOpen,
|
|
@@ -987,7 +1269,7 @@ var Tooltip = ({
|
|
|
987
1269
|
...options
|
|
988
1270
|
}) => {
|
|
989
1271
|
const tooltip = useTooltip(options);
|
|
990
|
-
return /* @__PURE__ */
|
|
1272
|
+
return /* @__PURE__ */ React17.createElement(TooltipContext.Provider, { value: tooltip }, children);
|
|
991
1273
|
};
|
|
992
1274
|
var TooltipTrigger = forwardRef(function TooltipTrigger2({ children, asChild = false, ...props }, propRef) {
|
|
993
1275
|
const context = useTooltipContext();
|
|
@@ -1004,7 +1286,7 @@ var TooltipTrigger = forwardRef(function TooltipTrigger2({ children, asChild = f
|
|
|
1004
1286
|
})
|
|
1005
1287
|
);
|
|
1006
1288
|
}
|
|
1007
|
-
return /* @__PURE__ */
|
|
1289
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1008
1290
|
"span",
|
|
1009
1291
|
{
|
|
1010
1292
|
ref,
|
|
@@ -1020,18 +1302,17 @@ var TooltipContent = forwardRef(function TooltipContent2({ style, className, ...
|
|
|
1020
1302
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
1021
1303
|
if (!context.open || context.disabled)
|
|
1022
1304
|
return null;
|
|
1023
|
-
return /* @__PURE__ */
|
|
1305
|
+
return /* @__PURE__ */ React17.createElement(FloatingPortal, null, /* @__PURE__ */ React17.createElement(
|
|
1024
1306
|
"div",
|
|
1025
1307
|
{
|
|
1026
1308
|
ref,
|
|
1027
1309
|
className,
|
|
1028
1310
|
style: {
|
|
1029
|
-
...context.
|
|
1030
|
-
...context.floatingStyles,
|
|
1031
|
-
...style
|
|
1311
|
+
...context.floatingStyles
|
|
1032
1312
|
},
|
|
1033
1313
|
...context.getFloatingProps(props)
|
|
1034
|
-
}
|
|
1314
|
+
},
|
|
1315
|
+
/* @__PURE__ */ React17.createElement("div", { className: "Layer__tooltip-content ", style: { ...context.styles } }, props.children)
|
|
1035
1316
|
));
|
|
1036
1317
|
});
|
|
1037
1318
|
|
|
@@ -1039,15 +1320,19 @@ var TooltipContent = forwardRef(function TooltipContent2({ style, className, ...
|
|
|
1039
1320
|
import classNames2 from "classnames";
|
|
1040
1321
|
var buildRightIcon = ({
|
|
1041
1322
|
processing,
|
|
1042
|
-
error
|
|
1323
|
+
error,
|
|
1324
|
+
action
|
|
1043
1325
|
}) => {
|
|
1044
1326
|
if (processing) {
|
|
1045
|
-
return /* @__PURE__ */
|
|
1327
|
+
return /* @__PURE__ */ React18.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
|
|
1046
1328
|
}
|
|
1047
1329
|
if (error) {
|
|
1048
|
-
return /* @__PURE__ */
|
|
1330
|
+
return /* @__PURE__ */ React18.createElement(Tooltip, { offset: 12 }, /* @__PURE__ */ React18.createElement(TooltipTrigger, null, /* @__PURE__ */ React18.createElement(AlertCircle_default, { size: 14 })), /* @__PURE__ */ React18.createElement(TooltipContent, { className: "Layer__tooltip" }, error));
|
|
1049
1331
|
}
|
|
1050
|
-
|
|
1332
|
+
if (action === "update" /* UPDATE */) {
|
|
1333
|
+
return /* @__PURE__ */ React18.createElement("span", { className: "Layer__pt-2" }, /* @__PURE__ */ React18.createElement(Save_default, { size: 14 }));
|
|
1334
|
+
}
|
|
1335
|
+
return /* @__PURE__ */ React18.createElement("span", null, /* @__PURE__ */ React18.createElement(Check_default, { className: "Layer__btn-icon--on-active", size: 14 }), /* @__PURE__ */ React18.createElement(
|
|
1051
1336
|
CheckCircle_default,
|
|
1052
1337
|
{
|
|
1053
1338
|
className: "Layer__btn-icon--on-inactive",
|
|
@@ -1063,345 +1348,436 @@ var SubmitButton = ({
|
|
|
1063
1348
|
disabled,
|
|
1064
1349
|
error,
|
|
1065
1350
|
children,
|
|
1351
|
+
action = "save" /* SAVE */,
|
|
1066
1352
|
...props
|
|
1067
1353
|
}) => {
|
|
1068
1354
|
const baseClassName = classNames2(
|
|
1069
1355
|
active ? "Layer__btn--active" : "",
|
|
1070
1356
|
className
|
|
1071
1357
|
);
|
|
1072
|
-
return /* @__PURE__ */
|
|
1358
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1073
1359
|
Button,
|
|
1074
1360
|
{
|
|
1075
1361
|
...props,
|
|
1076
1362
|
className: baseClassName,
|
|
1077
1363
|
variant: "primary" /* primary */,
|
|
1078
1364
|
disabled: processing || disabled,
|
|
1079
|
-
rightIcon: buildRightIcon({ processing, error })
|
|
1365
|
+
rightIcon: buildRightIcon({ processing, error, action }),
|
|
1366
|
+
iconAsPrimary: true
|
|
1080
1367
|
},
|
|
1081
1368
|
children
|
|
1082
1369
|
);
|
|
1083
1370
|
};
|
|
1084
1371
|
|
|
1085
|
-
// src/components/
|
|
1086
|
-
import
|
|
1087
|
-
import
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
bankTransaction,
|
|
1095
|
-
name,
|
|
1096
|
-
value,
|
|
1097
|
-
onChange,
|
|
1098
|
-
disabled,
|
|
1099
|
-
className
|
|
1372
|
+
// src/components/Button/IconButton.tsx
|
|
1373
|
+
import React19 from "react";
|
|
1374
|
+
import classNames3 from "classnames";
|
|
1375
|
+
var IconButton = ({
|
|
1376
|
+
className,
|
|
1377
|
+
children,
|
|
1378
|
+
icon,
|
|
1379
|
+
active,
|
|
1380
|
+
...props
|
|
1100
1381
|
}) => {
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
{
|
|
1104
|
-
|
|
1105
|
-
options: bankTransaction.categorization_flow.suggestions
|
|
1106
|
-
}
|
|
1107
|
-
] : [];
|
|
1108
|
-
const categoryOptions = (categories || []).map((category) => {
|
|
1109
|
-
if (category?.subCategories && category?.subCategories?.length > 0) {
|
|
1110
|
-
return {
|
|
1111
|
-
label: category.display_name,
|
|
1112
|
-
options: category.subCategories
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
return {
|
|
1116
|
-
label: category.display_name,
|
|
1117
|
-
options: [category]
|
|
1118
|
-
};
|
|
1119
|
-
}).filter((x) => x);
|
|
1120
|
-
const options = [...suggestedOptions, ...categoryOptions];
|
|
1121
|
-
return /* @__PURE__ */ React16.createElement(
|
|
1122
|
-
Select,
|
|
1123
|
-
{
|
|
1124
|
-
name,
|
|
1125
|
-
className: `Layer__category-menu Layer__select ${className ?? ""}`,
|
|
1126
|
-
classNamePrefix: "Layer__select",
|
|
1127
|
-
options,
|
|
1128
|
-
isSearchable: true,
|
|
1129
|
-
value,
|
|
1130
|
-
onChange: (newValue) => newValue && onChange(newValue),
|
|
1131
|
-
getOptionLabel: (category) => category.display_name,
|
|
1132
|
-
getOptionValue: (category) => category.stable_name || category.category,
|
|
1133
|
-
menuPortalTarget: document.body,
|
|
1134
|
-
styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
|
|
1135
|
-
components: { DropdownIndicator },
|
|
1136
|
-
isDisabled: disabled
|
|
1137
|
-
}
|
|
1382
|
+
const baseClassName = classNames3(
|
|
1383
|
+
"Layer__icon-btn",
|
|
1384
|
+
`Layer__icon-btn--${active ? "active" : "inactive"}`,
|
|
1385
|
+
className
|
|
1138
1386
|
);
|
|
1387
|
+
return /* @__PURE__ */ React19.createElement("button", { ...props, className: baseClassName }, icon);
|
|
1139
1388
|
};
|
|
1140
1389
|
|
|
1141
|
-
// src/components/
|
|
1142
|
-
import
|
|
1390
|
+
// src/components/Button/TextButton.tsx
|
|
1391
|
+
import React20 from "react";
|
|
1392
|
+
import classNames4 from "classnames";
|
|
1393
|
+
var TextButton = ({
|
|
1394
|
+
className,
|
|
1395
|
+
children,
|
|
1396
|
+
...props
|
|
1397
|
+
}) => {
|
|
1398
|
+
const baseClassName = classNames4("Layer__text-btn", className);
|
|
1399
|
+
return /* @__PURE__ */ React20.createElement("button", { ...props, className: baseClassName }, children);
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// src/components/Badge/Badge.tsx
|
|
1403
|
+
import classNames5 from "classnames";
|
|
1404
|
+
var Badge = ({
|
|
1405
|
+
icon,
|
|
1406
|
+
onClick,
|
|
1407
|
+
children,
|
|
1408
|
+
tooltip,
|
|
1409
|
+
size = "medium" /* MEDIUM */
|
|
1410
|
+
}) => {
|
|
1411
|
+
const baseProps = {
|
|
1412
|
+
className: classNames5(
|
|
1413
|
+
"Layer__badge",
|
|
1414
|
+
onClick || tooltip ? "Layer__badge--clickable" : "",
|
|
1415
|
+
`Layer__badge--${size}`
|
|
1416
|
+
),
|
|
1417
|
+
onClick,
|
|
1418
|
+
children
|
|
1419
|
+
};
|
|
1420
|
+
let content = /* @__PURE__ */ React21.createElement(React21.Fragment, null, icon && /* @__PURE__ */ React21.createElement("span", { className: "Layer__badge__icon" }, icon), children);
|
|
1421
|
+
content = onClick ? /* @__PURE__ */ React21.createElement(Button, { ...baseProps }, content) : /* @__PURE__ */ React21.createElement("span", { ...baseProps }, content);
|
|
1422
|
+
if (tooltip) {
|
|
1423
|
+
return /* @__PURE__ */ React21.createElement(Tooltip, { offset: 12 }, /* @__PURE__ */ React21.createElement(TooltipTrigger, null, content), /* @__PURE__ */ React21.createElement(TooltipContent, { className: "Layer__tooltip" }, tooltip));
|
|
1424
|
+
}
|
|
1425
|
+
return content;
|
|
1426
|
+
};
|
|
1143
1427
|
|
|
1144
|
-
// src/
|
|
1145
|
-
import
|
|
1146
|
-
|
|
1428
|
+
// src/components/CategorySelect/CategorySelect.tsx
|
|
1429
|
+
import React23 from "react";
|
|
1430
|
+
import Select, {
|
|
1431
|
+
components
|
|
1432
|
+
} from "react-select";
|
|
1433
|
+
|
|
1434
|
+
// src/icons/MinimizeTwo.tsx
|
|
1435
|
+
import * as React22 from "react";
|
|
1436
|
+
var MinimizeTwo = ({ size = 18, ...props }) => /* @__PURE__ */ React22.createElement(
|
|
1147
1437
|
"svg",
|
|
1148
1438
|
{
|
|
1439
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1149
1440
|
viewBox: "0 0 18 18",
|
|
1150
1441
|
fill: "none",
|
|
1151
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1152
1442
|
...props,
|
|
1153
1443
|
width: size,
|
|
1154
1444
|
height: size
|
|
1155
1445
|
},
|
|
1156
|
-
/* @__PURE__ */
|
|
1446
|
+
/* @__PURE__ */ React22.createElement(
|
|
1157
1447
|
"path",
|
|
1158
1448
|
{
|
|
1159
|
-
d: "
|
|
1449
|
+
d: "M3 10.5H7.5V15",
|
|
1160
1450
|
stroke: "currentColor",
|
|
1161
1451
|
strokeLinecap: "round",
|
|
1162
1452
|
strokeLinejoin: "round"
|
|
1163
1453
|
}
|
|
1164
1454
|
),
|
|
1165
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ React22.createElement(
|
|
1166
1456
|
"path",
|
|
1167
1457
|
{
|
|
1168
|
-
d: "
|
|
1458
|
+
d: "M15 7.5H10.5V3",
|
|
1169
1459
|
stroke: "currentColor",
|
|
1170
1460
|
strokeLinecap: "round",
|
|
1171
1461
|
strokeLinejoin: "round"
|
|
1172
1462
|
}
|
|
1173
1463
|
),
|
|
1174
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ React22.createElement(
|
|
1175
1465
|
"path",
|
|
1176
1466
|
{
|
|
1177
|
-
d: "
|
|
1178
|
-
stroke: "currentColor",
|
|
1179
|
-
strokeLinecap: "round",
|
|
1180
|
-
strokeLinejoin: "round"
|
|
1181
|
-
}
|
|
1182
|
-
)
|
|
1183
|
-
);
|
|
1184
|
-
var FolderPlus_default = FolderPlus;
|
|
1185
|
-
|
|
1186
|
-
// src/icons/Link.tsx
|
|
1187
|
-
import * as React18 from "react";
|
|
1188
|
-
var Link = ({ size = 18, ...props }) => /* @__PURE__ */ React18.createElement(
|
|
1189
|
-
"svg",
|
|
1190
|
-
{
|
|
1191
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1192
|
-
viewBox: "0 0 18 18",
|
|
1193
|
-
fill: "none",
|
|
1194
|
-
...props,
|
|
1195
|
-
width: size,
|
|
1196
|
-
height: size
|
|
1197
|
-
},
|
|
1198
|
-
/* @__PURE__ */ React18.createElement(
|
|
1199
|
-
"path",
|
|
1200
|
-
{
|
|
1201
|
-
d: "M7.5 9.75C7.82209 10.1806 8.23302 10.5369 8.70491 10.7947C9.17681 11.0525 9.69863 11.2058 10.235 11.2442C10.7713 11.2827 11.3097 11.2053 11.8135 11.0173C12.3173 10.8294 12.7748 10.5353 13.155 10.155L15.405 7.905C16.0881 7.19774 16.4661 6.25048 16.4575 5.26724C16.449 4.284 16.0546 3.34346 15.3593 2.64818C14.664 1.9529 13.7235 1.55851 12.7403 1.54997C11.757 1.54143 10.8098 1.9194 10.1025 2.6025L8.8125 3.885",
|
|
1467
|
+
d: "M10.5 7.5L15.75 2.25",
|
|
1202
1468
|
stroke: "currentColor",
|
|
1203
1469
|
strokeLinecap: "round",
|
|
1204
1470
|
strokeLinejoin: "round"
|
|
1205
1471
|
}
|
|
1206
1472
|
),
|
|
1207
|
-
/* @__PURE__ */
|
|
1473
|
+
/* @__PURE__ */ React22.createElement(
|
|
1208
1474
|
"path",
|
|
1209
1475
|
{
|
|
1210
|
-
d: "
|
|
1476
|
+
d: "M2.25 15.75L7.5 10.5",
|
|
1211
1477
|
stroke: "currentColor",
|
|
1212
1478
|
strokeLinecap: "round",
|
|
1213
1479
|
strokeLinejoin: "round"
|
|
1214
1480
|
}
|
|
1215
1481
|
)
|
|
1216
1482
|
);
|
|
1217
|
-
var
|
|
1483
|
+
var MinimizeTwo_default = MinimizeTwo;
|
|
1218
1484
|
|
|
1219
|
-
// src/
|
|
1220
|
-
import
|
|
1221
|
-
|
|
1222
|
-
|
|
1485
|
+
// src/components/CategorySelect/CategorySelect.tsx
|
|
1486
|
+
import classNames6 from "classnames";
|
|
1487
|
+
import { parseISO as parseISO2, format as formatTime } from "date-fns";
|
|
1488
|
+
var mapCategoryToOption = (category) => {
|
|
1489
|
+
return {
|
|
1490
|
+
type: "category" /* CATEGORY */,
|
|
1491
|
+
payload: {
|
|
1492
|
+
id: category.id,
|
|
1493
|
+
option_type: "category" /* CATEGORY */,
|
|
1494
|
+
display_name: category.display_name,
|
|
1495
|
+
type: category.type,
|
|
1496
|
+
stable_name: category.stable_name,
|
|
1497
|
+
entries: category.entries,
|
|
1498
|
+
subCategories: category.subCategories
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
var mapSuggestedMatchToOption = (record) => {
|
|
1503
|
+
return {
|
|
1504
|
+
type: "match" /* MATCH */,
|
|
1505
|
+
payload: {
|
|
1506
|
+
id: record.id,
|
|
1507
|
+
option_type: "match" /* MATCH */,
|
|
1508
|
+
display_name: record.details.description,
|
|
1509
|
+
amount: record.details.amount
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
};
|
|
1513
|
+
var DropdownIndicator = (props) => {
|
|
1514
|
+
return /* @__PURE__ */ React23.createElement(components.DropdownIndicator, { ...props }, /* @__PURE__ */ React23.createElement(ChevronDown_default, null));
|
|
1515
|
+
};
|
|
1516
|
+
var GroupHeading = (props) => {
|
|
1517
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1518
|
+
components.GroupHeading,
|
|
1519
|
+
{
|
|
1520
|
+
className: classNames6(
|
|
1521
|
+
props.className,
|
|
1522
|
+
props.children === "Match" || props.children === "All categories" ? "Layer__select__group-heading--main" : ""
|
|
1523
|
+
),
|
|
1524
|
+
...props
|
|
1525
|
+
}
|
|
1526
|
+
);
|
|
1527
|
+
};
|
|
1528
|
+
var Option = (props) => {
|
|
1529
|
+
if (props.data.payload.option_type === "hidden") {
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (props.data.type === "match") {
|
|
1533
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1534
|
+
components.Option,
|
|
1535
|
+
{
|
|
1536
|
+
...props,
|
|
1537
|
+
className: `${props.className} Layer__select__option-content__match`
|
|
1538
|
+
},
|
|
1539
|
+
/* @__PURE__ */ React23.createElement("div", { className: "Layer__select__option-content__match__main-row" }, /* @__PURE__ */ React23.createElement("span", { className: "Layer__select__option-content__match__date" }, props.data.payload.date && formatTime(parseISO2(props.data.payload.date), DATE_FORMAT)), /* @__PURE__ */ React23.createElement("span", { className: "Layer__select__option-content__match__description" }, props.data.payload.display_name)),
|
|
1540
|
+
/* @__PURE__ */ React23.createElement("div", { className: "Layer__select__option-content__match__amount-row" }, /* @__PURE__ */ React23.createElement("span", { className: "Layer__select__option-content__match__amount" }, "$", centsToDollars(props.data.payload.amount)))
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1544
|
+
components.Option,
|
|
1545
|
+
{
|
|
1546
|
+
...props,
|
|
1547
|
+
className: `Layer__select__option-menu-content ${props.className}`
|
|
1548
|
+
},
|
|
1549
|
+
/* @__PURE__ */ React23.createElement("div", null, props.data.payload.display_name),
|
|
1550
|
+
props.isSelected ? /* @__PURE__ */ React23.createElement("span", { className: "Layer__select__option-menu-content-check" }, /* @__PURE__ */ React23.createElement(Check_default, { size: 16 })) : null
|
|
1551
|
+
);
|
|
1552
|
+
};
|
|
1553
|
+
var allCategoriesDivider = [
|
|
1223
1554
|
{
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1555
|
+
label: "All categories",
|
|
1556
|
+
options: [
|
|
1557
|
+
{
|
|
1558
|
+
type: "All categories",
|
|
1559
|
+
disabled: true,
|
|
1560
|
+
payload: {
|
|
1561
|
+
id: "all_categories",
|
|
1562
|
+
option_type: "hidden" /* HIDDEN */,
|
|
1563
|
+
display_name: "ALL CATEGORIES"
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
]
|
|
1567
|
+
}
|
|
1568
|
+
];
|
|
1569
|
+
function flattenCategories(categories) {
|
|
1570
|
+
const categoryOptions = (categories || []).flatMap((category) => {
|
|
1571
|
+
if (category?.subCategories && category?.subCategories?.length > 0) {
|
|
1572
|
+
if (category?.subCategories?.every((c) => c.subCategories === void 0)) {
|
|
1573
|
+
return [
|
|
1574
|
+
{
|
|
1575
|
+
label: category.display_name,
|
|
1576
|
+
options: category.subCategories.map((x) => mapCategoryToOption(x))
|
|
1577
|
+
}
|
|
1578
|
+
];
|
|
1579
|
+
}
|
|
1580
|
+
return flattenCategories(category.subCategories);
|
|
1581
|
+
}
|
|
1582
|
+
const resultOption = {
|
|
1583
|
+
label: category.display_name,
|
|
1584
|
+
options: [mapCategoryToOption(category)]
|
|
1585
|
+
};
|
|
1586
|
+
return [resultOption];
|
|
1587
|
+
});
|
|
1588
|
+
return categoryOptions;
|
|
1589
|
+
}
|
|
1590
|
+
var CategorySelect = ({
|
|
1591
|
+
bankTransaction,
|
|
1592
|
+
name,
|
|
1593
|
+
value,
|
|
1594
|
+
onChange,
|
|
1595
|
+
disabled,
|
|
1596
|
+
className
|
|
1597
|
+
}) => {
|
|
1598
|
+
const { categories } = useLayerContext();
|
|
1599
|
+
const matchOptions = bankTransaction?.suggested_matches ? [
|
|
1233
1600
|
{
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1601
|
+
label: "Match",
|
|
1602
|
+
options: bankTransaction.suggested_matches.map((x) => {
|
|
1603
|
+
return {
|
|
1604
|
+
type: "match" /* MATCH */,
|
|
1605
|
+
payload: {
|
|
1606
|
+
id: x.id,
|
|
1607
|
+
option_type: "match" /* MATCH */,
|
|
1608
|
+
display_name: x.details.description,
|
|
1609
|
+
date: x.details.date,
|
|
1610
|
+
amount: x.details.amount
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
})
|
|
1238
1614
|
}
|
|
1239
|
-
|
|
1240
|
-
/*
|
|
1241
|
-
"path",
|
|
1615
|
+
] : [];
|
|
1616
|
+
const suggestedOptions = bankTransaction?.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? [
|
|
1242
1617
|
{
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1618
|
+
label: "Suggestions",
|
|
1619
|
+
options: bankTransaction.categorization_flow.suggestions.map(
|
|
1620
|
+
(x) => mapCategoryToOption(x)
|
|
1621
|
+
)
|
|
1247
1622
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1623
|
+
] : [];
|
|
1624
|
+
const categoryOptions = flattenCategories(categories);
|
|
1625
|
+
const options = [
|
|
1626
|
+
...matchOptions,
|
|
1627
|
+
...suggestedOptions,
|
|
1628
|
+
...allCategoriesDivider,
|
|
1629
|
+
...categoryOptions
|
|
1630
|
+
];
|
|
1631
|
+
const selected = value ? value : matchOptions?.length === 1 && matchOptions[0].options.length === 1 ? matchOptions[0].options[0] : void 0;
|
|
1632
|
+
const placeholder = matchOptions?.length === 1 && matchOptions[0].options.length > 1 ? `${matchOptions[0].options.length} possible matches...` : "Categorize or match...";
|
|
1633
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1634
|
+
Select,
|
|
1251
1635
|
{
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1636
|
+
name,
|
|
1637
|
+
className: `Layer__category-menu Layer__select ${className ?? ""}`,
|
|
1638
|
+
classNamePrefix: "Layer__select",
|
|
1639
|
+
options,
|
|
1640
|
+
isSearchable: true,
|
|
1641
|
+
placeholder,
|
|
1642
|
+
defaultValue: selected,
|
|
1643
|
+
formatOptionLabel: (props) => /* @__PURE__ */ React23.createElement("div", { className: "Layer__select__option-label" }, props.type === "match" && /* @__PURE__ */ React23.createElement(Badge, { size: "small" /* SMALL */, icon: /* @__PURE__ */ React23.createElement(MinimizeTwo_default, { size: 11 }) }, "Match"), /* @__PURE__ */ React23.createElement("span", null, props.payload.display_name)),
|
|
1644
|
+
value,
|
|
1645
|
+
onChange: (newValue) => newValue && onChange(newValue),
|
|
1646
|
+
getOptionLabel: (category) => category.payload.display_name,
|
|
1647
|
+
getOptionValue: (category) => category.payload.id,
|
|
1648
|
+
menuPortalTarget: document.body,
|
|
1649
|
+
styles: {
|
|
1650
|
+
menuPortal: (base) => ({ ...base, zIndex: 9999 })
|
|
1651
|
+
},
|
|
1652
|
+
components: { DropdownIndicator, GroupHeading, Option },
|
|
1653
|
+
isDisabled: disabled,
|
|
1654
|
+
isOptionDisabled: (option) => option.disabled ?? false
|
|
1256
1655
|
}
|
|
1257
|
-
)
|
|
1258
|
-
|
|
1259
|
-
var RefreshCcw_default = RefreshCcw;
|
|
1656
|
+
);
|
|
1657
|
+
};
|
|
1260
1658
|
|
|
1261
|
-
// src/
|
|
1262
|
-
import
|
|
1263
|
-
|
|
1659
|
+
// src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
|
|
1660
|
+
import React36, {
|
|
1661
|
+
forwardRef as forwardRef2,
|
|
1662
|
+
useImperativeHandle,
|
|
1663
|
+
useState as useState6,
|
|
1664
|
+
useCallback,
|
|
1665
|
+
useEffect as useEffect3,
|
|
1666
|
+
useRef as useRef9
|
|
1667
|
+
} from "react";
|
|
1668
|
+
|
|
1669
|
+
// src/icons/Link.tsx
|
|
1670
|
+
import * as React24 from "react";
|
|
1671
|
+
var Link = ({ size = 18, ...props }) => /* @__PURE__ */ React24.createElement(
|
|
1264
1672
|
"svg",
|
|
1265
1673
|
{
|
|
1266
|
-
viewBox: "0 0 11 11",
|
|
1267
|
-
fill: "none",
|
|
1268
1674
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1675
|
+
viewBox: "0 0 18 18",
|
|
1676
|
+
fill: "none",
|
|
1269
1677
|
...props,
|
|
1270
1678
|
width: size,
|
|
1271
1679
|
height: size
|
|
1272
1680
|
},
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
"path",
|
|
1275
|
-
{
|
|
1276
|
-
d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
1277
|
-
stroke: "currentColor",
|
|
1278
|
-
strokeLinecap: "round",
|
|
1279
|
-
strokeLinejoin: "round"
|
|
1280
|
-
},
|
|
1281
|
-
/* @__PURE__ */ React20.createElement(
|
|
1282
|
-
"animate",
|
|
1283
|
-
{
|
|
1284
|
-
attributeName: "d",
|
|
1285
|
-
className: "animateOnHover",
|
|
1286
|
-
values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
|
|
1287
|
-
begin: "indefinite",
|
|
1288
|
-
dur: "400ms",
|
|
1289
|
-
repeatCount: "1",
|
|
1290
|
-
fill: "freeze",
|
|
1291
|
-
calcMode: "linear",
|
|
1292
|
-
keyTimes: "0;0.5;1"
|
|
1293
|
-
}
|
|
1294
|
-
)
|
|
1295
|
-
),
|
|
1296
|
-
/* @__PURE__ */ React20.createElement(
|
|
1681
|
+
/* @__PURE__ */ React24.createElement(
|
|
1297
1682
|
"path",
|
|
1298
1683
|
{
|
|
1299
|
-
d: "
|
|
1300
|
-
stroke: "currentColor",
|
|
1301
|
-
strokeLinecap: "round",
|
|
1302
|
-
strokeLinejoin: "round"
|
|
1303
|
-
},
|
|
1304
|
-
/* @__PURE__ */ React20.createElement(
|
|
1305
|
-
"animate",
|
|
1306
|
-
{
|
|
1307
|
-
attributeName: "d",
|
|
1308
|
-
className: "animateOnHover",
|
|
1309
|
-
values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
|
|
1310
|
-
begin: "indefinite",
|
|
1311
|
-
dur: "400ms",
|
|
1312
|
-
repeatCount: "1",
|
|
1313
|
-
fill: "freeze",
|
|
1314
|
-
calcMode: "linear",
|
|
1315
|
-
keyTimes: "0;0.5;1"
|
|
1316
|
-
}
|
|
1317
|
-
)
|
|
1318
|
-
),
|
|
1319
|
-
/* @__PURE__ */ React20.createElement(
|
|
1320
|
-
"path",
|
|
1321
|
-
{
|
|
1322
|
-
d: "M9.16668 1.83325L3.72168 7.27825",
|
|
1323
|
-
stroke: "currentColor",
|
|
1324
|
-
strokeLinecap: "round",
|
|
1325
|
-
strokeLinejoin: "round"
|
|
1326
|
-
},
|
|
1327
|
-
/* @__PURE__ */ React20.createElement(
|
|
1328
|
-
"animate",
|
|
1329
|
-
{
|
|
1330
|
-
attributeName: "d",
|
|
1331
|
-
className: "animateOnHover",
|
|
1332
|
-
values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
|
|
1333
|
-
begin: "indefinite",
|
|
1334
|
-
dur: "400ms",
|
|
1335
|
-
repeatCount: "1",
|
|
1336
|
-
fill: "freeze",
|
|
1337
|
-
calcMode: "linear",
|
|
1338
|
-
keyTimes: "0;0.5;1"
|
|
1339
|
-
}
|
|
1340
|
-
)
|
|
1341
|
-
),
|
|
1342
|
-
/* @__PURE__ */ React20.createElement(
|
|
1343
|
-
"path",
|
|
1344
|
-
{
|
|
1345
|
-
d: "M6.63232 6.63672L9.16691 9.16672",
|
|
1346
|
-
stroke: "currentColor",
|
|
1347
|
-
strokeLinecap: "round",
|
|
1348
|
-
strokeLinejoin: "round"
|
|
1349
|
-
},
|
|
1350
|
-
/* @__PURE__ */ React20.createElement(
|
|
1351
|
-
"animate",
|
|
1352
|
-
{
|
|
1353
|
-
attributeName: "d",
|
|
1354
|
-
className: "animateOnHover",
|
|
1355
|
-
values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
|
|
1356
|
-
begin: "indefinite",
|
|
1357
|
-
dur: "400ms",
|
|
1358
|
-
repeatCount: "1",
|
|
1359
|
-
fill: "freeze",
|
|
1360
|
-
calcMode: "linear",
|
|
1361
|
-
keyTimes: "0;0.5;1"
|
|
1362
|
-
}
|
|
1363
|
-
)
|
|
1364
|
-
),
|
|
1365
|
-
/* @__PURE__ */ React20.createElement(
|
|
1366
|
-
"path",
|
|
1367
|
-
{
|
|
1368
|
-
d: "M3.72168 3.72168L5.50001 5.50001",
|
|
1684
|
+
d: "M7.5 9.75C7.82209 10.1806 8.23302 10.5369 8.70491 10.7947C9.17681 11.0525 9.69863 11.2058 10.235 11.2442C10.7713 11.2827 11.3097 11.2053 11.8135 11.0173C12.3173 10.8294 12.7748 10.5353 13.155 10.155L15.405 7.905C16.0881 7.19774 16.4661 6.25048 16.4575 5.26724C16.449 4.284 16.0546 3.34346 15.3593 2.64818C14.664 1.9529 13.7235 1.55851 12.7403 1.54997C11.757 1.54143 10.8098 1.9194 10.1025 2.6025L8.8125 3.885",
|
|
1369
1685
|
stroke: "currentColor",
|
|
1370
1686
|
strokeLinecap: "round",
|
|
1371
1687
|
strokeLinejoin: "round"
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
fill: "freeze",
|
|
1383
|
-
calcMode: "linear",
|
|
1384
|
-
keyTimes: "0;0.5;1"
|
|
1385
|
-
}
|
|
1386
|
-
)
|
|
1688
|
+
}
|
|
1689
|
+
),
|
|
1690
|
+
/* @__PURE__ */ React24.createElement(
|
|
1691
|
+
"path",
|
|
1692
|
+
{
|
|
1693
|
+
d: "M10.5 8.25C10.1779 7.8194 9.76698 7.46311 9.29508 7.2053C8.82319 6.94748 8.30137 6.79416 7.76501 6.75575C7.22865 6.71734 6.69031 6.79473 6.18649 6.98266C5.68267 7.1706 5.22516 7.4647 4.845 7.845L2.595 10.095C1.9119 10.8023 1.53393 11.7495 1.54247 12.7328C1.55101 13.716 1.9454 14.6565 2.64068 15.3518C3.33596 16.0471 4.2765 16.4415 5.25974 16.45C6.24298 16.4586 7.19024 16.0806 7.8975 15.3975L9.18 14.115",
|
|
1694
|
+
stroke: "currentColor",
|
|
1695
|
+
strokeLinecap: "round",
|
|
1696
|
+
strokeLinejoin: "round"
|
|
1697
|
+
}
|
|
1387
1698
|
)
|
|
1388
1699
|
);
|
|
1389
|
-
var
|
|
1700
|
+
var Link_default = Link;
|
|
1701
|
+
|
|
1702
|
+
// src/components/CategoryMenu/CategoryMenu.tsx
|
|
1703
|
+
import React25 from "react";
|
|
1704
|
+
import Select2, {
|
|
1705
|
+
components as components2
|
|
1706
|
+
} from "react-select";
|
|
1707
|
+
var DropdownIndicator2 = (props) => {
|
|
1708
|
+
return /* @__PURE__ */ React25.createElement(components2.DropdownIndicator, { ...props }, /* @__PURE__ */ React25.createElement(ChevronDown_default, null));
|
|
1709
|
+
};
|
|
1710
|
+
var CategoryMenu = ({
|
|
1711
|
+
bankTransaction,
|
|
1712
|
+
name,
|
|
1713
|
+
value,
|
|
1714
|
+
onChange,
|
|
1715
|
+
disabled,
|
|
1716
|
+
className
|
|
1717
|
+
}) => {
|
|
1718
|
+
const { categories } = useLayerContext();
|
|
1719
|
+
const suggestedOptions = hasSuggestions(bankTransaction.categorization_flow) ? [
|
|
1720
|
+
{
|
|
1721
|
+
label: "Suggested",
|
|
1722
|
+
options: bankTransaction.categorization_flow.suggestions
|
|
1723
|
+
}
|
|
1724
|
+
] : [];
|
|
1725
|
+
const categoryOptions = (categories || []).map((category) => {
|
|
1726
|
+
if (category?.subCategories && category?.subCategories?.length > 0) {
|
|
1727
|
+
return {
|
|
1728
|
+
label: category.display_name,
|
|
1729
|
+
options: category.subCategories
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
return {
|
|
1733
|
+
label: category.display_name,
|
|
1734
|
+
options: [category]
|
|
1735
|
+
};
|
|
1736
|
+
}).filter((x) => x);
|
|
1737
|
+
const options = [...suggestedOptions, ...categoryOptions];
|
|
1738
|
+
return /* @__PURE__ */ React25.createElement(
|
|
1739
|
+
Select2,
|
|
1740
|
+
{
|
|
1741
|
+
name,
|
|
1742
|
+
className: `Layer__category-menu Layer__select ${className ?? ""}`,
|
|
1743
|
+
classNamePrefix: "Layer__select",
|
|
1744
|
+
options,
|
|
1745
|
+
isSearchable: true,
|
|
1746
|
+
value,
|
|
1747
|
+
onChange: (newValue) => newValue && onChange(newValue),
|
|
1748
|
+
getOptionLabel: (category) => category.display_name,
|
|
1749
|
+
getOptionValue: (category) => category.stable_name || category.category,
|
|
1750
|
+
menuPortalTarget: document.body,
|
|
1751
|
+
styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
|
|
1752
|
+
components: { DropdownIndicator: DropdownIndicator2 },
|
|
1753
|
+
isDisabled: disabled
|
|
1754
|
+
}
|
|
1755
|
+
);
|
|
1756
|
+
};
|
|
1390
1757
|
|
|
1391
1758
|
// src/components/Input/Input.tsx
|
|
1392
|
-
import
|
|
1393
|
-
import
|
|
1394
|
-
var Input = ({
|
|
1395
|
-
|
|
1396
|
-
|
|
1759
|
+
import React26 from "react";
|
|
1760
|
+
import classNames7 from "classnames";
|
|
1761
|
+
var Input = ({
|
|
1762
|
+
className,
|
|
1763
|
+
isInvalid,
|
|
1764
|
+
errorMessage,
|
|
1765
|
+
...props
|
|
1766
|
+
}) => {
|
|
1767
|
+
const baseClassName = classNames7(
|
|
1768
|
+
"Layer__input",
|
|
1769
|
+
isInvalid ? "Layer__input--error" : "",
|
|
1770
|
+
className
|
|
1771
|
+
);
|
|
1772
|
+
return /* @__PURE__ */ React26.createElement(Tooltip, { disabled: !isInvalid || !errorMessage }, /* @__PURE__ */ React26.createElement(TooltipTrigger, { className: "Layer__input-tooltip" }, /* @__PURE__ */ React26.createElement("input", { ...props, className: baseClassName })), /* @__PURE__ */ React26.createElement(TooltipContent, { className: "Layer__tooltip" }, errorMessage));
|
|
1397
1773
|
};
|
|
1398
1774
|
|
|
1399
1775
|
// src/components/Input/InputGroup.tsx
|
|
1400
|
-
import
|
|
1776
|
+
import React29 from "react";
|
|
1401
1777
|
|
|
1402
1778
|
// src/components/Typography/Text.tsx
|
|
1403
|
-
import
|
|
1404
|
-
import
|
|
1779
|
+
import React27, { useRef as useRef6, useState as useState4, useEffect } from "react";
|
|
1780
|
+
import classNames8 from "classnames";
|
|
1405
1781
|
var Text = ({
|
|
1406
1782
|
as: Component = "p",
|
|
1407
1783
|
className,
|
|
@@ -1411,12 +1787,12 @@ var Text = ({
|
|
|
1411
1787
|
withTooltip,
|
|
1412
1788
|
...props
|
|
1413
1789
|
}) => {
|
|
1414
|
-
const baseClassName =
|
|
1790
|
+
const baseClassName = classNames8(
|
|
1415
1791
|
`Layer__text Layer__text--${size} Layer__text--${weight}`,
|
|
1416
1792
|
className
|
|
1417
1793
|
);
|
|
1418
1794
|
if (withTooltip) {
|
|
1419
|
-
return /* @__PURE__ */
|
|
1795
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1420
1796
|
TextWithTooltip,
|
|
1421
1797
|
{
|
|
1422
1798
|
as: Component,
|
|
@@ -1429,7 +1805,7 @@ var Text = ({
|
|
|
1429
1805
|
children
|
|
1430
1806
|
);
|
|
1431
1807
|
}
|
|
1432
|
-
return /* @__PURE__ */
|
|
1808
|
+
return /* @__PURE__ */ React27.createElement(Component, { ...props, className: baseClassName }, children);
|
|
1433
1809
|
};
|
|
1434
1810
|
var TextWithTooltip = ({
|
|
1435
1811
|
as: Component = "p",
|
|
@@ -1441,7 +1817,7 @@ var TextWithTooltip = ({
|
|
|
1441
1817
|
tooltipOptions,
|
|
1442
1818
|
...props
|
|
1443
1819
|
}) => {
|
|
1444
|
-
const textElementRef =
|
|
1820
|
+
const textElementRef = useRef6();
|
|
1445
1821
|
const compareSize = () => {
|
|
1446
1822
|
if (textElementRef.current) {
|
|
1447
1823
|
const compare = textElementRef.current.children[0].scrollWidth > textElementRef.current.children[0].clientWidth;
|
|
@@ -1459,48 +1835,48 @@ var TextWithTooltip = ({
|
|
|
1459
1835
|
[]
|
|
1460
1836
|
);
|
|
1461
1837
|
const [hoverStatus, setHover] = useState4(false);
|
|
1462
|
-
const contentClassName =
|
|
1838
|
+
const contentClassName = classNames8(
|
|
1463
1839
|
"Layer__tooltip",
|
|
1464
1840
|
tooltipOptions?.contentClassName
|
|
1465
1841
|
);
|
|
1466
|
-
return /* @__PURE__ */
|
|
1842
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1467
1843
|
Tooltip,
|
|
1468
1844
|
{
|
|
1469
1845
|
disabled: !hoverStatus,
|
|
1470
1846
|
offset: tooltipOptions?.offset,
|
|
1471
1847
|
shift: tooltipOptions?.shift
|
|
1472
1848
|
},
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
/* @__PURE__ */
|
|
1849
|
+
/* @__PURE__ */ React27.createElement(TooltipTrigger, null, /* @__PURE__ */ React27.createElement(Component, { className, ref: textElementRef, ...props }, children)),
|
|
1850
|
+
/* @__PURE__ */ React27.createElement(TooltipContent, { className: contentClassName }, children)
|
|
1475
1851
|
);
|
|
1476
1852
|
};
|
|
1477
1853
|
|
|
1478
1854
|
// src/components/Typography/Heading.tsx
|
|
1479
|
-
import
|
|
1480
|
-
import
|
|
1855
|
+
import React28 from "react";
|
|
1856
|
+
import classNames9 from "classnames";
|
|
1481
1857
|
var Heading = ({
|
|
1482
1858
|
as: Component = "h2",
|
|
1483
1859
|
className,
|
|
1484
1860
|
children,
|
|
1485
1861
|
size = "primary" /* primary */
|
|
1486
1862
|
}) => {
|
|
1487
|
-
const baseClassName =
|
|
1863
|
+
const baseClassName = classNames9(
|
|
1488
1864
|
`Layer__heading Layer__heading--${size}`,
|
|
1489
1865
|
className
|
|
1490
1866
|
);
|
|
1491
|
-
return /* @__PURE__ */
|
|
1867
|
+
return /* @__PURE__ */ React28.createElement(Component, { className: baseClassName }, children);
|
|
1492
1868
|
};
|
|
1493
1869
|
|
|
1494
1870
|
// src/components/Input/InputGroup.tsx
|
|
1495
|
-
import
|
|
1871
|
+
import classNames10 from "classnames";
|
|
1496
1872
|
var InputGroup = ({
|
|
1497
1873
|
label,
|
|
1498
1874
|
name,
|
|
1499
1875
|
className,
|
|
1500
1876
|
children
|
|
1501
1877
|
}) => {
|
|
1502
|
-
const baseClassName =
|
|
1503
|
-
return /* @__PURE__ */
|
|
1878
|
+
const baseClassName = classNames10("Layer__input-group", className);
|
|
1879
|
+
return /* @__PURE__ */ React29.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ React29.createElement(
|
|
1504
1880
|
Text,
|
|
1505
1881
|
{
|
|
1506
1882
|
as: "label",
|
|
@@ -1513,11 +1889,11 @@ var InputGroup = ({
|
|
|
1513
1889
|
};
|
|
1514
1890
|
|
|
1515
1891
|
// src/components/Input/FileInput.tsx
|
|
1516
|
-
import
|
|
1892
|
+
import React31, { useRef as useRef7 } from "react";
|
|
1517
1893
|
|
|
1518
1894
|
// src/icons/UploadCloud.tsx
|
|
1519
|
-
import * as
|
|
1520
|
-
var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1895
|
+
import * as React30 from "react";
|
|
1896
|
+
var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React30.createElement(
|
|
1521
1897
|
"svg",
|
|
1522
1898
|
{
|
|
1523
1899
|
viewBox: "0 0 18 18",
|
|
@@ -1527,7 +1903,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1527
1903
|
width: size,
|
|
1528
1904
|
height: size
|
|
1529
1905
|
},
|
|
1530
|
-
/* @__PURE__ */
|
|
1906
|
+
/* @__PURE__ */ React30.createElement(
|
|
1531
1907
|
"path",
|
|
1532
1908
|
{
|
|
1533
1909
|
d: "M12 12L9 9L6 12",
|
|
@@ -1536,7 +1912,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1536
1912
|
strokeLinejoin: "round"
|
|
1537
1913
|
}
|
|
1538
1914
|
),
|
|
1539
|
-
/* @__PURE__ */
|
|
1915
|
+
/* @__PURE__ */ React30.createElement(
|
|
1540
1916
|
"path",
|
|
1541
1917
|
{
|
|
1542
1918
|
d: "M9 9V15.75",
|
|
@@ -1545,7 +1921,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1545
1921
|
strokeLinejoin: "round"
|
|
1546
1922
|
}
|
|
1547
1923
|
),
|
|
1548
|
-
/* @__PURE__ */
|
|
1924
|
+
/* @__PURE__ */ React30.createElement(
|
|
1549
1925
|
"path",
|
|
1550
1926
|
{
|
|
1551
1927
|
d: "M15.2925 13.7925C16.024 13.3937 16.6019 12.7626 16.9349 11.999C17.2679 11.2353 17.3372 10.3824 17.1317 9.57501C16.9262 8.7676 16.4576 8.05162 15.8 7.54007C15.1424 7.02852 14.3332 6.75054 13.5 6.74999H12.555C12.328 5.87192 11.9049 5.05674 11.3175 4.36573C10.7301 3.67473 9.99364 3.12588 9.16358 2.76044C8.33352 2.39501 7.43141 2.22251 6.52509 2.2559C5.61876 2.28929 4.7318 2.52771 3.93088 2.95324C3.12997 3.37876 2.43593 3.98032 1.90097 4.71267C1.366 5.44503 1.00402 6.28914 0.842236 7.18153C0.680453 8.07393 0.72308 8.99139 0.966911 9.86493C1.21074 10.7385 1.64943 11.5454 2.25 12.225",
|
|
@@ -1554,7 +1930,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1554
1930
|
strokeLinejoin: "round"
|
|
1555
1931
|
}
|
|
1556
1932
|
),
|
|
1557
|
-
/* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ React30.createElement(
|
|
1558
1934
|
"path",
|
|
1559
1935
|
{
|
|
1560
1936
|
d: "M12 12L9 9L6 12",
|
|
@@ -1568,7 +1944,7 @@ var UploadCloud_default = UploadCloud;
|
|
|
1568
1944
|
|
|
1569
1945
|
// src/components/Input/FileInput.tsx
|
|
1570
1946
|
var FileInput = ({ text = "Upload", onUpload }) => {
|
|
1571
|
-
const hiddenFileInput =
|
|
1947
|
+
const hiddenFileInput = useRef7(null);
|
|
1572
1948
|
const onClick = () => {
|
|
1573
1949
|
if (hiddenFileInput.current) {
|
|
1574
1950
|
hiddenFileInput.current.click();
|
|
@@ -1580,15 +1956,15 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
1580
1956
|
onUpload(fileUploaded);
|
|
1581
1957
|
}
|
|
1582
1958
|
};
|
|
1583
|
-
return /* @__PURE__ */
|
|
1959
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
1584
1960
|
Button,
|
|
1585
1961
|
{
|
|
1586
1962
|
onClick,
|
|
1587
1963
|
variant: "secondary" /* secondary */,
|
|
1588
|
-
|
|
1964
|
+
rightIcon: /* @__PURE__ */ React31.createElement(UploadCloud_default, null)
|
|
1589
1965
|
},
|
|
1590
1966
|
text
|
|
1591
|
-
), /* @__PURE__ */
|
|
1967
|
+
), /* @__PURE__ */ React31.createElement(
|
|
1592
1968
|
"input",
|
|
1593
1969
|
{
|
|
1594
1970
|
type: "file",
|
|
@@ -1599,23 +1975,105 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
1599
1975
|
));
|
|
1600
1976
|
};
|
|
1601
1977
|
|
|
1978
|
+
// src/components/MatchForm/MatchForm.tsx
|
|
1979
|
+
import React33 from "react";
|
|
1980
|
+
|
|
1981
|
+
// src/components/BankTransactionRow/MatchBadge.tsx
|
|
1982
|
+
import React32 from "react";
|
|
1983
|
+
import { parseISO as parseISO3, format as formatTime2 } from "date-fns";
|
|
1984
|
+
var MatchBadge = ({
|
|
1985
|
+
bankTransaction,
|
|
1986
|
+
classNamePrefix,
|
|
1987
|
+
dateFormat,
|
|
1988
|
+
text = "Match"
|
|
1989
|
+
}) => {
|
|
1990
|
+
if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction.match) {
|
|
1991
|
+
const { date, amount, description } = bankTransaction.match.bank_transaction;
|
|
1992
|
+
return /* @__PURE__ */ React32.createElement(
|
|
1993
|
+
Badge,
|
|
1994
|
+
{
|
|
1995
|
+
icon: /* @__PURE__ */ React32.createElement(MinimizeTwo_default, { size: 11 }),
|
|
1996
|
+
tooltip: /* @__PURE__ */ React32.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ React32.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, formatTime2(parseISO3(date), dateFormat)), /* @__PURE__ */ React32.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ React32.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
|
|
1997
|
+
},
|
|
1998
|
+
text
|
|
1999
|
+
);
|
|
2000
|
+
}
|
|
2001
|
+
return;
|
|
2002
|
+
};
|
|
2003
|
+
|
|
2004
|
+
// src/components/MatchForm/MatchForm.tsx
|
|
2005
|
+
import classNames11 from "classnames";
|
|
2006
|
+
import { parseISO as parseISO4, format as formatTime3 } from "date-fns";
|
|
2007
|
+
var MatchForm = ({
|
|
2008
|
+
classNamePrefix,
|
|
2009
|
+
bankTransaction,
|
|
2010
|
+
selectedMatchId,
|
|
2011
|
+
setSelectedMatchId
|
|
2012
|
+
}) => {
|
|
2013
|
+
return /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__status` })), bankTransaction.suggested_matches?.map((match, idx) => {
|
|
2014
|
+
return /* @__PURE__ */ React33.createElement(
|
|
2015
|
+
"div",
|
|
2016
|
+
{
|
|
2017
|
+
key: idx,
|
|
2018
|
+
className: classNames11(
|
|
2019
|
+
`${classNamePrefix}__match-row`,
|
|
2020
|
+
match.id === selectedMatchId ? `${classNamePrefix}__match-row--selected` : ""
|
|
2021
|
+
),
|
|
2022
|
+
onClick: () => {
|
|
2023
|
+
if (selectedMatchId === match.id) {
|
|
2024
|
+
setSelectedMatchId(void 0);
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
2027
|
+
setSelectedMatchId(match.id);
|
|
2028
|
+
}
|
|
2029
|
+
},
|
|
2030
|
+
/* @__PURE__ */ React33.createElement(
|
|
2031
|
+
"div",
|
|
2032
|
+
{
|
|
2033
|
+
className: `Layer__nowrap ${classNamePrefix}__match-table__date`
|
|
2034
|
+
},
|
|
2035
|
+
formatTime3(parseISO4(match.details.date), DATE_FORMAT)
|
|
2036
|
+
),
|
|
2037
|
+
/* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ React33.createElement(
|
|
2038
|
+
Text,
|
|
2039
|
+
{
|
|
2040
|
+
className: `${classNamePrefix}__match-table__desc-tooltip`,
|
|
2041
|
+
withTooltip: "whenTruncated" /* whenTruncated */,
|
|
2042
|
+
as: "span"
|
|
2043
|
+
},
|
|
2044
|
+
match.details.description
|
|
2045
|
+
)),
|
|
2046
|
+
/* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
|
|
2047
|
+
/* @__PURE__ */ React33.createElement("div", { className: `${classNamePrefix}__match-table__status` }, match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ React33.createElement(
|
|
2048
|
+
MatchBadge,
|
|
2049
|
+
{
|
|
2050
|
+
classNamePrefix,
|
|
2051
|
+
bankTransaction,
|
|
2052
|
+
dateFormat: DATE_FORMAT,
|
|
2053
|
+
text: "Matched"
|
|
2054
|
+
}
|
|
2055
|
+
))
|
|
2056
|
+
);
|
|
2057
|
+
}));
|
|
2058
|
+
};
|
|
2059
|
+
|
|
1602
2060
|
// src/components/Textarea/Textarea.tsx
|
|
1603
|
-
import
|
|
1604
|
-
import
|
|
2061
|
+
import React34 from "react";
|
|
2062
|
+
import classNames12 from "classnames";
|
|
1605
2063
|
var Textarea = ({
|
|
1606
2064
|
className,
|
|
1607
2065
|
...props
|
|
1608
2066
|
}) => {
|
|
1609
|
-
const baseClassName =
|
|
1610
|
-
return /* @__PURE__ */
|
|
2067
|
+
const baseClassName = classNames12("Layer__textarea", className);
|
|
2068
|
+
return /* @__PURE__ */ React34.createElement("textarea", { ...props, className: baseClassName });
|
|
1611
2069
|
};
|
|
1612
2070
|
|
|
1613
2071
|
// src/components/Toggle/Toggle.tsx
|
|
1614
|
-
import
|
|
2072
|
+
import React35, {
|
|
1615
2073
|
useEffect as useEffect2,
|
|
1616
2074
|
useState as useState5
|
|
1617
2075
|
} from "react";
|
|
1618
|
-
import
|
|
2076
|
+
import classNames13 from "classnames";
|
|
1619
2077
|
var Toggle = ({
|
|
1620
2078
|
name,
|
|
1621
2079
|
options,
|
|
@@ -1632,7 +2090,7 @@ var Toggle = ({
|
|
|
1632
2090
|
}
|
|
1633
2091
|
});
|
|
1634
2092
|
const selectedValue = selected || options[0].value;
|
|
1635
|
-
const baseClassName =
|
|
2093
|
+
const baseClassName = classNames13(
|
|
1636
2094
|
"Layer__toggle",
|
|
1637
2095
|
`Layer__toggle--${size}`,
|
|
1638
2096
|
initialized ? "Layer__toggle--initialized" : ""
|
|
@@ -1657,7 +2115,7 @@ var Toggle = ({
|
|
|
1657
2115
|
width = c.offsetWidth;
|
|
1658
2116
|
}
|
|
1659
2117
|
});
|
|
1660
|
-
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1);
|
|
2118
|
+
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
|
|
1661
2119
|
setThumbPos({ left: shift2, width });
|
|
1662
2120
|
};
|
|
1663
2121
|
useEffect2(() => {
|
|
@@ -1680,7 +2138,7 @@ var Toggle = ({
|
|
|
1680
2138
|
}
|
|
1681
2139
|
return selectedIndex;
|
|
1682
2140
|
};
|
|
1683
|
-
return /* @__PURE__ */
|
|
2141
|
+
return /* @__PURE__ */ React35.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ React35.createElement(
|
|
1684
2142
|
ToggleOption,
|
|
1685
2143
|
{
|
|
1686
2144
|
...option,
|
|
@@ -1692,7 +2150,7 @@ var Toggle = ({
|
|
|
1692
2150
|
disabled: option.disabled ?? false,
|
|
1693
2151
|
index
|
|
1694
2152
|
}
|
|
1695
|
-
)), /* @__PURE__ */
|
|
2153
|
+
)), /* @__PURE__ */ React35.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
|
|
1696
2154
|
};
|
|
1697
2155
|
var ToggleOption = ({
|
|
1698
2156
|
checked,
|
|
@@ -1705,7 +2163,7 @@ var ToggleOption = ({
|
|
|
1705
2163
|
disabled,
|
|
1706
2164
|
index
|
|
1707
2165
|
}) => {
|
|
1708
|
-
return /* @__PURE__ */
|
|
2166
|
+
return /* @__PURE__ */ React35.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React35.createElement(
|
|
1709
2167
|
"input",
|
|
1710
2168
|
{
|
|
1711
2169
|
type: "radio",
|
|
@@ -1716,10 +2174,25 @@ var ToggleOption = ({
|
|
|
1716
2174
|
disabled: disabled ?? false,
|
|
1717
2175
|
"data-idx": index
|
|
1718
2176
|
}
|
|
1719
|
-
), /* @__PURE__ */
|
|
2177
|
+
), /* @__PURE__ */ React35.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ React35.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ React35.createElement("span", null, label)));
|
|
1720
2178
|
};
|
|
1721
2179
|
|
|
1722
2180
|
// src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
|
|
2181
|
+
import classNames14 from "classnames";
|
|
2182
|
+
var hasMatch = (bankTransaction) => {
|
|
2183
|
+
return Boolean(
|
|
2184
|
+
bankTransaction?.suggested_matches && bankTransaction?.suggested_matches?.length > 0 || bankTransaction?.match
|
|
2185
|
+
);
|
|
2186
|
+
};
|
|
2187
|
+
var isAlreadyMatched = (bankTransaction) => {
|
|
2188
|
+
if (bankTransaction?.match) {
|
|
2189
|
+
const foundMatch = bankTransaction.suggested_matches?.find(
|
|
2190
|
+
(x) => x.details.id === bankTransaction?.match?.details.id
|
|
2191
|
+
);
|
|
2192
|
+
return foundMatch?.id;
|
|
2193
|
+
}
|
|
2194
|
+
return void 0;
|
|
2195
|
+
};
|
|
1723
2196
|
var ExpandedBankTransactionRow = forwardRef2(
|
|
1724
2197
|
({
|
|
1725
2198
|
bankTransaction,
|
|
@@ -1727,11 +2200,29 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1727
2200
|
asListItem = false,
|
|
1728
2201
|
submitBtnText = "Save"
|
|
1729
2202
|
}, ref) => {
|
|
1730
|
-
const {
|
|
1731
|
-
|
|
1732
|
-
|
|
2203
|
+
const {
|
|
2204
|
+
categorize: categorizeBankTransaction2,
|
|
2205
|
+
match: matchBankTransaction2
|
|
2206
|
+
} = useBankTransactions();
|
|
2207
|
+
const [purpose, setPurpose] = useState6(
|
|
2208
|
+
bankTransaction.category ? "categorize" /* categorize */ : hasMatch(bankTransaction) ? "match" /* match */ : "categorize" /* categorize */
|
|
2209
|
+
);
|
|
2210
|
+
const [selectedMatchId, setSelectedMatchId] = useState6(
|
|
2211
|
+
isAlreadyMatched(bankTransaction)
|
|
2212
|
+
);
|
|
2213
|
+
const [height, setHeight] = useState6(0);
|
|
2214
|
+
const [isOver, setOver] = useState6(false);
|
|
2215
|
+
const bodyRef = useRef9(null);
|
|
2216
|
+
const [isLoaded, setIsLoaded] = useState6(false);
|
|
2217
|
+
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
1733
2218
|
const [rowState, updateRowState] = useState6({
|
|
1734
|
-
splits:
|
|
2219
|
+
splits: bankTransaction.category?.entries ? bankTransaction.category?.entries.map((c) => {
|
|
2220
|
+
return {
|
|
2221
|
+
amount: c.amount || 0,
|
|
2222
|
+
inputValue: centsToDollars(c.amount),
|
|
2223
|
+
category: c.category
|
|
2224
|
+
};
|
|
2225
|
+
}) : [
|
|
1735
2226
|
{
|
|
1736
2227
|
amount: bankTransaction.amount,
|
|
1737
2228
|
inputValue: centsToDollars(bankTransaction.amount),
|
|
@@ -1748,22 +2239,32 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1748
2239
|
{ amount: 0, inputValue: "0.00", category: defaultCategory }
|
|
1749
2240
|
]
|
|
1750
2241
|
});
|
|
1751
|
-
const removeSplit = () =>
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
2242
|
+
const removeSplit = (index) => {
|
|
2243
|
+
const newSplits = rowState.splits.filter((_v, idx) => idx !== index);
|
|
2244
|
+
const splitTotal = newSplits.reduce((sum, split, index2) => {
|
|
2245
|
+
const amount = index2 === 0 ? 0 : split.amount;
|
|
2246
|
+
return sum + amount;
|
|
2247
|
+
}, 0);
|
|
2248
|
+
const remaining = bankTransaction.amount - splitTotal;
|
|
2249
|
+
newSplits[0].amount = remaining;
|
|
2250
|
+
newSplits[0].inputValue = centsToDollars(remaining);
|
|
2251
|
+
updateRowState({
|
|
2252
|
+
...rowState,
|
|
2253
|
+
splits: newSplits
|
|
2254
|
+
});
|
|
2255
|
+
};
|
|
1755
2256
|
const updateAmounts = (rowNumber) => (event) => {
|
|
1756
2257
|
const newAmount = dollarsToCents(event.target.value) || 0;
|
|
1757
2258
|
const newDisplaying = event.target.value;
|
|
1758
|
-
const splitTotal = rowState.splits.
|
|
1759
|
-
const amount = index === rowNumber ? newAmount : split.amount;
|
|
2259
|
+
const splitTotal = rowState.splits.reduce((sum, split, index) => {
|
|
2260
|
+
const amount = index === 0 ? 0 : index === rowNumber ? newAmount : split.amount;
|
|
1760
2261
|
return sum + amount;
|
|
1761
2262
|
}, 0);
|
|
1762
2263
|
const remaining = bankTransaction.amount - splitTotal;
|
|
1763
2264
|
rowState.splits[rowNumber].amount = newAmount;
|
|
1764
2265
|
rowState.splits[rowNumber].inputValue = newDisplaying;
|
|
1765
|
-
rowState.splits[
|
|
1766
|
-
rowState.splits[
|
|
2266
|
+
rowState.splits[0].amount = remaining;
|
|
2267
|
+
rowState.splits[0].inputValue = centsToDollars(remaining);
|
|
1767
2268
|
updateRowState({ ...rowState });
|
|
1768
2269
|
};
|
|
1769
2270
|
const onBlur = (event) => {
|
|
@@ -1780,32 +2281,83 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1780
2281
|
rowState.splits[index].category = newValue;
|
|
1781
2282
|
updateRowState({ ...rowState });
|
|
1782
2283
|
};
|
|
1783
|
-
const save = () =>
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
category: {
|
|
1788
|
-
type: "StableName",
|
|
1789
|
-
stable_name: rowState?.splits[0].category?.stable_name || rowState?.splits[0].category?.category
|
|
2284
|
+
const save = () => {
|
|
2285
|
+
if (purpose === "match" /* match */) {
|
|
2286
|
+
if (selectedMatchId && selectedMatchId !== isAlreadyMatched(bankTransaction)) {
|
|
2287
|
+
onMatchSubmit(selectedMatchId);
|
|
1790
2288
|
}
|
|
1791
|
-
|
|
1792
|
-
type: "Split",
|
|
1793
|
-
entries: rowState.splits.map((split) => ({
|
|
1794
|
-
category: split.category?.stable_name || split.category?.category,
|
|
1795
|
-
amount: split.amount
|
|
1796
|
-
}))
|
|
2289
|
+
return;
|
|
1797
2290
|
}
|
|
1798
|
-
|
|
2291
|
+
categorizeBankTransaction2(
|
|
2292
|
+
bankTransaction.id,
|
|
2293
|
+
rowState.splits.length === 1 ? {
|
|
2294
|
+
type: "Category",
|
|
2295
|
+
category: {
|
|
2296
|
+
type: "StableName",
|
|
2297
|
+
stable_name: rowState?.splits[0].category?.stable_name || rowState?.splits[0].category?.category
|
|
2298
|
+
}
|
|
2299
|
+
} : {
|
|
2300
|
+
type: "Split",
|
|
2301
|
+
entries: rowState.splits.map((split) => ({
|
|
2302
|
+
category: split.category?.stable_name || split.category?.category,
|
|
2303
|
+
amount: split.amount
|
|
2304
|
+
}))
|
|
2305
|
+
}
|
|
2306
|
+
).catch((e) => console.error(e));
|
|
2307
|
+
};
|
|
1799
2308
|
useImperativeHandle(ref, () => ({
|
|
1800
2309
|
save
|
|
1801
2310
|
}));
|
|
2311
|
+
const onMatchSubmit = (matchId) => {
|
|
2312
|
+
const foundMatch = bankTransaction.suggested_matches?.find(
|
|
2313
|
+
(x) => x.id === matchId
|
|
2314
|
+
);
|
|
2315
|
+
if (!foundMatch) {
|
|
2316
|
+
return;
|
|
2317
|
+
}
|
|
2318
|
+
matchBankTransaction2(bankTransaction.id, foundMatch.id);
|
|
2319
|
+
};
|
|
2320
|
+
const getDivHeight = useCallback(() => {
|
|
2321
|
+
const { height: height2 } = bodyRef.current ? bodyRef.current.getBoundingClientRect() : { height: void 0 };
|
|
2322
|
+
return height2 || 0;
|
|
2323
|
+
}, []);
|
|
2324
|
+
const handleTransitionEnd = useCallback(
|
|
2325
|
+
(e) => {
|
|
2326
|
+
if (e.propertyName === "height") {
|
|
2327
|
+
setHeight(isOpen ? "auto" : 0);
|
|
2328
|
+
if (!isOpen) {
|
|
2329
|
+
setOver(true);
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
},
|
|
2333
|
+
[isOpen]
|
|
2334
|
+
);
|
|
2335
|
+
useEffect3(() => {
|
|
2336
|
+
if (!isLoaded) {
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
setHeight(getDivHeight());
|
|
2340
|
+
setOver(false);
|
|
2341
|
+
if (!isOpen) {
|
|
2342
|
+
requestAnimationFrame(() => {
|
|
2343
|
+
requestAnimationFrame(() => setHeight(0));
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
}, [getDivHeight, isOpen]);
|
|
2347
|
+
useEffect3(() => {
|
|
2348
|
+
setIsLoaded(true);
|
|
2349
|
+
setOver(true);
|
|
2350
|
+
}, []);
|
|
1802
2351
|
const className = "Layer__expanded-bank-transaction-row";
|
|
1803
|
-
|
|
2352
|
+
const shouldHide = !isOpen && isOver;
|
|
2353
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1804
2354
|
"span",
|
|
1805
2355
|
{
|
|
1806
|
-
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}
|
|
2356
|
+
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
2357
|
+
style: { height },
|
|
2358
|
+
onTransitionEnd: handleTransitionEnd
|
|
1807
2359
|
},
|
|
1808
|
-
/* @__PURE__ */
|
|
2360
|
+
shouldHide ? null : /* @__PURE__ */ React36.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ React36.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React36.createElement(
|
|
1809
2361
|
Toggle,
|
|
1810
2362
|
{
|
|
1811
2363
|
name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
|
|
@@ -1813,81 +2365,129 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1813
2365
|
options: [
|
|
1814
2366
|
{
|
|
1815
2367
|
value: "categorize",
|
|
1816
|
-
label: "Categorize"
|
|
1817
|
-
leftIcon: /* @__PURE__ */ React29.createElement(FolderPlus_default, { size: 15 })
|
|
2368
|
+
label: "Categorize"
|
|
1818
2369
|
},
|
|
1819
2370
|
{
|
|
1820
2371
|
value: "match",
|
|
1821
2372
|
label: "Match",
|
|
1822
|
-
disabled:
|
|
1823
|
-
leftIcon: /* @__PURE__ */ React29.createElement(RefreshCcw_default, { size: 15 })
|
|
2373
|
+
disabled: !hasMatch(bankTransaction)
|
|
1824
2374
|
}
|
|
1825
2375
|
],
|
|
1826
2376
|
selected: purpose,
|
|
1827
2377
|
onChange: onChangePurpose
|
|
1828
2378
|
}
|
|
1829
|
-
)), /* @__PURE__ */
|
|
2379
|
+
)), /* @__PURE__ */ React36.createElement(
|
|
1830
2380
|
"div",
|
|
1831
2381
|
{
|
|
1832
2382
|
className: `${className}__content`,
|
|
1833
2383
|
id: `expanded-${bankTransaction.id}`
|
|
1834
2384
|
},
|
|
1835
|
-
/* @__PURE__ */
|
|
2385
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ React36.createElement(
|
|
1836
2386
|
"div",
|
|
1837
2387
|
{
|
|
1838
|
-
className:
|
|
1839
|
-
|
|
2388
|
+
className: classNames14(
|
|
2389
|
+
`${className}__match`,
|
|
2390
|
+
`${className}__content-panel`,
|
|
2391
|
+
purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
|
|
2392
|
+
)
|
|
1840
2393
|
},
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
{
|
|
1844
|
-
type: "text",
|
|
1845
|
-
name: `split-${index}${asListItem ? "-li" : ""}`,
|
|
1846
|
-
disabled: index + 1 === rowState.splits.length,
|
|
1847
|
-
onChange: updateAmounts(index),
|
|
1848
|
-
value: split.inputValue,
|
|
1849
|
-
onBlur,
|
|
1850
|
-
className: `${className}__split-amount${split.amount < 0 ? "--negative" : ""}`
|
|
1851
|
-
}
|
|
1852
|
-
),
|
|
1853
|
-
/* @__PURE__ */ React29.createElement(
|
|
1854
|
-
CategoryMenu,
|
|
2394
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React36.createElement(
|
|
2395
|
+
MatchForm,
|
|
1855
2396
|
{
|
|
2397
|
+
classNamePrefix: className,
|
|
1856
2398
|
bankTransaction,
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
onChange: (value) => changeCategory(index, value),
|
|
1860
|
-
className: "Layer__category-menu--full"
|
|
2399
|
+
selectedMatchId,
|
|
2400
|
+
setSelectedMatchId
|
|
1861
2401
|
}
|
|
1862
|
-
)
|
|
1863
|
-
)
|
|
1864
|
-
|
|
1865
|
-
{
|
|
1866
|
-
onClick: addSplit,
|
|
1867
|
-
leftIcon: /* @__PURE__ */ React29.createElement(Scissors_default, { size: 14 }),
|
|
1868
|
-
variant: "secondary" /* secondary */
|
|
1869
|
-
},
|
|
1870
|
-
"Split"
|
|
1871
|
-
) : /* @__PURE__ */ React29.createElement(
|
|
1872
|
-
Button,
|
|
2402
|
+
))
|
|
2403
|
+
), /* @__PURE__ */ React36.createElement(
|
|
2404
|
+
"div",
|
|
1873
2405
|
{
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
2406
|
+
className: classNames14(
|
|
2407
|
+
`${className}__splits`,
|
|
2408
|
+
`${className}__content-panel`,
|
|
2409
|
+
purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
|
|
2410
|
+
)
|
|
1877
2411
|
},
|
|
1878
|
-
"
|
|
1879
|
-
|
|
1880
|
-
|
|
2412
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React36.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ React36.createElement(
|
|
2413
|
+
"div",
|
|
2414
|
+
{
|
|
2415
|
+
className: `${className}__table-cell--split-entry`,
|
|
2416
|
+
key: `split-${index}`
|
|
2417
|
+
},
|
|
2418
|
+
/* @__PURE__ */ React36.createElement(
|
|
2419
|
+
Input,
|
|
2420
|
+
{
|
|
2421
|
+
type: "text",
|
|
2422
|
+
name: `split-${index}${asListItem ? "-li" : ""}`,
|
|
2423
|
+
disabled: index === 0,
|
|
2424
|
+
onChange: updateAmounts(index),
|
|
2425
|
+
value: split.inputValue,
|
|
2426
|
+
onBlur,
|
|
2427
|
+
isInvalid: split.amount < 0,
|
|
2428
|
+
errorMessage: "Negative values are not allowed"
|
|
2429
|
+
}
|
|
2430
|
+
),
|
|
2431
|
+
/* @__PURE__ */ React36.createElement(
|
|
2432
|
+
CategoryMenu,
|
|
2433
|
+
{
|
|
2434
|
+
bankTransaction,
|
|
2435
|
+
name: `category-${index}${asListItem ? "-li" : ""}`,
|
|
2436
|
+
value: split.category,
|
|
2437
|
+
onChange: (value) => changeCategory(index, value),
|
|
2438
|
+
className: "Layer__category-menu--full"
|
|
2439
|
+
}
|
|
2440
|
+
),
|
|
2441
|
+
index > 0 && /* @__PURE__ */ React36.createElement(
|
|
2442
|
+
Button,
|
|
2443
|
+
{
|
|
2444
|
+
onClick: () => removeSplit(index),
|
|
2445
|
+
rightIcon: /* @__PURE__ */ React36.createElement(Link_default, { size: 14 }),
|
|
2446
|
+
variant: "secondary" /* secondary */
|
|
2447
|
+
},
|
|
2448
|
+
"Merge"
|
|
2449
|
+
)
|
|
2450
|
+
))), /* @__PURE__ */ React36.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ React36.createElement(
|
|
2451
|
+
TextButton,
|
|
2452
|
+
{
|
|
2453
|
+
onClick: addSplit,
|
|
2454
|
+
disabled: rowState.splits.length > 5
|
|
2455
|
+
},
|
|
2456
|
+
"Add new split"
|
|
2457
|
+
) : /* @__PURE__ */ React36.createElement(
|
|
2458
|
+
Button,
|
|
2459
|
+
{
|
|
2460
|
+
onClick: addSplit,
|
|
2461
|
+
rightIcon: /* @__PURE__ */ React36.createElement(Scissors_default, { size: 14 }),
|
|
2462
|
+
variant: "secondary" /* secondary */,
|
|
2463
|
+
disabled: rowState.splits.length > 5
|
|
2464
|
+
},
|
|
2465
|
+
"Split"
|
|
2466
|
+
)), rowState.splits.length > 1 && /* @__PURE__ */ React36.createElement(
|
|
2467
|
+
Text,
|
|
2468
|
+
{
|
|
2469
|
+
size: "sm" /* sm */,
|
|
2470
|
+
className: `${className}__splits-total`
|
|
2471
|
+
},
|
|
2472
|
+
"Total: $",
|
|
2473
|
+
centsToDollars(
|
|
2474
|
+
rowState.splits.reduce(
|
|
2475
|
+
(x, { amount }) => x + amount,
|
|
2476
|
+
0
|
|
2477
|
+
)
|
|
2478
|
+
)
|
|
2479
|
+
))
|
|
2480
|
+
)),
|
|
2481
|
+
/* @__PURE__ */ React36.createElement(
|
|
1881
2482
|
InputGroup,
|
|
1882
2483
|
{
|
|
1883
2484
|
className: `${className}__description`,
|
|
1884
|
-
name: "description"
|
|
1885
|
-
label: "Description"
|
|
2485
|
+
name: "description"
|
|
1886
2486
|
},
|
|
1887
|
-
/* @__PURE__ */
|
|
2487
|
+
/* @__PURE__ */ React36.createElement(Textarea, { name: "description", placeholder: "Add description" })
|
|
1888
2488
|
),
|
|
1889
|
-
/* @__PURE__ */
|
|
1890
|
-
asListItem ? /* @__PURE__ */
|
|
2489
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ React36.createElement(FileInput, { text: "Upload receipt" })),
|
|
2490
|
+
asListItem ? /* @__PURE__ */ React36.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ React36.createElement(
|
|
1891
2491
|
SubmitButton,
|
|
1892
2492
|
{
|
|
1893
2493
|
onClick: () => {
|
|
@@ -1907,134 +2507,62 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1907
2507
|
}
|
|
1908
2508
|
);
|
|
1909
2509
|
|
|
1910
|
-
// src/components/
|
|
1911
|
-
import
|
|
1912
|
-
var
|
|
2510
|
+
// src/components/BankTransactionRow/SplitTooltipDetails.tsx
|
|
2511
|
+
import React37 from "react";
|
|
2512
|
+
var SplitTooltipDetails = ({
|
|
2513
|
+
classNamePrefix,
|
|
2514
|
+
category
|
|
2515
|
+
}) => {
|
|
2516
|
+
if (!category.entries) {
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
return /* @__PURE__ */ React37.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ React37.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ React37.createElement("li", { key: idx }, /* @__PURE__ */ React37.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ React37.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
|
|
2520
|
+
};
|
|
1913
2521
|
|
|
1914
|
-
// src/components/
|
|
1915
|
-
import
|
|
1916
|
-
import { parseISO as
|
|
2522
|
+
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
2523
|
+
import classNames15 from "classnames";
|
|
2524
|
+
import { parseISO as parseISO5, format as formatTime4 } from "date-fns";
|
|
1917
2525
|
var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
1918
|
-
var
|
|
1919
|
-
|
|
2526
|
+
var extractDescriptionForSplit = (category) => {
|
|
2527
|
+
if (!category.entries) {
|
|
2528
|
+
return "";
|
|
2529
|
+
}
|
|
2530
|
+
return category.entries.map((c) => c.category.display_name).join(", ");
|
|
2531
|
+
};
|
|
2532
|
+
var getDefaultSelectedCategory = (bankTransaction) => {
|
|
2533
|
+
return hasSuggestions(bankTransaction.categorization_flow) ? mapCategoryToOption(bankTransaction.categorization_flow.suggestions[0]) : bankTransaction.suggested_matches?.length === 1 ? mapSuggestedMatchToOption(bankTransaction.suggested_matches[0]) : void 0;
|
|
2534
|
+
};
|
|
2535
|
+
var BankTransactionRow = ({
|
|
2536
|
+
dateFormat,
|
|
1920
2537
|
bankTransaction,
|
|
1921
|
-
isOpen,
|
|
1922
|
-
toggleOpen,
|
|
1923
2538
|
editable
|
|
1924
2539
|
}) => {
|
|
1925
|
-
const expandedRowRef =
|
|
2540
|
+
const expandedRowRef = useRef10(null);
|
|
1926
2541
|
const [removed, setRemoved] = useState7(false);
|
|
1927
|
-
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
2542
|
+
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
1928
2543
|
const [selectedCategory, setSelectedCategory] = useState7(
|
|
1929
|
-
bankTransaction
|
|
2544
|
+
getDefaultSelectedCategory(bankTransaction)
|
|
1930
2545
|
);
|
|
2546
|
+
const [open, setOpen] = useState7(false);
|
|
2547
|
+
const toggleOpen = () => setOpen(!open);
|
|
1931
2548
|
const save = () => {
|
|
1932
|
-
if (
|
|
2549
|
+
if (open && expandedRowRef?.current) {
|
|
1933
2550
|
expandedRowRef?.current?.save();
|
|
1934
|
-
|
|
2551
|
+
setOpen(false);
|
|
1935
2552
|
return;
|
|
1936
2553
|
}
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
category: {
|
|
1940
|
-
type: "StableName",
|
|
1941
|
-
stable_name: selectedCategory?.stable_name || selectedCategory?.category || ""
|
|
1942
|
-
}
|
|
1943
|
-
});
|
|
1944
|
-
};
|
|
1945
|
-
if (removed) {
|
|
1946
|
-
return null;
|
|
1947
|
-
}
|
|
1948
|
-
const className = "Layer__bank-transaction-list-item";
|
|
1949
|
-
const openClassName = isOpen ? `${className}--expanded` : "";
|
|
1950
|
-
const rowClassName = classNames9(
|
|
1951
|
-
className,
|
|
1952
|
-
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
1953
|
-
isOpen ? openClassName : ""
|
|
1954
|
-
);
|
|
1955
|
-
return /* @__PURE__ */ React31.createElement("li", { className: rowClassName }, /* @__PURE__ */ React31.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ React31.createElement("span", { className: `${className}__heading-date` }, formatTime(parseISO2(bankTransaction.date), dateFormat2)), /* @__PURE__ */ React31.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ React31.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ React31.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ React31.createElement("span", { className: `${className}__body__name` }, bankTransaction.counterparty_name), /* @__PURE__ */ React31.createElement(
|
|
1956
|
-
"span",
|
|
1957
|
-
{
|
|
1958
|
-
className: `${className}__amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
|
|
1959
|
-
},
|
|
1960
|
-
isCredit(bankTransaction) ? "+$" : " $",
|
|
1961
|
-
centsToDollars(bankTransaction.amount)
|
|
1962
|
-
), /* @__PURE__ */ React31.createElement(
|
|
1963
|
-
"div",
|
|
1964
|
-
{
|
|
1965
|
-
onClick: () => toggleOpen(bankTransaction.id),
|
|
1966
|
-
className: "Layer__bank-transaction-row__expand-button"
|
|
1967
|
-
},
|
|
1968
|
-
/* @__PURE__ */ React31.createElement(
|
|
1969
|
-
ChevronDown_default,
|
|
1970
|
-
{
|
|
1971
|
-
className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
1972
|
-
}
|
|
1973
|
-
)
|
|
1974
|
-
)), /* @__PURE__ */ React31.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React31.createElement(
|
|
1975
|
-
ExpandedBankTransactionRow,
|
|
1976
|
-
{
|
|
1977
|
-
ref: expandedRowRef,
|
|
1978
|
-
bankTransaction,
|
|
1979
|
-
close: () => toggleOpen(bankTransaction.id),
|
|
1980
|
-
isOpen,
|
|
1981
|
-
asListItem: true,
|
|
1982
|
-
submitBtnText: editable ? "Approve" : "Save"
|
|
1983
|
-
}
|
|
1984
|
-
)), /* @__PURE__ */ React31.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ React31.createElement(
|
|
1985
|
-
CategoryMenu,
|
|
1986
|
-
{
|
|
1987
|
-
bankTransaction,
|
|
1988
|
-
name: `category-${bankTransaction.id}`,
|
|
1989
|
-
value: selectedCategory,
|
|
1990
|
-
onChange: setSelectedCategory,
|
|
1991
|
-
disabled: bankTransaction.processing
|
|
1992
|
-
}
|
|
1993
|
-
) : null, !editable ? /* @__PURE__ */ React31.createElement(Pill, null, bankTransaction?.category?.display_name) : null, editable && /* @__PURE__ */ React31.createElement(
|
|
1994
|
-
SubmitButton,
|
|
1995
|
-
{
|
|
1996
|
-
onClick: () => {
|
|
1997
|
-
if (!bankTransaction.processing) {
|
|
1998
|
-
save();
|
|
1999
|
-
}
|
|
2000
|
-
},
|
|
2001
|
-
className: "Layer__bank-transaction__submit-btn",
|
|
2002
|
-
processing: bankTransaction.processing,
|
|
2003
|
-
error: bankTransaction.error,
|
|
2004
|
-
iconOnly: true
|
|
2554
|
+
if (!selectedCategory) {
|
|
2555
|
+
return;
|
|
2005
2556
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
2010
|
-
import React32, { useRef as useRef8, useState as useState8 } from "react";
|
|
2011
|
-
import classNames10 from "classnames";
|
|
2012
|
-
import { parseISO as parseISO3, format as formatTime2 } from "date-fns";
|
|
2013
|
-
var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
2014
|
-
var BankTransactionRow = ({
|
|
2015
|
-
dateFormat: dateFormat2,
|
|
2016
|
-
bankTransaction,
|
|
2017
|
-
isOpen,
|
|
2018
|
-
toggleOpen,
|
|
2019
|
-
editable
|
|
2020
|
-
}) => {
|
|
2021
|
-
const expandedRowRef = useRef8(null);
|
|
2022
|
-
const [removed, setRemoved] = useState8(false);
|
|
2023
|
-
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
2024
|
-
const [selectedCategory, setSelectedCategory] = useState8(
|
|
2025
|
-
bankTransaction.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions[0] : void 0
|
|
2026
|
-
);
|
|
2027
|
-
const save = () => {
|
|
2028
|
-
if (isOpen && expandedRowRef?.current) {
|
|
2029
|
-
expandedRowRef?.current?.save();
|
|
2030
|
-
toggleOpen(bankTransaction.id);
|
|
2557
|
+
if (selectedCategory.type === "match") {
|
|
2558
|
+
matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
|
|
2031
2559
|
return;
|
|
2032
2560
|
}
|
|
2033
2561
|
categorizeBankTransaction2(bankTransaction.id, {
|
|
2034
2562
|
type: "Category",
|
|
2035
2563
|
category: {
|
|
2036
2564
|
type: "StableName",
|
|
2037
|
-
stable_name: selectedCategory?.stable_name ||
|
|
2565
|
+
stable_name: selectedCategory?.payload.stable_name || ""
|
|
2038
2566
|
}
|
|
2039
2567
|
});
|
|
2040
2568
|
};
|
|
@@ -2042,13 +2570,13 @@ var BankTransactionRow = ({
|
|
|
2042
2570
|
return null;
|
|
2043
2571
|
}
|
|
2044
2572
|
const className = "Layer__bank-transaction-row";
|
|
2045
|
-
const openClassName =
|
|
2046
|
-
const rowClassName =
|
|
2573
|
+
const openClassName = open ? `${className}--expanded` : "";
|
|
2574
|
+
const rowClassName = classNames15(
|
|
2047
2575
|
className,
|
|
2048
2576
|
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
2049
|
-
|
|
2577
|
+
open ? openClassName : ""
|
|
2050
2578
|
);
|
|
2051
|
-
return /* @__PURE__ */
|
|
2579
|
+
return /* @__PURE__ */ React38.createElement(React38.Fragment, null, /* @__PURE__ */ React38.createElement(
|
|
2052
2580
|
"tr",
|
|
2053
2581
|
{
|
|
2054
2582
|
className: rowClassName,
|
|
@@ -2058,8 +2586,8 @@ var BankTransactionRow = ({
|
|
|
2058
2586
|
}
|
|
2059
2587
|
}
|
|
2060
2588
|
},
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */
|
|
2589
|
+
/* @__PURE__ */ React38.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React38.createElement("span", { className: "Layer__table-cell-content" }, formatTime4(parseISO5(bankTransaction.date), dateFormat))),
|
|
2590
|
+
/* @__PURE__ */ React38.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__tx-col" }, /* @__PURE__ */ React38.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React38.createElement(
|
|
2063
2591
|
Text,
|
|
2064
2592
|
{
|
|
2065
2593
|
as: "span",
|
|
@@ -2069,9 +2597,9 @@ var BankTransactionRow = ({
|
|
|
2069
2597
|
contentClassName: "Layer__bank-transactions__tx-tooltip"
|
|
2070
2598
|
}
|
|
2071
2599
|
},
|
|
2072
|
-
bankTransaction.counterparty_name
|
|
2600
|
+
bankTransaction.counterparty_name ?? bankTransaction.description
|
|
2073
2601
|
))),
|
|
2074
|
-
/* @__PURE__ */
|
|
2602
|
+
/* @__PURE__ */ React38.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__account-col" }, /* @__PURE__ */ React38.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React38.createElement(
|
|
2075
2603
|
Text,
|
|
2076
2604
|
{
|
|
2077
2605
|
as: "span",
|
|
@@ -2080,30 +2608,30 @@ var BankTransactionRow = ({
|
|
|
2080
2608
|
},
|
|
2081
2609
|
bankTransaction.account_name ?? ""
|
|
2082
2610
|
))),
|
|
2083
|
-
/* @__PURE__ */
|
|
2611
|
+
/* @__PURE__ */ React38.createElement(
|
|
2084
2612
|
"td",
|
|
2085
2613
|
{
|
|
2086
|
-
className: `Layer__table-cell Layer__table-cell__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${
|
|
2614
|
+
className: `Layer__table-cell Layer__table-cell__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
|
|
2087
2615
|
},
|
|
2088
|
-
/* @__PURE__ */
|
|
2616
|
+
/* @__PURE__ */ React38.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
2089
2617
|
),
|
|
2090
|
-
/* @__PURE__ */
|
|
2618
|
+
/* @__PURE__ */ React38.createElement(
|
|
2091
2619
|
"td",
|
|
2092
2620
|
{
|
|
2093
|
-
className:
|
|
2621
|
+
className: classNames15(
|
|
2094
2622
|
"Layer__table-cell",
|
|
2095
2623
|
"Layer__table-cell__category-col",
|
|
2096
2624
|
`${className}__actions-cell`,
|
|
2097
|
-
`${className}__actions-cell--${
|
|
2625
|
+
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
2098
2626
|
)
|
|
2099
2627
|
},
|
|
2100
|
-
/* @__PURE__ */
|
|
2628
|
+
/* @__PURE__ */ React38.createElement(
|
|
2101
2629
|
"span",
|
|
2102
2630
|
{
|
|
2103
2631
|
className: `${className}__actions-container Layer__table-cell-content`
|
|
2104
2632
|
},
|
|
2105
|
-
editable && !
|
|
2106
|
-
|
|
2633
|
+
editable && !open ? /* @__PURE__ */ React38.createElement(
|
|
2634
|
+
CategorySelect,
|
|
2107
2635
|
{
|
|
2108
2636
|
bankTransaction,
|
|
2109
2637
|
name: `category-${bankTransaction.id}`,
|
|
@@ -2112,8 +2640,31 @@ var BankTransactionRow = ({
|
|
|
2112
2640
|
disabled: bankTransaction.processing
|
|
2113
2641
|
}
|
|
2114
2642
|
) : null,
|
|
2115
|
-
!editable && !
|
|
2116
|
-
|
|
2643
|
+
!editable && !open ? /* @__PURE__ */ React38.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ React38.createElement(React38.Fragment, null, /* @__PURE__ */ React38.createElement(
|
|
2644
|
+
Badge,
|
|
2645
|
+
{
|
|
2646
|
+
icon: /* @__PURE__ */ React38.createElement(Scissors_default, { size: 11 }),
|
|
2647
|
+
tooltip: /* @__PURE__ */ React38.createElement(
|
|
2648
|
+
SplitTooltipDetails,
|
|
2649
|
+
{
|
|
2650
|
+
classNamePrefix: className,
|
|
2651
|
+
category: bankTransaction.category
|
|
2652
|
+
}
|
|
2653
|
+
)
|
|
2654
|
+
},
|
|
2655
|
+
"Split"
|
|
2656
|
+
), /* @__PURE__ */ React38.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ React38.createElement(React38.Fragment, null, /* @__PURE__ */ React38.createElement(
|
|
2657
|
+
MatchBadge,
|
|
2658
|
+
{
|
|
2659
|
+
classNamePrefix: className,
|
|
2660
|
+
bankTransaction,
|
|
2661
|
+
dateFormat
|
|
2662
|
+
}
|
|
2663
|
+
), /* @__PURE__ */ React38.createElement("span", { className: `${className}__category-text__text` }, `${formatTime4(
|
|
2664
|
+
parseISO5(bankTransaction.match.bank_transaction.date),
|
|
2665
|
+
dateFormat
|
|
2666
|
+
)}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ React38.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
|
|
2667
|
+
editable || open ? /* @__PURE__ */ React38.createElement(
|
|
2117
2668
|
SubmitButton,
|
|
2118
2669
|
{
|
|
2119
2670
|
onClick: () => {
|
|
@@ -2124,38 +2675,198 @@ var BankTransactionRow = ({
|
|
|
2124
2675
|
className: "Layer__bank-transaction__submit-btn",
|
|
2125
2676
|
processing: bankTransaction.processing,
|
|
2126
2677
|
error: bankTransaction.error,
|
|
2127
|
-
active:
|
|
2678
|
+
active: open,
|
|
2679
|
+
action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
2128
2680
|
},
|
|
2129
|
-
editable ? "Approve" : "
|
|
2681
|
+
editable ? "Approve" : "Update"
|
|
2130
2682
|
) : null,
|
|
2131
|
-
/* @__PURE__ */
|
|
2132
|
-
|
|
2683
|
+
/* @__PURE__ */ React38.createElement(
|
|
2684
|
+
IconButton,
|
|
2685
|
+
{
|
|
2686
|
+
onClick: toggleOpen,
|
|
2687
|
+
className: "Layer__bank-transaction-row__expand-button",
|
|
2688
|
+
active: open,
|
|
2689
|
+
icon: open ? /* @__PURE__ */ React38.createElement(X_default, null) : /* @__PURE__ */ React38.createElement(ChevronDown_default, { className: "Layer__chevron Layer__chevron__down" })
|
|
2690
|
+
}
|
|
2691
|
+
)
|
|
2692
|
+
)
|
|
2693
|
+
)
|
|
2694
|
+
), /* @__PURE__ */ React38.createElement("tr", null, /* @__PURE__ */ React38.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ React38.createElement(
|
|
2695
|
+
ExpandedBankTransactionRow,
|
|
2696
|
+
{
|
|
2697
|
+
ref: expandedRowRef,
|
|
2698
|
+
bankTransaction,
|
|
2699
|
+
isOpen: open
|
|
2700
|
+
}
|
|
2701
|
+
))));
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
// src/components/BankTransactionListItem/Assignment.tsx
|
|
2705
|
+
import React39 from "react";
|
|
2706
|
+
import { parseISO as parseISO6, format as formatTime5 } from "date-fns";
|
|
2707
|
+
var Assignment = ({ bankTransaction }) => {
|
|
2708
|
+
if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
|
|
2709
|
+
return /* @__PURE__ */ React39.createElement(React39.Fragment, null, /* @__PURE__ */ React39.createElement(
|
|
2710
|
+
MatchBadge,
|
|
2711
|
+
{
|
|
2712
|
+
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
2713
|
+
bankTransaction,
|
|
2714
|
+
dateFormat: DATE_FORMAT,
|
|
2715
|
+
text: "Matched"
|
|
2716
|
+
}
|
|
2717
|
+
), /* @__PURE__ */ React39.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${formatTime5(
|
|
2718
|
+
parseISO6(bankTransaction.match.bank_transaction.date),
|
|
2719
|
+
DATE_FORMAT
|
|
2720
|
+
)}, ${bankTransaction.match.bank_transaction.description}`));
|
|
2721
|
+
}
|
|
2722
|
+
if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
|
|
2723
|
+
return /* @__PURE__ */ React39.createElement(React39.Fragment, null, /* @__PURE__ */ React39.createElement(
|
|
2724
|
+
Badge,
|
|
2725
|
+
{
|
|
2726
|
+
icon: /* @__PURE__ */ React39.createElement(Scissors_default, { size: 11 }),
|
|
2727
|
+
tooltip: /* @__PURE__ */ React39.createElement(
|
|
2728
|
+
SplitTooltipDetails,
|
|
2133
2729
|
{
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
}
|
|
2137
|
-
/* @__PURE__ */ React32.createElement(
|
|
2138
|
-
ChevronDown_default,
|
|
2139
|
-
{
|
|
2140
|
-
className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
2141
|
-
}
|
|
2142
|
-
)
|
|
2730
|
+
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
2731
|
+
category: bankTransaction.category
|
|
2732
|
+
}
|
|
2143
2733
|
)
|
|
2144
|
-
|
|
2734
|
+
},
|
|
2735
|
+
"Split"
|
|
2736
|
+
), /* @__PURE__ */ React39.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
|
|
2737
|
+
}
|
|
2738
|
+
return /* @__PURE__ */ React39.createElement(Text, null, bankTransaction?.category?.display_name);
|
|
2739
|
+
};
|
|
2740
|
+
|
|
2741
|
+
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
2742
|
+
import classNames16 from "classnames";
|
|
2743
|
+
import { parseISO as parseISO7, format as formatTime6 } from "date-fns";
|
|
2744
|
+
var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
2745
|
+
var BankTransactionListItem = ({
|
|
2746
|
+
dateFormat,
|
|
2747
|
+
bankTransaction,
|
|
2748
|
+
editable
|
|
2749
|
+
}) => {
|
|
2750
|
+
const expandedRowRef = useRef11(null);
|
|
2751
|
+
const [removed, setRemoved] = useState8(false);
|
|
2752
|
+
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
2753
|
+
const [selectedCategory, setSelectedCategory] = useState8(
|
|
2754
|
+
getDefaultSelectedCategory(bankTransaction)
|
|
2755
|
+
);
|
|
2756
|
+
const [open, setOpen] = useState8(false);
|
|
2757
|
+
const toggleOpen = () => setOpen(!open);
|
|
2758
|
+
const save = () => {
|
|
2759
|
+
if (open && expandedRowRef?.current) {
|
|
2760
|
+
expandedRowRef?.current?.save();
|
|
2761
|
+
setOpen(false);
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
if (!selectedCategory) {
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
if (selectedCategory.type === "match") {
|
|
2768
|
+
matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
|
|
2769
|
+
return;
|
|
2770
|
+
}
|
|
2771
|
+
categorizeBankTransaction2(bankTransaction.id, {
|
|
2772
|
+
type: "Category",
|
|
2773
|
+
category: {
|
|
2774
|
+
type: "StableName",
|
|
2775
|
+
stable_name: selectedCategory?.payload.stable_name || ""
|
|
2776
|
+
}
|
|
2777
|
+
});
|
|
2778
|
+
};
|
|
2779
|
+
if (removed) {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
const className = "Layer__bank-transaction-list-item";
|
|
2783
|
+
const openClassName = open ? `${className}--expanded` : "";
|
|
2784
|
+
const rowClassName = classNames16(
|
|
2785
|
+
className,
|
|
2786
|
+
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
2787
|
+
open ? openClassName : ""
|
|
2788
|
+
);
|
|
2789
|
+
return /* @__PURE__ */ React40.createElement("li", { className: rowClassName }, /* @__PURE__ */ React40.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ React40.createElement("span", { className: `${className}__heading-date` }, formatTime6(parseISO7(bankTransaction.date), dateFormat)), /* @__PURE__ */ React40.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ React40.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ React40.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ React40.createElement("span", { className: `${className}__body__name` }, bankTransaction.counterparty_name), /* @__PURE__ */ React40.createElement(
|
|
2790
|
+
"span",
|
|
2791
|
+
{
|
|
2792
|
+
className: `${className}__amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
|
|
2793
|
+
},
|
|
2794
|
+
isCredit2(bankTransaction) ? "+$" : " $",
|
|
2795
|
+
centsToDollars(bankTransaction.amount)
|
|
2796
|
+
), /* @__PURE__ */ React40.createElement(
|
|
2797
|
+
"div",
|
|
2798
|
+
{
|
|
2799
|
+
onClick: toggleOpen,
|
|
2800
|
+
className: "Layer__bank-transaction-row__expand-button"
|
|
2801
|
+
},
|
|
2802
|
+
/* @__PURE__ */ React40.createElement(
|
|
2803
|
+
ChevronDown_default,
|
|
2804
|
+
{
|
|
2805
|
+
className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
2806
|
+
}
|
|
2145
2807
|
)
|
|
2146
|
-
), /* @__PURE__ */
|
|
2808
|
+
)), /* @__PURE__ */ React40.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React40.createElement(
|
|
2147
2809
|
ExpandedBankTransactionRow,
|
|
2148
2810
|
{
|
|
2149
2811
|
ref: expandedRowRef,
|
|
2150
2812
|
bankTransaction,
|
|
2151
|
-
close:
|
|
2152
|
-
isOpen
|
|
2813
|
+
close: toggleOpen,
|
|
2814
|
+
isOpen: open,
|
|
2815
|
+
asListItem: true,
|
|
2816
|
+
submitBtnText: editable ? "Approve" : "Save"
|
|
2153
2817
|
}
|
|
2154
|
-
))
|
|
2818
|
+
)), /* @__PURE__ */ React40.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ React40.createElement(
|
|
2819
|
+
CategorySelect,
|
|
2820
|
+
{
|
|
2821
|
+
bankTransaction,
|
|
2822
|
+
name: `category-${bankTransaction.id}`,
|
|
2823
|
+
value: selectedCategory,
|
|
2824
|
+
onChange: setSelectedCategory,
|
|
2825
|
+
disabled: bankTransaction.processing
|
|
2826
|
+
}
|
|
2827
|
+
) : null, !editable ? /* @__PURE__ */ React40.createElement(Assignment, { bankTransaction }) : null, editable && /* @__PURE__ */ React40.createElement(
|
|
2828
|
+
SubmitButton,
|
|
2829
|
+
{
|
|
2830
|
+
onClick: () => {
|
|
2831
|
+
if (!bankTransaction.processing) {
|
|
2832
|
+
save();
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
className: "Layer__bank-transaction__submit-btn",
|
|
2836
|
+
processing: bankTransaction.processing,
|
|
2837
|
+
error: bankTransaction.error,
|
|
2838
|
+
iconOnly: true
|
|
2839
|
+
}
|
|
2840
|
+
)));
|
|
2155
2841
|
};
|
|
2156
2842
|
|
|
2157
2843
|
// src/components/Container/Container.tsx
|
|
2158
|
-
import
|
|
2844
|
+
import React41, { forwardRef as forwardRef3 } from "react";
|
|
2845
|
+
|
|
2846
|
+
// src/config/theme.ts
|
|
2847
|
+
var SHADES = {
|
|
2848
|
+
50: { s: 1, l: 98 },
|
|
2849
|
+
100: { s: 1, l: 96 },
|
|
2850
|
+
200: { s: 1, l: 94 },
|
|
2851
|
+
300: { s: 2, l: 92 },
|
|
2852
|
+
500: { s: 5, l: 53 },
|
|
2853
|
+
600: { s: 7, l: 40 },
|
|
2854
|
+
700: { s: 9, l: 27 },
|
|
2855
|
+
800: { s: 12, l: 20 },
|
|
2856
|
+
1e3: { s: 20, l: 7 }
|
|
2857
|
+
};
|
|
2858
|
+
var COLORS = {
|
|
2859
|
+
dark: {
|
|
2860
|
+
h: 0,
|
|
2861
|
+
s: 0,
|
|
2862
|
+
l: 7
|
|
2863
|
+
},
|
|
2864
|
+
light: {
|
|
2865
|
+
h: 0,
|
|
2866
|
+
s: 0,
|
|
2867
|
+
l: 100
|
|
2868
|
+
}
|
|
2869
|
+
};
|
|
2159
2870
|
|
|
2160
2871
|
// src/utils/colors.ts
|
|
2161
2872
|
var parseStylesFromThemeConfig = (theme) => {
|
|
@@ -2211,6 +2922,47 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2211
2922
|
return {};
|
|
2212
2923
|
}
|
|
2213
2924
|
};
|
|
2925
|
+
var parseColorFromThemeToHsl = (color) => {
|
|
2926
|
+
if (!color) {
|
|
2927
|
+
return;
|
|
2928
|
+
}
|
|
2929
|
+
try {
|
|
2930
|
+
if ("h" in color && "s" in color && "l" in color) {
|
|
2931
|
+
return {
|
|
2932
|
+
h: Number(color.h),
|
|
2933
|
+
s: Number(color.s),
|
|
2934
|
+
l: Number(color.l)
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
if ("r" in color && "g" in color && "b" in color) {
|
|
2938
|
+
const { h, s, l } = rgbToHsl(color);
|
|
2939
|
+
return {
|
|
2940
|
+
h,
|
|
2941
|
+
s,
|
|
2942
|
+
l
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
if ("hex" in color) {
|
|
2946
|
+
const rgb = hexToRgb(color.hex);
|
|
2947
|
+
if (!rgb) {
|
|
2948
|
+
return void 0;
|
|
2949
|
+
}
|
|
2950
|
+
const { h, s, l } = rgbToHsl({
|
|
2951
|
+
r: rgb.r.toString(),
|
|
2952
|
+
g: rgb.g.toString(),
|
|
2953
|
+
b: rgb.b.toString()
|
|
2954
|
+
});
|
|
2955
|
+
return {
|
|
2956
|
+
h,
|
|
2957
|
+
s,
|
|
2958
|
+
l
|
|
2959
|
+
};
|
|
2960
|
+
}
|
|
2961
|
+
return;
|
|
2962
|
+
} catch (_err) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2214
2966
|
var rgbToHsl = (color) => {
|
|
2215
2967
|
let r = Number(color.r);
|
|
2216
2968
|
let g = Number(color.g);
|
|
@@ -2241,42 +2993,113 @@ var hexToRgb = (hex) => {
|
|
|
2241
2993
|
b: values[2]
|
|
2242
2994
|
};
|
|
2243
2995
|
};
|
|
2996
|
+
var buildColorsPalette = (theme) => {
|
|
2997
|
+
const darkColor = parseColorFromThemeToHsl(theme?.colors?.dark) ?? COLORS.dark;
|
|
2998
|
+
const lightColor = parseColorFromThemeToHsl(theme?.colors?.light) ?? COLORS.light;
|
|
2999
|
+
return {
|
|
3000
|
+
50: buildColorShade(50, darkColor),
|
|
3001
|
+
100: buildColorShade(100, darkColor),
|
|
3002
|
+
200: buildColorShade(200, darkColor),
|
|
3003
|
+
300: buildColorShade(300, darkColor),
|
|
3004
|
+
400: {
|
|
3005
|
+
hsl: lightColor,
|
|
3006
|
+
rgb: hslToRgb(lightColor),
|
|
3007
|
+
hex: hslToHex(lightColor)
|
|
3008
|
+
},
|
|
3009
|
+
500: buildColorShade(500, darkColor),
|
|
3010
|
+
600: buildColorShade(600, darkColor),
|
|
3011
|
+
700: buildColorShade(700, darkColor),
|
|
3012
|
+
800: buildColorShade(800, darkColor),
|
|
3013
|
+
900: {
|
|
3014
|
+
hsl: darkColor,
|
|
3015
|
+
rgb: hslToRgb(darkColor),
|
|
3016
|
+
hex: hslToHex(darkColor)
|
|
3017
|
+
},
|
|
3018
|
+
1e3: buildColorShade(1e3, darkColor)
|
|
3019
|
+
};
|
|
3020
|
+
};
|
|
3021
|
+
var buildColorShade = (shade, darkColorHsl) => {
|
|
3022
|
+
const hsl = { h: darkColorHsl.h, ...SHADES[shade] };
|
|
3023
|
+
const rgb = hslToRgb(hsl);
|
|
3024
|
+
const hex = hslToHex(hsl);
|
|
3025
|
+
return { hsl, rgb, hex };
|
|
3026
|
+
};
|
|
3027
|
+
var hueToRgb = (p, q, t) => {
|
|
3028
|
+
if (t < 0)
|
|
3029
|
+
t += 1;
|
|
3030
|
+
if (t > 1)
|
|
3031
|
+
t -= 1;
|
|
3032
|
+
if (t < 1 / 6)
|
|
3033
|
+
return p + (q - p) * 6 * t;
|
|
3034
|
+
if (t < 1 / 2)
|
|
3035
|
+
return q;
|
|
3036
|
+
if (t < 2 / 3)
|
|
3037
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
3038
|
+
return p;
|
|
3039
|
+
};
|
|
3040
|
+
var hslToRgb = (hsl) => {
|
|
3041
|
+
let r, g, b;
|
|
3042
|
+
let l = hsl.l / 100;
|
|
3043
|
+
let s = hsl.s / 100;
|
|
3044
|
+
if (hsl.s === 0) {
|
|
3045
|
+
r = g = b = l;
|
|
3046
|
+
} else {
|
|
3047
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
3048
|
+
const p = 2 * l - q;
|
|
3049
|
+
r = hueToRgb(p, q, hsl.h + 1 / 3);
|
|
3050
|
+
g = hueToRgb(p, q, hsl.h);
|
|
3051
|
+
b = hueToRgb(p, q, hsl.h - 1 / 3);
|
|
3052
|
+
}
|
|
3053
|
+
return {
|
|
3054
|
+
r: Math.round(r * 255),
|
|
3055
|
+
g: Math.round(g * 255),
|
|
3056
|
+
b: Math.round(b * 255)
|
|
3057
|
+
};
|
|
3058
|
+
};
|
|
3059
|
+
var hslToHex = (hsl) => {
|
|
3060
|
+
const l = hsl.l / 100;
|
|
3061
|
+
const s = hsl.s;
|
|
3062
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
3063
|
+
const f = (n) => {
|
|
3064
|
+
const k = (n + hsl.h / 30) % 12;
|
|
3065
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
3066
|
+
return Math.round(255 * color).toString(16).padStart(2, "0");
|
|
3067
|
+
};
|
|
3068
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
3069
|
+
};
|
|
2244
3070
|
|
|
2245
3071
|
// src/components/Container/Container.tsx
|
|
2246
|
-
import
|
|
2247
|
-
var Container = (
|
|
2248
|
-
name,
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
className
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
const styles = parseStylesFromThemeConfig(theme);
|
|
2261
|
-
return /* @__PURE__ */ React33.createElement("div", { className: baseClassName, style: { ...styles } }, children);
|
|
2262
|
-
};
|
|
3072
|
+
import classNames17 from "classnames";
|
|
3073
|
+
var Container = forwardRef3(
|
|
3074
|
+
({ name, className, children, asWidget }, ref) => {
|
|
3075
|
+
const baseClassName = classNames17(
|
|
3076
|
+
"Layer__component Layer__component-container",
|
|
3077
|
+
`Layer__${name}`,
|
|
3078
|
+
asWidget ? "Layer__component--as-widget" : "",
|
|
3079
|
+
className
|
|
3080
|
+
);
|
|
3081
|
+
const { theme } = useLayerContext();
|
|
3082
|
+
const styles = parseStylesFromThemeConfig(theme);
|
|
3083
|
+
return /* @__PURE__ */ React41.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
|
|
3084
|
+
}
|
|
3085
|
+
);
|
|
2263
3086
|
|
|
2264
3087
|
// src/components/Container/Header.tsx
|
|
2265
|
-
import
|
|
2266
|
-
import
|
|
2267
|
-
var Header =
|
|
3088
|
+
import React42, { forwardRef as forwardRef4 } from "react";
|
|
3089
|
+
import classNames18 from "classnames";
|
|
3090
|
+
var Header = forwardRef4(
|
|
2268
3091
|
({ className, children, style }, ref) => {
|
|
2269
|
-
const baseClassName =
|
|
2270
|
-
return /* @__PURE__ */
|
|
3092
|
+
const baseClassName = classNames18("Layer__component-header", className);
|
|
3093
|
+
return /* @__PURE__ */ React42.createElement("header", { ref, className: baseClassName, style }, children);
|
|
2271
3094
|
}
|
|
2272
3095
|
);
|
|
2273
3096
|
|
|
2274
3097
|
// src/components/DataState/DataState.tsx
|
|
2275
|
-
import
|
|
3098
|
+
import React45 from "react";
|
|
2276
3099
|
|
|
2277
3100
|
// src/icons/AlertOctagon.tsx
|
|
2278
|
-
import * as
|
|
2279
|
-
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3101
|
+
import * as React43 from "react";
|
|
3102
|
+
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2280
3103
|
"svg",
|
|
2281
3104
|
{
|
|
2282
3105
|
viewBox: "0 0 18 18",
|
|
@@ -2286,7 +3109,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
|
|
|
2286
3109
|
width: size,
|
|
2287
3110
|
height: size
|
|
2288
3111
|
},
|
|
2289
|
-
/* @__PURE__ */
|
|
3112
|
+
/* @__PURE__ */ React43.createElement(
|
|
2290
3113
|
"path",
|
|
2291
3114
|
{
|
|
2292
3115
|
d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
|
|
@@ -2295,77 +3118,290 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
|
|
|
2295
3118
|
strokeLinejoin: "round"
|
|
2296
3119
|
}
|
|
2297
3120
|
),
|
|
2298
|
-
/* @__PURE__ */
|
|
3121
|
+
/* @__PURE__ */ React43.createElement(
|
|
3122
|
+
"path",
|
|
3123
|
+
{
|
|
3124
|
+
d: "M9 6V9",
|
|
3125
|
+
stroke: "currentColor",
|
|
3126
|
+
strokeLinecap: "round",
|
|
3127
|
+
strokeLinejoin: "round"
|
|
3128
|
+
}
|
|
3129
|
+
),
|
|
3130
|
+
/* @__PURE__ */ React43.createElement(
|
|
3131
|
+
"path",
|
|
3132
|
+
{
|
|
3133
|
+
d: "M9 12H9.0075",
|
|
3134
|
+
stroke: "currentColor",
|
|
3135
|
+
strokeLinecap: "round",
|
|
3136
|
+
strokeLinejoin: "round"
|
|
3137
|
+
}
|
|
3138
|
+
)
|
|
3139
|
+
);
|
|
3140
|
+
var AlertOctagon_default = AlertOctagon;
|
|
3141
|
+
|
|
3142
|
+
// src/icons/RefreshCcw.tsx
|
|
3143
|
+
import * as React44 from "react";
|
|
3144
|
+
var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React44.createElement(
|
|
3145
|
+
"svg",
|
|
3146
|
+
{
|
|
3147
|
+
viewBox: "0 0 18 18",
|
|
3148
|
+
fill: "none",
|
|
3149
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3150
|
+
...props,
|
|
3151
|
+
width: size,
|
|
3152
|
+
height: size
|
|
3153
|
+
},
|
|
3154
|
+
/* @__PURE__ */ React44.createElement(
|
|
3155
|
+
"path",
|
|
3156
|
+
{
|
|
3157
|
+
d: "M0.75 3V7.5H5.25",
|
|
3158
|
+
stroke: "currentColor",
|
|
3159
|
+
strokeLinecap: "round",
|
|
3160
|
+
strokeLinejoin: "round"
|
|
3161
|
+
}
|
|
3162
|
+
),
|
|
3163
|
+
/* @__PURE__ */ React44.createElement(
|
|
3164
|
+
"path",
|
|
3165
|
+
{
|
|
3166
|
+
d: "M17.25 15V10.5H12.75",
|
|
3167
|
+
stroke: "currentColor",
|
|
3168
|
+
strokeLinecap: "round",
|
|
3169
|
+
strokeLinejoin: "round"
|
|
3170
|
+
}
|
|
3171
|
+
),
|
|
3172
|
+
/* @__PURE__ */ React44.createElement(
|
|
3173
|
+
"path",
|
|
3174
|
+
{
|
|
3175
|
+
d: "M15.3675 6.75C14.9871 5.67508 14.3407 4.71405 13.4884 3.95656C12.6361 3.19907 11.6059 2.66982 10.4938 2.41819C9.38167 2.16656 8.22393 2.20075 7.12861 2.51758C6.03328 2.8344 5.03606 3.42353 4.23 4.23L0.75 7.5M17.25 10.5L13.77 13.77C12.9639 14.5765 11.9667 15.1656 10.8714 15.4824C9.77607 15.7992 8.61833 15.8334 7.50621 15.5818C6.3941 15.3302 5.36385 14.8009 4.5116 14.0434C3.65935 13.2859 3.01288 12.3249 2.6325 11.25",
|
|
3176
|
+
stroke: "currentColor",
|
|
3177
|
+
strokeLinecap: "round",
|
|
3178
|
+
strokeLinejoin: "round"
|
|
3179
|
+
}
|
|
3180
|
+
)
|
|
3181
|
+
);
|
|
3182
|
+
var RefreshCcw_default = RefreshCcw;
|
|
3183
|
+
|
|
3184
|
+
// src/components/DataState/DataState.tsx
|
|
3185
|
+
var getIcon = (status) => {
|
|
3186
|
+
switch (status) {
|
|
3187
|
+
case "failed" /* failed */:
|
|
3188
|
+
return /* @__PURE__ */ React45.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ React45.createElement(AlertOctagon_default, { size: 12 }));
|
|
3189
|
+
default:
|
|
3190
|
+
return /* @__PURE__ */ React45.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ React45.createElement(CheckCircle_default, { size: 12 }));
|
|
3191
|
+
}
|
|
3192
|
+
};
|
|
3193
|
+
var DataState = ({
|
|
3194
|
+
status,
|
|
3195
|
+
title,
|
|
3196
|
+
description,
|
|
3197
|
+
onRefresh,
|
|
3198
|
+
isLoading
|
|
3199
|
+
}) => {
|
|
3200
|
+
return /* @__PURE__ */ React45.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ React45.createElement(
|
|
3201
|
+
Text,
|
|
3202
|
+
{
|
|
3203
|
+
as: "span",
|
|
3204
|
+
size: "lg" /* lg */,
|
|
3205
|
+
weight: "bold" /* bold */,
|
|
3206
|
+
className: "Layer__data-state__title"
|
|
3207
|
+
},
|
|
3208
|
+
title
|
|
3209
|
+
), /* @__PURE__ */ React45.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ React45.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ React45.createElement(
|
|
3210
|
+
Button,
|
|
3211
|
+
{
|
|
3212
|
+
variant: "secondary" /* secondary */,
|
|
3213
|
+
rightIcon: isLoading ? /* @__PURE__ */ React45.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ React45.createElement(RefreshCcw_default, { size: 12 }),
|
|
3214
|
+
onClick: onRefresh,
|
|
3215
|
+
disabled: isLoading
|
|
3216
|
+
},
|
|
3217
|
+
"Refresh"
|
|
3218
|
+
)));
|
|
3219
|
+
};
|
|
3220
|
+
|
|
3221
|
+
// src/components/Loader/Loader.tsx
|
|
3222
|
+
import React46 from "react";
|
|
3223
|
+
var Loader2 = ({ children }) => {
|
|
3224
|
+
return /* @__PURE__ */ React46.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ React46.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
|
|
3225
|
+
};
|
|
3226
|
+
|
|
3227
|
+
// src/components/Pagination/Pagination.tsx
|
|
3228
|
+
import React49 from "react";
|
|
3229
|
+
|
|
3230
|
+
// src/hooks/usePagination/usePagination.ts
|
|
3231
|
+
import { useMemo } from "react";
|
|
3232
|
+
|
|
3233
|
+
// src/utils/helpers.ts
|
|
3234
|
+
var range = (start, end) => {
|
|
3235
|
+
let length = end - start + 1;
|
|
3236
|
+
return Array.from({ length }, (_, idx) => idx + start);
|
|
3237
|
+
};
|
|
3238
|
+
|
|
3239
|
+
// src/hooks/usePagination/usePagination.ts
|
|
3240
|
+
var DOTS = "...";
|
|
3241
|
+
var usePagination = ({
|
|
3242
|
+
totalCount,
|
|
3243
|
+
pageSize,
|
|
3244
|
+
siblingCount = 1,
|
|
3245
|
+
currentPage
|
|
3246
|
+
}) => {
|
|
3247
|
+
const paginationRange = useMemo(() => {
|
|
3248
|
+
const totalPageCount = Math.ceil(totalCount / pageSize);
|
|
3249
|
+
const totalPageNumbers = siblingCount + 5;
|
|
3250
|
+
if (totalPageNumbers >= totalPageCount) {
|
|
3251
|
+
return range(1, totalPageCount);
|
|
3252
|
+
}
|
|
3253
|
+
const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
|
|
3254
|
+
const rightSiblingIndex = Math.min(
|
|
3255
|
+
currentPage + siblingCount,
|
|
3256
|
+
totalPageCount
|
|
3257
|
+
);
|
|
3258
|
+
const shouldShowLeftDots = leftSiblingIndex > 2;
|
|
3259
|
+
const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
|
|
3260
|
+
const firstPageIndex = 1;
|
|
3261
|
+
const lastPageIndex = totalPageCount;
|
|
3262
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
3263
|
+
let leftItemCount = 3 + 2 * siblingCount;
|
|
3264
|
+
let leftRange = range(1, leftItemCount);
|
|
3265
|
+
return [...leftRange, DOTS, totalPageCount];
|
|
3266
|
+
}
|
|
3267
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
3268
|
+
let rightItemCount = 3 + 2 * siblingCount;
|
|
3269
|
+
let rightRange = range(
|
|
3270
|
+
totalPageCount - rightItemCount + 1,
|
|
3271
|
+
totalPageCount
|
|
3272
|
+
);
|
|
3273
|
+
return [firstPageIndex, DOTS, ...rightRange];
|
|
3274
|
+
}
|
|
3275
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
3276
|
+
let middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
3277
|
+
return [firstPageIndex, DOTS, ...middleRange, DOTS, lastPageIndex];
|
|
3278
|
+
}
|
|
3279
|
+
}, [totalCount, pageSize, siblingCount, currentPage]);
|
|
3280
|
+
return paginationRange;
|
|
3281
|
+
};
|
|
3282
|
+
|
|
3283
|
+
// src/icons/ChevronLeft.tsx
|
|
3284
|
+
import * as React47 from "react";
|
|
3285
|
+
var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React47.createElement(
|
|
3286
|
+
"svg",
|
|
3287
|
+
{
|
|
3288
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3289
|
+
width: "18",
|
|
3290
|
+
height: "18",
|
|
3291
|
+
viewBox: "0 0 18 18",
|
|
3292
|
+
fill: "none",
|
|
3293
|
+
...props
|
|
3294
|
+
},
|
|
3295
|
+
/* @__PURE__ */ React47.createElement(
|
|
2299
3296
|
"path",
|
|
2300
3297
|
{
|
|
2301
|
-
d: "
|
|
3298
|
+
d: "M11.25 13.5L6.75 9L11.25 4.5",
|
|
2302
3299
|
stroke: "currentColor",
|
|
2303
3300
|
strokeLinecap: "round",
|
|
2304
3301
|
strokeLinejoin: "round"
|
|
2305
3302
|
}
|
|
2306
|
-
)
|
|
2307
|
-
|
|
3303
|
+
)
|
|
3304
|
+
);
|
|
3305
|
+
var ChevronLeft_default = ChevronLeft;
|
|
3306
|
+
|
|
3307
|
+
// src/icons/ChevronRight.tsx
|
|
3308
|
+
import * as React48 from "react";
|
|
3309
|
+
var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React48.createElement(
|
|
3310
|
+
"svg",
|
|
3311
|
+
{
|
|
3312
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3313
|
+
width: "18",
|
|
3314
|
+
height: "18",
|
|
3315
|
+
viewBox: "0 0 18 18",
|
|
3316
|
+
fill: "none",
|
|
3317
|
+
...props
|
|
3318
|
+
},
|
|
3319
|
+
/* @__PURE__ */ React48.createElement(
|
|
2308
3320
|
"path",
|
|
2309
3321
|
{
|
|
2310
|
-
d: "
|
|
3322
|
+
d: "M6.75 13.5L11.25 9L6.75 4.5",
|
|
2311
3323
|
stroke: "currentColor",
|
|
2312
3324
|
strokeLinecap: "round",
|
|
2313
3325
|
strokeLinejoin: "round"
|
|
2314
3326
|
}
|
|
2315
3327
|
)
|
|
2316
3328
|
);
|
|
2317
|
-
var
|
|
3329
|
+
var ChevronRight_default = ChavronRight;
|
|
2318
3330
|
|
|
2319
|
-
// src/components/
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
};
|
|
2328
|
-
var DataState = ({
|
|
2329
|
-
status,
|
|
2330
|
-
title,
|
|
2331
|
-
description,
|
|
2332
|
-
onRefresh,
|
|
2333
|
-
isLoading
|
|
3331
|
+
// src/components/Pagination/Pagination.tsx
|
|
3332
|
+
import classnames from "classnames";
|
|
3333
|
+
var Pagination = ({
|
|
3334
|
+
onPageChange,
|
|
3335
|
+
totalCount,
|
|
3336
|
+
siblingCount = 1,
|
|
3337
|
+
currentPage,
|
|
3338
|
+
pageSize
|
|
2334
3339
|
}) => {
|
|
2335
|
-
|
|
2336
|
-
|
|
3340
|
+
const paginationRange = usePagination({
|
|
3341
|
+
currentPage,
|
|
3342
|
+
totalCount,
|
|
3343
|
+
siblingCount,
|
|
3344
|
+
pageSize
|
|
3345
|
+
});
|
|
3346
|
+
if (!paginationRange) {
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
if (currentPage === 0 || paginationRange.length < 2) {
|
|
3350
|
+
return;
|
|
3351
|
+
}
|
|
3352
|
+
let lastPage = paginationRange[paginationRange.length - 1];
|
|
3353
|
+
return /* @__PURE__ */ React49.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ React49.createElement(
|
|
3354
|
+
"li",
|
|
2337
3355
|
{
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
3356
|
+
className: classnames(
|
|
3357
|
+
"Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--previous",
|
|
3358
|
+
{
|
|
3359
|
+
disabled: currentPage === 1
|
|
3360
|
+
}
|
|
3361
|
+
),
|
|
3362
|
+
onClick: () => onPageChange(currentPage - 1)
|
|
2342
3363
|
},
|
|
2343
|
-
|
|
2344
|
-
),
|
|
2345
|
-
|
|
3364
|
+
/* @__PURE__ */ React49.createElement(ChevronLeft_default, { size: 12 })
|
|
3365
|
+
), paginationRange.map((pageNumber) => {
|
|
3366
|
+
if (pageNumber === DOTS) {
|
|
3367
|
+
return /* @__PURE__ */ React49.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
|
|
3368
|
+
}
|
|
3369
|
+
return /* @__PURE__ */ React49.createElement(
|
|
3370
|
+
"li",
|
|
3371
|
+
{
|
|
3372
|
+
className: classnames("Layer__pagination-item", {
|
|
3373
|
+
selected: pageNumber === currentPage
|
|
3374
|
+
}),
|
|
3375
|
+
onClick: () => {
|
|
3376
|
+
if (typeof pageNumber === "number") {
|
|
3377
|
+
onPageChange(pageNumber);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
},
|
|
3381
|
+
pageNumber
|
|
3382
|
+
);
|
|
3383
|
+
}), /* @__PURE__ */ React49.createElement(
|
|
3384
|
+
"li",
|
|
2346
3385
|
{
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
3386
|
+
className: classnames(
|
|
3387
|
+
"Layer__pagination-item Layer__pagination-arrow Layer__pagination-arrow--next",
|
|
3388
|
+
{
|
|
3389
|
+
disabled: currentPage === lastPage
|
|
3390
|
+
}
|
|
3391
|
+
),
|
|
3392
|
+
onClick: () => onPageChange(currentPage + 1)
|
|
2351
3393
|
},
|
|
2352
|
-
|
|
2353
|
-
))
|
|
2354
|
-
};
|
|
2355
|
-
|
|
2356
|
-
// src/components/Loader/Loader.tsx
|
|
2357
|
-
import React37 from "react";
|
|
2358
|
-
var Loader2 = ({ children }) => {
|
|
2359
|
-
return /* @__PURE__ */ React37.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ React37.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
|
|
3394
|
+
/* @__PURE__ */ React49.createElement(ChevronRight_default, { size: 12 })
|
|
3395
|
+
));
|
|
2360
3396
|
};
|
|
2361
3397
|
|
|
2362
3398
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
2363
3399
|
var COMPONENT_NAME = "bank-transactions";
|
|
2364
|
-
var dateFormat = "LLL d, yyyy";
|
|
2365
3400
|
var CategorizedCategories = [
|
|
2366
3401
|
"CATEGORIZED" /* CATEGORIZED */,
|
|
2367
3402
|
"JOURNALING" /* JOURNALING */,
|
|
2368
|
-
"SPLIT" /* SPLIT
|
|
3403
|
+
"SPLIT" /* SPLIT */,
|
|
3404
|
+
"MATCHED" /* MATCHED */
|
|
2369
3405
|
];
|
|
2370
3406
|
var ReviewCategories = [
|
|
2371
3407
|
"READY_FOR_INPUT" /* READY_FOR_INPUT */,
|
|
@@ -2379,18 +3415,27 @@ var filterVisibility = (display) => (bankTransaction) => {
|
|
|
2379
3415
|
return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
|
|
2380
3416
|
};
|
|
2381
3417
|
var BankTransactions = ({
|
|
2382
|
-
asWidget = false
|
|
3418
|
+
asWidget = false,
|
|
3419
|
+
pageSize = 15
|
|
2383
3420
|
}) => {
|
|
2384
3421
|
const [display, setDisplay] = useState9("review" /* review */);
|
|
3422
|
+
const [currentPage, setCurrentPage] = useState9(1);
|
|
2385
3423
|
const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
|
|
2386
|
-
const
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
3424
|
+
const bankTransactionsByFilter = data?.filter(filterVisibility(display));
|
|
3425
|
+
const bankTransactions = useMemo2(() => {
|
|
3426
|
+
const firstPageIndex = (currentPage - 1) * pageSize;
|
|
3427
|
+
const lastPageIndex = firstPageIndex + pageSize;
|
|
3428
|
+
return bankTransactionsByFilter?.slice(firstPageIndex, lastPageIndex);
|
|
3429
|
+
}, [currentPage, bankTransactionsByFilter]);
|
|
3430
|
+
const onCategorizationDisplayChange = (event) => {
|
|
3431
|
+
setDisplay(
|
|
3432
|
+
event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
|
|
3433
|
+
);
|
|
3434
|
+
setCurrentPage(1);
|
|
3435
|
+
};
|
|
2392
3436
|
const [shiftStickyHeader, setShiftStickyHeader] = useState9(0);
|
|
2393
|
-
const
|
|
3437
|
+
const [listView, setListView] = useState9(false);
|
|
3438
|
+
const containerRef = useElementSize((_el, _en, size) => {
|
|
2394
3439
|
if (size?.height && size?.height >= 90) {
|
|
2395
3440
|
const newShift = -Math.floor(size.height / 2) + 6;
|
|
2396
3441
|
if (newShift !== shiftStickyHeader) {
|
|
@@ -2399,17 +3444,21 @@ var BankTransactions = ({
|
|
|
2399
3444
|
} else if (size?.height > 0 && shiftStickyHeader !== 0) {
|
|
2400
3445
|
setShiftStickyHeader(0);
|
|
2401
3446
|
}
|
|
3447
|
+
if (size.width > 700 && listView) {
|
|
3448
|
+
setListView(false);
|
|
3449
|
+
} else if (size.width <= 700 && !listView) {
|
|
3450
|
+
setListView(true);
|
|
3451
|
+
}
|
|
2402
3452
|
});
|
|
2403
3453
|
const editable = display === "review" /* review */;
|
|
2404
|
-
return /* @__PURE__ */
|
|
3454
|
+
return /* @__PURE__ */ React50.createElement(Container, { name: COMPONENT_NAME, asWidget, ref: containerRef }, /* @__PURE__ */ React50.createElement(
|
|
2405
3455
|
Header,
|
|
2406
3456
|
{
|
|
2407
|
-
ref: headerRef,
|
|
2408
3457
|
className: "Layer__bank-transactions__header",
|
|
2409
3458
|
style: { top: shiftStickyHeader }
|
|
2410
3459
|
},
|
|
2411
|
-
/* @__PURE__ */
|
|
2412
|
-
/* @__PURE__ */
|
|
3460
|
+
/* @__PURE__ */ React50.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
3461
|
+
/* @__PURE__ */ React50.createElement(
|
|
2413
3462
|
Toggle,
|
|
2414
3463
|
{
|
|
2415
3464
|
name: "bank-transaction-display",
|
|
@@ -2421,35 +3470,31 @@ var BankTransactions = ({
|
|
|
2421
3470
|
onChange: onCategorizationDisplayChange
|
|
2422
3471
|
}
|
|
2423
3472
|
)
|
|
2424
|
-
), /* @__PURE__ */
|
|
3473
|
+
), !listView && /* @__PURE__ */ React50.createElement(
|
|
2425
3474
|
"table",
|
|
2426
3475
|
{
|
|
2427
3476
|
width: "100%",
|
|
2428
|
-
className: "Layer__table Layer__bank-transactions__table"
|
|
3477
|
+
className: "Layer__table Layer__bank-transactions__table with-cell-separators"
|
|
2429
3478
|
},
|
|
2430
|
-
/* @__PURE__ */
|
|
2431
|
-
/* @__PURE__ */
|
|
3479
|
+
/* @__PURE__ */ React50.createElement("thead", null, /* @__PURE__ */ React50.createElement("tr", null, /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ React50.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
|
|
3480
|
+
/* @__PURE__ */ React50.createElement("tbody", null, !isLoading && bankTransactions?.map((bankTransaction) => /* @__PURE__ */ React50.createElement(
|
|
2432
3481
|
BankTransactionRow,
|
|
2433
3482
|
{
|
|
2434
3483
|
key: bankTransaction.id,
|
|
2435
|
-
dateFormat,
|
|
3484
|
+
dateFormat: DATE_FORMAT,
|
|
2436
3485
|
bankTransaction,
|
|
2437
|
-
isOpen: openRows[bankTransaction.id],
|
|
2438
|
-
toggleOpen,
|
|
2439
3486
|
editable
|
|
2440
3487
|
}
|
|
2441
3488
|
)))
|
|
2442
|
-
), isLoading && !bankTransactions ? /* @__PURE__ */
|
|
3489
|
+
), isLoading && !bankTransactions ? /* @__PURE__ */ React50.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ React50.createElement(Loader2, null)) : null, !isLoading && listView ? /* @__PURE__ */ React50.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map((bankTransaction) => /* @__PURE__ */ React50.createElement(
|
|
2443
3490
|
BankTransactionListItem,
|
|
2444
3491
|
{
|
|
2445
3492
|
key: bankTransaction.id,
|
|
2446
|
-
dateFormat,
|
|
3493
|
+
dateFormat: DATE_FORMAT,
|
|
2447
3494
|
bankTransaction,
|
|
2448
|
-
isOpen: openRows[bankTransaction.id],
|
|
2449
|
-
toggleOpen,
|
|
2450
3495
|
editable
|
|
2451
3496
|
}
|
|
2452
|
-
))), !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */
|
|
3497
|
+
))) : null, !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ React50.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React50.createElement(
|
|
2453
3498
|
DataState,
|
|
2454
3499
|
{
|
|
2455
3500
|
status: "allDone" /* allDone */,
|
|
@@ -2458,7 +3503,7 @@ var BankTransactions = ({
|
|
|
2458
3503
|
onRefresh: () => refetch(),
|
|
2459
3504
|
isLoading: isValidating
|
|
2460
3505
|
}
|
|
2461
|
-
)) : null, !isLoading && error ? /* @__PURE__ */
|
|
3506
|
+
)) : null, !isLoading && error ? /* @__PURE__ */ React50.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React50.createElement(
|
|
2462
3507
|
DataState,
|
|
2463
3508
|
{
|
|
2464
3509
|
status: "failed" /* failed */,
|
|
@@ -2467,11 +3512,19 @@ var BankTransactions = ({
|
|
|
2467
3512
|
onRefresh: () => refetch(),
|
|
2468
3513
|
isLoading: isValidating
|
|
2469
3514
|
}
|
|
2470
|
-
)) : null
|
|
3515
|
+
)) : null, /* @__PURE__ */ React50.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ React50.createElement(
|
|
3516
|
+
Pagination,
|
|
3517
|
+
{
|
|
3518
|
+
currentPage,
|
|
3519
|
+
totalCount: bankTransactionsByFilter?.length || 0,
|
|
3520
|
+
pageSize,
|
|
3521
|
+
onPageChange: (page) => setCurrentPage(page)
|
|
3522
|
+
}
|
|
3523
|
+
)));
|
|
2471
3524
|
};
|
|
2472
3525
|
|
|
2473
3526
|
// src/components/Hello/Hello.tsx
|
|
2474
|
-
import
|
|
3527
|
+
import React51 from "react";
|
|
2475
3528
|
import useSWR3 from "swr";
|
|
2476
3529
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
2477
3530
|
var Hello = ({ user }) => {
|
|
@@ -2480,17 +3533,22 @@ var Hello = ({ user }) => {
|
|
|
2480
3533
|
fetcher
|
|
2481
3534
|
);
|
|
2482
3535
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
2483
|
-
return /* @__PURE__ */
|
|
3536
|
+
return /* @__PURE__ */ React51.createElement(React51.Fragment, null, /* @__PURE__ */ React51.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
2484
3537
|
};
|
|
2485
3538
|
|
|
2486
3539
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2487
|
-
import
|
|
3540
|
+
import React59, { createContext as createContext2 } from "react";
|
|
2488
3541
|
|
|
2489
3542
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
2490
3543
|
import { useState as useState10 } from "react";
|
|
2491
3544
|
import { startOfMonth, endOfMonth, formatISO } from "date-fns";
|
|
2492
3545
|
import useSWR4 from "swr";
|
|
2493
|
-
var useProfitAndLoss = ({
|
|
3546
|
+
var useProfitAndLoss = ({
|
|
3547
|
+
startDate: initialStartDate,
|
|
3548
|
+
endDate: initialEndDate,
|
|
3549
|
+
tagFilter,
|
|
3550
|
+
reportingBasis
|
|
3551
|
+
} = {
|
|
2494
3552
|
startDate: startOfMonth(/* @__PURE__ */ new Date()),
|
|
2495
3553
|
endDate: endOfMonth(/* @__PURE__ */ new Date())
|
|
2496
3554
|
}) => {
|
|
@@ -2504,14 +3562,21 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2504
3562
|
const {
|
|
2505
3563
|
data: rawData,
|
|
2506
3564
|
isLoading,
|
|
2507
|
-
|
|
3565
|
+
isValidating,
|
|
3566
|
+
error: rawError,
|
|
3567
|
+
mutate
|
|
2508
3568
|
} = useSWR4(
|
|
2509
|
-
businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}
|
|
3569
|
+
businessId && startDate && endDate && auth?.access_token && `profit-and-loss-${businessId}-${startDate.valueOf()}-${endDate.valueOf()}-${tagFilter?.key}-${tagFilter?.values?.join(
|
|
3570
|
+
","
|
|
3571
|
+
)}-${reportingBasis}`,
|
|
2510
3572
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
2511
3573
|
params: {
|
|
2512
3574
|
businessId,
|
|
2513
3575
|
startDate: formatISO(startDate),
|
|
2514
|
-
endDate: formatISO(endDate)
|
|
3576
|
+
endDate: formatISO(endDate),
|
|
3577
|
+
tagKey: tagFilter?.key,
|
|
3578
|
+
tagValues: tagFilter?.values?.join(","),
|
|
3579
|
+
reportingBasis
|
|
2515
3580
|
}
|
|
2516
3581
|
})
|
|
2517
3582
|
);
|
|
@@ -2523,20 +3588,28 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2523
3588
|
newStartDate && setStartDate(newStartDate);
|
|
2524
3589
|
newEndDate && setEndDate(newEndDate);
|
|
2525
3590
|
};
|
|
3591
|
+
const refetch = () => {
|
|
3592
|
+
mutate();
|
|
3593
|
+
};
|
|
2526
3594
|
return {
|
|
2527
3595
|
data,
|
|
2528
3596
|
isLoading,
|
|
3597
|
+
isValidating,
|
|
2529
3598
|
error: error || rawError,
|
|
2530
3599
|
dateRange: { startDate, endDate },
|
|
3600
|
+
refetch,
|
|
2531
3601
|
changeDateRange
|
|
2532
3602
|
};
|
|
2533
3603
|
};
|
|
2534
3604
|
|
|
2535
3605
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2536
|
-
import
|
|
3606
|
+
import React53, { useContext as useContext2, useMemo as useMemo3, useState as useState11 } from "react";
|
|
3607
|
+
|
|
3608
|
+
// src/utils/format.ts
|
|
3609
|
+
var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
2537
3610
|
|
|
2538
3611
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
2539
|
-
import
|
|
3612
|
+
import React52, { useEffect as useEffect4 } from "react";
|
|
2540
3613
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
2541
3614
|
var Indicator = ({
|
|
2542
3615
|
viewBox = {},
|
|
@@ -2547,35 +3620,34 @@ var Indicator = ({
|
|
|
2547
3620
|
if (!className?.match(/selected/)) {
|
|
2548
3621
|
return null;
|
|
2549
3622
|
}
|
|
2550
|
-
const {
|
|
2551
|
-
x: animateTo = 0,
|
|
2552
|
-
y = 0,
|
|
2553
|
-
width = 0,
|
|
2554
|
-
height = 0
|
|
2555
|
-
} = "x" in viewBox ? viewBox : emptyViewBox;
|
|
3623
|
+
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
2556
3624
|
const boxWidth = width * 2 + 4;
|
|
2557
3625
|
const multiplier = 1.5;
|
|
2558
3626
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
2559
|
-
|
|
3627
|
+
useEffect4(() => {
|
|
2560
3628
|
setAnimateFrom(animateTo);
|
|
2561
3629
|
}, [animateTo]);
|
|
2562
3630
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
2563
|
-
return /* @__PURE__ */
|
|
3631
|
+
return /* @__PURE__ */ React52.createElement(
|
|
2564
3632
|
"rect",
|
|
2565
3633
|
{
|
|
2566
3634
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
3635
|
+
rx: "8",
|
|
3636
|
+
ry: "8",
|
|
2567
3637
|
style: {
|
|
2568
3638
|
width: `${boxWidth * multiplier}px`,
|
|
2569
3639
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
2570
3640
|
x: actualX - xOffset,
|
|
2571
|
-
y:
|
|
3641
|
+
y: 5,
|
|
3642
|
+
borderRadius: 8,
|
|
3643
|
+
height: "calc(100% - 10px)"
|
|
2572
3644
|
}
|
|
2573
3645
|
}
|
|
2574
3646
|
);
|
|
2575
3647
|
};
|
|
2576
3648
|
|
|
2577
3649
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2578
|
-
import { endOfMonth as endOfMonth2, format as format4, parseISO as
|
|
3650
|
+
import { endOfMonth as endOfMonth2, format as format4, parseISO as parseISO8, startOfMonth as startOfMonth2, sub } from "date-fns";
|
|
2579
3651
|
import {
|
|
2580
3652
|
BarChart,
|
|
2581
3653
|
XAxis,
|
|
@@ -2584,11 +3656,14 @@ import {
|
|
|
2584
3656
|
LabelList,
|
|
2585
3657
|
CartesianGrid,
|
|
2586
3658
|
Legend,
|
|
2587
|
-
ResponsiveContainer
|
|
3659
|
+
ResponsiveContainer,
|
|
3660
|
+
Tooltip as Tooltip2,
|
|
3661
|
+
Rectangle
|
|
2588
3662
|
} from "recharts";
|
|
2589
3663
|
var barGap = 4;
|
|
2590
3664
|
var barSize = 20;
|
|
2591
3665
|
var ProfitAndLossChart = () => {
|
|
3666
|
+
const { getColor } = useLayerContext();
|
|
2592
3667
|
const { changeDateRange, dateRange } = useContext2(ProfitAndLoss.Context);
|
|
2593
3668
|
const thisMonth = startOfMonth2(Date.now());
|
|
2594
3669
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
@@ -2666,24 +3741,50 @@ var ProfitAndLossChart = () => {
|
|
|
2666
3741
|
endDate: endOfMonth2(thisMonth)
|
|
2667
3742
|
})?.data
|
|
2668
3743
|
);
|
|
2669
|
-
const getMonthName = (pnl) => pnl ? format4(
|
|
3744
|
+
const getMonthName = (pnl) => pnl ? format4(parseISO8(pnl.start_date), "LLL") : "";
|
|
2670
3745
|
const summarizePnL = (pnl) => ({
|
|
2671
3746
|
name: getMonthName(pnl),
|
|
2672
3747
|
revenue: pnl?.income.value || 0,
|
|
2673
|
-
expenses: (pnl?.income.value || 0) - (pnl?.net_profit || 0),
|
|
2674
|
-
selected: !!pnl &&
|
|
3748
|
+
expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
|
|
3749
|
+
selected: !!pnl && parseISO8(pnl.start_date).getMonth() >= startSelectionMonth && parseISO8(pnl.end_date).getMonth() <= endSelectionMonth
|
|
2675
3750
|
});
|
|
2676
3751
|
const onClick = ({ activeTooltipIndex }) => {
|
|
2677
3752
|
const selection = monthData[activeTooltipIndex || -1];
|
|
2678
3753
|
if (selection) {
|
|
2679
3754
|
const { start_date: startDate, end_date: endDate } = selection;
|
|
2680
3755
|
changeDateRange({
|
|
2681
|
-
startDate:
|
|
2682
|
-
endDate:
|
|
3756
|
+
startDate: parseISO8(startDate),
|
|
3757
|
+
endDate: parseISO8(endDate)
|
|
2683
3758
|
});
|
|
2684
3759
|
}
|
|
2685
3760
|
};
|
|
2686
|
-
const
|
|
3761
|
+
const CustomTooltip = ({
|
|
3762
|
+
active,
|
|
3763
|
+
payload,
|
|
3764
|
+
label
|
|
3765
|
+
}) => {
|
|
3766
|
+
if (active && payload && payload.length) {
|
|
3767
|
+
return /* @__PURE__ */ React53.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ React53.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ React53.createElement("li", null, /* @__PURE__ */ React53.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ React53.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ React53.createElement("li", null, /* @__PURE__ */ React53.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ React53.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0))))));
|
|
3768
|
+
}
|
|
3769
|
+
return null;
|
|
3770
|
+
};
|
|
3771
|
+
const CustomizedCursor = (props) => {
|
|
3772
|
+
const { x, y, width, height } = props;
|
|
3773
|
+
return /* @__PURE__ */ React53.createElement(
|
|
3774
|
+
Rectangle,
|
|
3775
|
+
{
|
|
3776
|
+
fill: getColor(100)?.hex ?? "#F5F4F3",
|
|
3777
|
+
stroke: "none",
|
|
3778
|
+
x,
|
|
3779
|
+
y,
|
|
3780
|
+
radius: 8,
|
|
3781
|
+
width,
|
|
3782
|
+
height: height + 24,
|
|
3783
|
+
className: "Layer__chart__tooltip-cursor"
|
|
3784
|
+
}
|
|
3785
|
+
);
|
|
3786
|
+
};
|
|
3787
|
+
const data = useMemo3(
|
|
2687
3788
|
() => monthData.map(summarizePnL),
|
|
2688
3789
|
[
|
|
2689
3790
|
startSelectionMonth,
|
|
@@ -2692,135 +3793,112 @@ var ProfitAndLossChart = () => {
|
|
|
2692
3793
|
]
|
|
2693
3794
|
);
|
|
2694
3795
|
const [animateFrom, setAnimateFrom] = useState11(-1);
|
|
2695
|
-
return /* @__PURE__ */
|
|
2696
|
-
|
|
3796
|
+
return /* @__PURE__ */ React53.createElement(
|
|
3797
|
+
ResponsiveContainer,
|
|
2697
3798
|
{
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
className: "Layer__profit-and-loss-chart"
|
|
3799
|
+
className: "Layer__chart-container",
|
|
3800
|
+
width: "100%",
|
|
3801
|
+
height: "100%",
|
|
3802
|
+
minHeight: 200
|
|
2703
3803
|
},
|
|
2704
|
-
/* @__PURE__ */
|
|
2705
|
-
|
|
2706
|
-
Legend,
|
|
2707
|
-
{
|
|
2708
|
-
verticalAlign: "top",
|
|
2709
|
-
align: "left",
|
|
2710
|
-
payload: [
|
|
2711
|
-
{ value: "Income", type: "circle", id: "IncomeLegend" },
|
|
2712
|
-
{ value: "Expenses", type: "circle", id: "ExpensesLegend" }
|
|
2713
|
-
]
|
|
2714
|
-
}
|
|
2715
|
-
),
|
|
2716
|
-
/* @__PURE__ */ React41.createElement(XAxis, { dataKey: "name", tickLine: false }),
|
|
2717
|
-
/* @__PURE__ */ React41.createElement(
|
|
2718
|
-
Bar,
|
|
3804
|
+
/* @__PURE__ */ React53.createElement(
|
|
3805
|
+
BarChart,
|
|
2719
3806
|
{
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
className: "Layer__profit-and-loss-
|
|
3807
|
+
margin: { left: 12, right: 12, bottom: 12 },
|
|
3808
|
+
data,
|
|
3809
|
+
onClick,
|
|
3810
|
+
barGap,
|
|
3811
|
+
className: "Layer__profit-and-loss-chart"
|
|
2725
3812
|
},
|
|
2726
|
-
/* @__PURE__ */
|
|
2727
|
-
|
|
3813
|
+
/* @__PURE__ */ React53.createElement(
|
|
3814
|
+
Tooltip2,
|
|
2728
3815
|
{
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
animateFrom,
|
|
2733
|
-
setAnimateFrom
|
|
2734
|
-
}
|
|
2735
|
-
)
|
|
3816
|
+
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
3817
|
+
content: /* @__PURE__ */ React53.createElement(CustomTooltip, null),
|
|
3818
|
+
cursor: /* @__PURE__ */ React53.createElement(CustomizedCursor, null)
|
|
2736
3819
|
}
|
|
2737
3820
|
),
|
|
2738
|
-
|
|
2739
|
-
|
|
3821
|
+
/* @__PURE__ */ React53.createElement(
|
|
3822
|
+
CartesianGrid,
|
|
2740
3823
|
{
|
|
2741
|
-
|
|
2742
|
-
|
|
3824
|
+
vertical: false,
|
|
3825
|
+
stroke: getColor(200)?.hex ?? "#fff",
|
|
3826
|
+
strokeDasharray: "5 5"
|
|
2743
3827
|
}
|
|
2744
|
-
)
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
Bar,
|
|
2748
|
-
{
|
|
2749
|
-
dataKey: "expenses",
|
|
2750
|
-
barSize,
|
|
2751
|
-
isAnimationActive: false,
|
|
2752
|
-
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2753
|
-
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
2754
|
-
},
|
|
2755
|
-
data.map((entry) => /* @__PURE__ */ React41.createElement(
|
|
2756
|
-
Cell,
|
|
3828
|
+
),
|
|
3829
|
+
/* @__PURE__ */ React53.createElement(
|
|
3830
|
+
Legend,
|
|
2757
3831
|
{
|
|
2758
|
-
|
|
2759
|
-
|
|
3832
|
+
verticalAlign: "top",
|
|
3833
|
+
align: "left",
|
|
3834
|
+
wrapperStyle: { top: -24 },
|
|
3835
|
+
payload: [
|
|
3836
|
+
{
|
|
3837
|
+
value: "Income",
|
|
3838
|
+
type: "circle",
|
|
3839
|
+
id: "IncomeLegend"
|
|
3840
|
+
},
|
|
3841
|
+
{
|
|
3842
|
+
value: "Expenses",
|
|
3843
|
+
type: "circle",
|
|
3844
|
+
id: "ExpensesLegend"
|
|
3845
|
+
}
|
|
3846
|
+
]
|
|
2760
3847
|
}
|
|
2761
|
-
)
|
|
3848
|
+
),
|
|
3849
|
+
/* @__PURE__ */ React53.createElement(XAxis, { dataKey: "name", tickLine: false }),
|
|
3850
|
+
/* @__PURE__ */ React53.createElement(
|
|
3851
|
+
Bar,
|
|
3852
|
+
{
|
|
3853
|
+
dataKey: "revenue",
|
|
3854
|
+
barSize,
|
|
3855
|
+
isAnimationActive: false,
|
|
3856
|
+
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
3857
|
+
className: "Layer__profit-and-loss-chart__bar--income"
|
|
3858
|
+
},
|
|
3859
|
+
/* @__PURE__ */ React53.createElement(
|
|
3860
|
+
LabelList,
|
|
3861
|
+
{
|
|
3862
|
+
content: /* @__PURE__ */ React53.createElement(
|
|
3863
|
+
Indicator,
|
|
3864
|
+
{
|
|
3865
|
+
animateFrom,
|
|
3866
|
+
setAnimateFrom
|
|
3867
|
+
}
|
|
3868
|
+
)
|
|
3869
|
+
}
|
|
3870
|
+
),
|
|
3871
|
+
data.map((entry) => /* @__PURE__ */ React53.createElement(
|
|
3872
|
+
Cell,
|
|
3873
|
+
{
|
|
3874
|
+
key: entry.name,
|
|
3875
|
+
className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
|
|
3876
|
+
}
|
|
3877
|
+
))
|
|
3878
|
+
),
|
|
3879
|
+
/* @__PURE__ */ React53.createElement(
|
|
3880
|
+
Bar,
|
|
3881
|
+
{
|
|
3882
|
+
dataKey: "expenses",
|
|
3883
|
+
barSize,
|
|
3884
|
+
isAnimationActive: false,
|
|
3885
|
+
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
3886
|
+
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
3887
|
+
},
|
|
3888
|
+
data.map((entry) => /* @__PURE__ */ React53.createElement(
|
|
3889
|
+
Cell,
|
|
3890
|
+
{
|
|
3891
|
+
key: entry.name,
|
|
3892
|
+
className: entry.selected ? "Layer__profit-and-loss-chart__cell--selected" : ""
|
|
3893
|
+
}
|
|
3894
|
+
))
|
|
3895
|
+
)
|
|
2762
3896
|
)
|
|
2763
|
-
)
|
|
3897
|
+
);
|
|
2764
3898
|
};
|
|
2765
3899
|
|
|
2766
3900
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2767
|
-
import
|
|
2768
|
-
|
|
2769
|
-
// src/icons/ChevronLeft.tsx
|
|
2770
|
-
import * as React42 from "react";
|
|
2771
|
-
var ChevronLeft = ({
|
|
2772
|
-
strokeColor,
|
|
2773
|
-
size,
|
|
2774
|
-
...props
|
|
2775
|
-
}) => /* @__PURE__ */ React42.createElement(
|
|
2776
|
-
"svg",
|
|
2777
|
-
{
|
|
2778
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2779
|
-
width: size || 24,
|
|
2780
|
-
height: size || 24,
|
|
2781
|
-
fill: "none",
|
|
2782
|
-
viewBox: "0 0 24 24",
|
|
2783
|
-
...props
|
|
2784
|
-
},
|
|
2785
|
-
/* @__PURE__ */ React42.createElement(
|
|
2786
|
-
"path",
|
|
2787
|
-
{
|
|
2788
|
-
stroke: strokeColor ?? "#000",
|
|
2789
|
-
strokeLinecap: "round",
|
|
2790
|
-
strokeLinejoin: "round",
|
|
2791
|
-
strokeWidth: 2,
|
|
2792
|
-
d: "m15 18-6-6 6-6"
|
|
2793
|
-
}
|
|
2794
|
-
)
|
|
2795
|
-
);
|
|
2796
|
-
var ChevronLeft_default = ChevronLeft;
|
|
2797
|
-
|
|
2798
|
-
// src/icons/ChevronRight.tsx
|
|
2799
|
-
import * as React43 from "react";
|
|
2800
|
-
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2801
|
-
"svg",
|
|
2802
|
-
{
|
|
2803
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2804
|
-
width: size || 24,
|
|
2805
|
-
height: size || 24,
|
|
2806
|
-
fill: "none",
|
|
2807
|
-
viewBox: "0 0 24 24",
|
|
2808
|
-
...props
|
|
2809
|
-
},
|
|
2810
|
-
/* @__PURE__ */ React43.createElement(
|
|
2811
|
-
"path",
|
|
2812
|
-
{
|
|
2813
|
-
stroke: "#000",
|
|
2814
|
-
strokeLinecap: "round",
|
|
2815
|
-
strokeLinejoin: "round",
|
|
2816
|
-
strokeWidth: 2,
|
|
2817
|
-
d: "m9 18 6-6-6-6"
|
|
2818
|
-
}
|
|
2819
|
-
)
|
|
2820
|
-
);
|
|
2821
|
-
var ChevronRight_default = ChavronRight;
|
|
2822
|
-
|
|
2823
|
-
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
3901
|
+
import React54, { useContext as useContext3 } from "react";
|
|
2824
3902
|
import { add, endOfMonth as endOfMonth3, format as format5, startOfMonth as startOfMonth3 } from "date-fns";
|
|
2825
3903
|
var ProfitAndLossDatePicker = () => {
|
|
2826
3904
|
const { changeDateRange, dateRange } = useContext3(ProfitAndLoss.Context);
|
|
@@ -2835,28 +3913,28 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2835
3913
|
};
|
|
2836
3914
|
const previousMonth = () => change({ months: -1 });
|
|
2837
3915
|
const nextMonth = () => change({ months: 1 });
|
|
2838
|
-
return /* @__PURE__ */
|
|
3916
|
+
return /* @__PURE__ */ React54.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ React54.createElement(
|
|
2839
3917
|
"button",
|
|
2840
3918
|
{
|
|
2841
3919
|
"aria-label": "View Previous Month",
|
|
2842
3920
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2843
3921
|
onClick: previousMonth
|
|
2844
3922
|
},
|
|
2845
|
-
/* @__PURE__ */
|
|
3923
|
+
/* @__PURE__ */ React54.createElement(
|
|
2846
3924
|
ChevronLeft_default,
|
|
2847
3925
|
{
|
|
2848
3926
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
2849
3927
|
size: 18
|
|
2850
3928
|
}
|
|
2851
3929
|
)
|
|
2852
|
-
), /* @__PURE__ */
|
|
3930
|
+
), /* @__PURE__ */ React54.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ React54.createElement(
|
|
2853
3931
|
"button",
|
|
2854
3932
|
{
|
|
2855
3933
|
"aria-label": "View Next Month",
|
|
2856
3934
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2857
3935
|
onClick: nextMonth
|
|
2858
3936
|
},
|
|
2859
|
-
/* @__PURE__ */
|
|
3937
|
+
/* @__PURE__ */ React54.createElement(
|
|
2860
3938
|
ChevronRight_default,
|
|
2861
3939
|
{
|
|
2862
3940
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -2867,46 +3945,74 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2867
3945
|
};
|
|
2868
3946
|
|
|
2869
3947
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
2870
|
-
import
|
|
2871
|
-
|
|
2872
|
-
|
|
3948
|
+
import React56, { useContext as useContext4 } from "react";
|
|
3949
|
+
|
|
3950
|
+
// src/components/SkeletonLoader/SkeletonLoader.tsx
|
|
3951
|
+
import React55 from "react";
|
|
3952
|
+
import classNames19 from "classnames";
|
|
3953
|
+
var SkeletonLoader = ({
|
|
3954
|
+
height,
|
|
3955
|
+
width,
|
|
3956
|
+
className
|
|
3957
|
+
}) => {
|
|
3958
|
+
const baseClassName = classNames19(
|
|
3959
|
+
"Layer__skeleton-loader Layer__anim--skeleton-loading",
|
|
3960
|
+
className
|
|
3961
|
+
);
|
|
3962
|
+
return /* @__PURE__ */ React55.createElement("div", { className: baseClassName, style: { width, height } });
|
|
3963
|
+
};
|
|
3964
|
+
|
|
3965
|
+
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
3966
|
+
var ProfitAndLossSummaries = ({
|
|
3967
|
+
vertical,
|
|
3968
|
+
revenueLabel = "Revenue"
|
|
3969
|
+
}) => {
|
|
3970
|
+
const { data: storedData, isLoading } = useContext4(ProfitAndLoss.Context);
|
|
2873
3971
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
2874
3972
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2875
3973
|
const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2876
3974
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2877
|
-
return /* @__PURE__ */
|
|
2878
|
-
"
|
|
2879
|
-
{
|
|
2880
|
-
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
2881
|
-
},
|
|
2882
|
-
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
2883
|
-
)), /* @__PURE__ */ React45.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ React45.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), /* @__PURE__ */ React45.createElement(
|
|
2884
|
-
"span",
|
|
2885
|
-
{
|
|
2886
|
-
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
2887
|
-
},
|
|
2888
|
-
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
2889
|
-
)), /* @__PURE__ */ React45.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ React45.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), /* @__PURE__ */ React45.createElement(
|
|
2890
|
-
"span",
|
|
3975
|
+
return /* @__PURE__ */ React56.createElement(
|
|
3976
|
+
"div",
|
|
2891
3977
|
{
|
|
2892
|
-
className: `Layer__profit-and-loss-
|
|
3978
|
+
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
2893
3979
|
},
|
|
2894
|
-
|
|
2895
|
-
|
|
3980
|
+
/* @__PURE__ */ React56.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ React56.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ React56.createElement(SkeletonLoader, null) : /* @__PURE__ */ React56.createElement(
|
|
3981
|
+
"span",
|
|
3982
|
+
{
|
|
3983
|
+
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
3984
|
+
},
|
|
3985
|
+
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
3986
|
+
)),
|
|
3987
|
+
/* @__PURE__ */ React56.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ React56.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ React56.createElement(SkeletonLoader, null) : /* @__PURE__ */ React56.createElement(
|
|
3988
|
+
"span",
|
|
3989
|
+
{
|
|
3990
|
+
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
3991
|
+
},
|
|
3992
|
+
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
3993
|
+
)),
|
|
3994
|
+
/* @__PURE__ */ React56.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ React56.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ React56.createElement(SkeletonLoader, null) : /* @__PURE__ */ React56.createElement(
|
|
3995
|
+
"span",
|
|
3996
|
+
{
|
|
3997
|
+
className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
|
|
3998
|
+
},
|
|
3999
|
+
centsToDollars(Math.abs(data.net_profit))
|
|
4000
|
+
))
|
|
4001
|
+
);
|
|
2896
4002
|
};
|
|
2897
4003
|
|
|
2898
4004
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2899
|
-
import
|
|
4005
|
+
import React58, { useContext as useContext5 } from "react";
|
|
2900
4006
|
|
|
2901
4007
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
2902
|
-
import
|
|
4008
|
+
import React57, { useState as useState12 } from "react";
|
|
2903
4009
|
var ProfitAndLossRow = ({
|
|
2904
4010
|
variant,
|
|
2905
4011
|
lineItem,
|
|
2906
4012
|
depth = 0,
|
|
2907
4013
|
maxDepth = 1,
|
|
2908
4014
|
direction = "DEBIT" /* DEBIT */,
|
|
2909
|
-
|
|
4015
|
+
lockExpanded = false
|
|
2910
4016
|
}) => {
|
|
2911
4017
|
if (!lineItem) {
|
|
2912
4018
|
return null;
|
|
@@ -2943,12 +4049,20 @@ var ProfitAndLossRow = ({
|
|
|
2943
4049
|
);
|
|
2944
4050
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
2945
4051
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
2946
|
-
return /* @__PURE__ */
|
|
4052
|
+
return /* @__PURE__ */ React57.createElement(React57.Fragment, null, /* @__PURE__ */ React57.createElement(
|
|
4053
|
+
"div",
|
|
4054
|
+
{
|
|
4055
|
+
className: labelClasses.join(" "),
|
|
4056
|
+
onClick: () => !lockExpanded && toggleExpanded()
|
|
4057
|
+
},
|
|
4058
|
+
!lockExpanded && /* @__PURE__ */ React57.createElement(ChevronDown_default, { size: 16 }),
|
|
4059
|
+
/* @__PURE__ */ React57.createElement(Text, null, display_name)
|
|
4060
|
+
), /* @__PURE__ */ React57.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ React57.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ React57.createElement(
|
|
2947
4061
|
"div",
|
|
2948
4062
|
{
|
|
2949
4063
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
2950
4064
|
},
|
|
2951
|
-
/* @__PURE__ */
|
|
4065
|
+
/* @__PURE__ */ React57.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ React57.createElement(
|
|
2952
4066
|
ProfitAndLossRow,
|
|
2953
4067
|
{
|
|
2954
4068
|
key: line_item.display_name,
|
|
@@ -2957,16 +4071,7 @@ var ProfitAndLossRow = ({
|
|
|
2957
4071
|
maxDepth,
|
|
2958
4072
|
direction
|
|
2959
4073
|
}
|
|
2960
|
-
))
|
|
2961
|
-
ProfitAndLossRow,
|
|
2962
|
-
{
|
|
2963
|
-
key: display_name,
|
|
2964
|
-
lineItem: { value, display_name: `Total of ${display_name}` },
|
|
2965
|
-
variant: "summation",
|
|
2966
|
-
depth: depth + 1,
|
|
2967
|
-
maxDepth
|
|
2968
|
-
}
|
|
2969
|
-
))
|
|
4074
|
+
)))
|
|
2970
4075
|
));
|
|
2971
4076
|
};
|
|
2972
4077
|
|
|
@@ -3019,16 +4124,27 @@ var empty_profit_and_loss_report_default = {
|
|
|
3019
4124
|
};
|
|
3020
4125
|
|
|
3021
4126
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
3022
|
-
var ProfitAndLossTable = () => {
|
|
4127
|
+
var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
3023
4128
|
const { data: actualData, isLoading } = useContext5(ProfitAndLoss.Context);
|
|
3024
4129
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
3025
|
-
|
|
4130
|
+
if (isLoading || actualData === void 0) {
|
|
4131
|
+
return /* @__PURE__ */ React58.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ React58.createElement(Loader2, null));
|
|
4132
|
+
}
|
|
4133
|
+
return /* @__PURE__ */ React58.createElement(React58.Fragment, null, /* @__PURE__ */ React58.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ React58.createElement(
|
|
4134
|
+
ProfitAndLossRow,
|
|
4135
|
+
{
|
|
4136
|
+
lineItem: data.income,
|
|
4137
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4138
|
+
lockExpanded
|
|
4139
|
+
}
|
|
4140
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3026
4141
|
ProfitAndLossRow,
|
|
3027
4142
|
{
|
|
3028
4143
|
lineItem: data.cost_of_goods_sold,
|
|
3029
|
-
direction: "DEBIT" /* DEBIT
|
|
4144
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4145
|
+
lockExpanded
|
|
3030
4146
|
}
|
|
3031
|
-
), /* @__PURE__ */
|
|
4147
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3032
4148
|
ProfitAndLossRow,
|
|
3033
4149
|
{
|
|
3034
4150
|
lineItem: {
|
|
@@ -3036,15 +4152,17 @@ var ProfitAndLossTable = () => {
|
|
|
3036
4152
|
display_name: "Gross Profit"
|
|
3037
4153
|
},
|
|
3038
4154
|
variant: "summation",
|
|
3039
|
-
direction: "CREDIT" /* CREDIT
|
|
4155
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4156
|
+
lockExpanded
|
|
3040
4157
|
}
|
|
3041
|
-
), /* @__PURE__ */
|
|
4158
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3042
4159
|
ProfitAndLossRow,
|
|
3043
4160
|
{
|
|
3044
4161
|
lineItem: data.expenses,
|
|
3045
|
-
direction: "DEBIT" /* DEBIT
|
|
4162
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4163
|
+
lockExpanded
|
|
3046
4164
|
}
|
|
3047
|
-
), /* @__PURE__ */
|
|
4165
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3048
4166
|
ProfitAndLossRow,
|
|
3049
4167
|
{
|
|
3050
4168
|
lineItem: {
|
|
@@ -3052,9 +4170,17 @@ var ProfitAndLossTable = () => {
|
|
|
3052
4170
|
display_name: "Profit Before Taxes"
|
|
3053
4171
|
},
|
|
3054
4172
|
variant: "summation",
|
|
3055
|
-
direction: "CREDIT" /* CREDIT
|
|
4173
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4174
|
+
lockExpanded
|
|
4175
|
+
}
|
|
4176
|
+
), /* @__PURE__ */ React58.createElement(
|
|
4177
|
+
ProfitAndLossRow,
|
|
4178
|
+
{
|
|
4179
|
+
lineItem: data.taxes,
|
|
4180
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4181
|
+
lockExpanded
|
|
3056
4182
|
}
|
|
3057
|
-
), /* @__PURE__ */
|
|
4183
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3058
4184
|
ProfitAndLossRow,
|
|
3059
4185
|
{
|
|
3060
4186
|
lineItem: {
|
|
@@ -3062,19 +4188,22 @@ var ProfitAndLossTable = () => {
|
|
|
3062
4188
|
display_name: "Net Profit"
|
|
3063
4189
|
},
|
|
3064
4190
|
variant: "summation",
|
|
3065
|
-
direction: "CREDIT" /* CREDIT
|
|
4191
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4192
|
+
lockExpanded
|
|
3066
4193
|
}
|
|
3067
|
-
)), /* @__PURE__ */
|
|
4194
|
+
)), /* @__PURE__ */ React58.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ React58.createElement(
|
|
3068
4195
|
ProfitAndLossRow,
|
|
3069
4196
|
{
|
|
3070
4197
|
lineItem: data.other_outflows,
|
|
3071
|
-
direction: "DEBIT" /* DEBIT
|
|
4198
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4199
|
+
lockExpanded
|
|
3072
4200
|
}
|
|
3073
|
-
), /* @__PURE__ */
|
|
4201
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3074
4202
|
ProfitAndLossRow,
|
|
3075
4203
|
{
|
|
3076
4204
|
lineItem: data.personal_expenses,
|
|
3077
|
-
direction: "DEBIT" /* DEBIT
|
|
4205
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4206
|
+
lockExpanded
|
|
3078
4207
|
}
|
|
3079
4208
|
)));
|
|
3080
4209
|
};
|
|
@@ -3084,17 +4213,20 @@ import { endOfMonth as endOfMonth4, startOfMonth as startOfMonth4 } from "date-f
|
|
|
3084
4213
|
var PNLContext = createContext2({
|
|
3085
4214
|
data: void 0,
|
|
3086
4215
|
isLoading: true,
|
|
4216
|
+
isValidating: false,
|
|
3087
4217
|
error: void 0,
|
|
3088
4218
|
dateRange: {
|
|
3089
4219
|
startDate: startOfMonth4(/* @__PURE__ */ new Date()),
|
|
3090
4220
|
endDate: endOfMonth4(/* @__PURE__ */ new Date())
|
|
3091
4221
|
},
|
|
3092
4222
|
changeDateRange: () => {
|
|
4223
|
+
},
|
|
4224
|
+
refetch: () => {
|
|
3093
4225
|
}
|
|
3094
4226
|
});
|
|
3095
|
-
var ProfitAndLoss = ({ children }) => {
|
|
3096
|
-
const contextData = useProfitAndLoss();
|
|
3097
|
-
return /* @__PURE__ */
|
|
4227
|
+
var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
|
|
4228
|
+
const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
|
|
4229
|
+
return /* @__PURE__ */ React59.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ React59.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
|
|
3098
4230
|
};
|
|
3099
4231
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
3100
4232
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -3102,8 +4234,46 @@ ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
|
|
|
3102
4234
|
ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
3103
4235
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
3104
4236
|
|
|
4237
|
+
// src/components/ProfitAndLossView/ProfitAndLossView.tsx
|
|
4238
|
+
import React60, { useContext as useContext6 } from "react";
|
|
4239
|
+
var COMPONENT_NAME2 = "profit-and-loss";
|
|
4240
|
+
var ProfitAndLossView = () => {
|
|
4241
|
+
return /* @__PURE__ */ React60.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ React60.createElement(Header, { className: `Layer__${COMPONENT_NAME2}__header` }, /* @__PURE__ */ React60.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit And Loss")), /* @__PURE__ */ React60.createElement(ProfitAndLoss, null, /* @__PURE__ */ React60.createElement(Components, null)));
|
|
4242
|
+
};
|
|
4243
|
+
var Components = () => {
|
|
4244
|
+
const { error, isLoading, isValidating, refetch } = useContext6(
|
|
4245
|
+
ProfitAndLoss.Context
|
|
4246
|
+
);
|
|
4247
|
+
if (!isLoading && error) {
|
|
4248
|
+
return /* @__PURE__ */ React60.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React60.createElement(
|
|
4249
|
+
DataState,
|
|
4250
|
+
{
|
|
4251
|
+
status: "failed" /* failed */,
|
|
4252
|
+
title: "Something went wrong",
|
|
4253
|
+
description: "We couldn\u2019t load your data.",
|
|
4254
|
+
onRefresh: () => refetch(),
|
|
4255
|
+
isLoading: isValidating
|
|
4256
|
+
}
|
|
4257
|
+
));
|
|
4258
|
+
}
|
|
4259
|
+
return /* @__PURE__ */ React60.createElement(React60.Fragment, null, /* @__PURE__ */ React60.createElement("div", { className: `Layer__${COMPONENT_NAME2}__chart_with_summaries` }, /* @__PURE__ */ React60.createElement(
|
|
4260
|
+
"div",
|
|
4261
|
+
{
|
|
4262
|
+
className: `Layer__${COMPONENT_NAME2}__chart_with_summaries__summary-col`
|
|
4263
|
+
},
|
|
4264
|
+
/* @__PURE__ */ React60.createElement(ProfitAndLoss.DatePicker, null),
|
|
4265
|
+
/* @__PURE__ */ React60.createElement(ProfitAndLoss.Summaries, { vertical: true })
|
|
4266
|
+
), /* @__PURE__ */ React60.createElement(
|
|
4267
|
+
"div",
|
|
4268
|
+
{
|
|
4269
|
+
className: `Layer__${COMPONENT_NAME2}__chart_with_summaries__chart-col`
|
|
4270
|
+
},
|
|
4271
|
+
/* @__PURE__ */ React60.createElement(ProfitAndLoss.Chart, null)
|
|
4272
|
+
)), /* @__PURE__ */ React60.createElement(ProfitAndLoss.Table, null));
|
|
4273
|
+
};
|
|
4274
|
+
|
|
3105
4275
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
3106
|
-
import
|
|
4276
|
+
import React61, { useReducer, useEffect as useEffect5 } from "react";
|
|
3107
4277
|
import { add as add2, isBefore } from "date-fns";
|
|
3108
4278
|
import useSWR5, { SWRConfig } from "swr";
|
|
3109
4279
|
var reducer = (state, action) => {
|
|
@@ -3143,6 +4313,7 @@ var LayerProvider = ({
|
|
|
3143
4313
|
revalidateOnReconnect: false,
|
|
3144
4314
|
revalidateIfStale: false
|
|
3145
4315
|
};
|
|
4316
|
+
const colors = buildColorsPalette(theme);
|
|
3146
4317
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
3147
4318
|
const [state, dispatch] = useReducer(reducer, {
|
|
3148
4319
|
auth: {
|
|
@@ -3154,7 +4325,8 @@ var LayerProvider = ({
|
|
|
3154
4325
|
businessId,
|
|
3155
4326
|
categories: [],
|
|
3156
4327
|
apiUrl,
|
|
3157
|
-
theme
|
|
4328
|
+
theme,
|
|
4329
|
+
colors
|
|
3158
4330
|
});
|
|
3159
4331
|
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR5(
|
|
3160
4332
|
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && isBefore(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
@@ -3166,7 +4338,7 @@ var LayerProvider = ({
|
|
|
3166
4338
|
}),
|
|
3167
4339
|
defaultSWRConfig
|
|
3168
4340
|
) : { data: void 0 };
|
|
3169
|
-
|
|
4341
|
+
useEffect5(() => {
|
|
3170
4342
|
if (businessAccessToken) {
|
|
3171
4343
|
dispatch({
|
|
3172
4344
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -3191,28 +4363,36 @@ var LayerProvider = ({
|
|
|
3191
4363
|
});
|
|
3192
4364
|
}
|
|
3193
4365
|
}, [businessAccessToken, auth?.access_token]);
|
|
3194
|
-
|
|
4366
|
+
useSWR5(
|
|
3195
4367
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
3196
4368
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
4369
|
+
{
|
|
4370
|
+
...defaultSWRConfig,
|
|
4371
|
+
onSuccess: (response) => {
|
|
4372
|
+
if (response?.data?.categories?.length) {
|
|
4373
|
+
dispatch({
|
|
4374
|
+
type: "LayerContext.setCategories" /* setCategories */,
|
|
4375
|
+
payload: { categories: response.data.categories || [] }
|
|
4376
|
+
});
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
3205
4379
|
}
|
|
3206
|
-
|
|
4380
|
+
);
|
|
3207
4381
|
const setTheme = (theme2) => dispatch({
|
|
3208
4382
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
3209
4383
|
payload: { theme: theme2 }
|
|
3210
4384
|
});
|
|
3211
|
-
|
|
4385
|
+
const getColor = (shade) => {
|
|
4386
|
+
if (colors && shade in colors) {
|
|
4387
|
+
return colors[shade];
|
|
4388
|
+
}
|
|
4389
|
+
return;
|
|
4390
|
+
};
|
|
4391
|
+
return /* @__PURE__ */ React61.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React61.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
|
|
3212
4392
|
};
|
|
3213
4393
|
|
|
3214
4394
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3215
|
-
import
|
|
4395
|
+
import React64, { useState as useState14 } from "react";
|
|
3216
4396
|
|
|
3217
4397
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
3218
4398
|
import useSWR6 from "swr";
|
|
@@ -3232,12 +4412,12 @@ var useChartOfAccounts = () => {
|
|
|
3232
4412
|
};
|
|
3233
4413
|
|
|
3234
4414
|
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
3235
|
-
import
|
|
3236
|
-
import
|
|
4415
|
+
import React62, { useMemo as useMemo4, useState as useState13 } from "react";
|
|
4416
|
+
import Select3 from "react-select";
|
|
3237
4417
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
3238
4418
|
var ChartOfAccountsNewForm = () => {
|
|
3239
4419
|
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
3240
|
-
const accountOptions =
|
|
4420
|
+
const accountOptions = useMemo4(
|
|
3241
4421
|
() => flattenAccounts(data?.accounts || []).sort(
|
|
3242
4422
|
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
3243
4423
|
),
|
|
@@ -3260,22 +4440,22 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3260
4440
|
description
|
|
3261
4441
|
});
|
|
3262
4442
|
};
|
|
3263
|
-
return /* @__PURE__ */
|
|
4443
|
+
return /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Name"), /* @__PURE__ */ React62.createElement(
|
|
3264
4444
|
"input",
|
|
3265
4445
|
{
|
|
3266
4446
|
name: "name",
|
|
3267
4447
|
value: name,
|
|
3268
4448
|
onChange: (event) => setName(event.target.value)
|
|
3269
4449
|
}
|
|
3270
|
-
)), /* @__PURE__ */
|
|
4450
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Description"), /* @__PURE__ */ React62.createElement(
|
|
3271
4451
|
"input",
|
|
3272
4452
|
{
|
|
3273
4453
|
name: "description",
|
|
3274
4454
|
value: description,
|
|
3275
4455
|
onChange: (event) => setDescription(event.target.value)
|
|
3276
4456
|
}
|
|
3277
|
-
)), /* @__PURE__ */
|
|
3278
|
-
|
|
4457
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Normality"), /* @__PURE__ */ React62.createElement(
|
|
4458
|
+
Select3,
|
|
3279
4459
|
{
|
|
3280
4460
|
isSearchable: false,
|
|
3281
4461
|
onChange: (value) => value && setNormality(value.value),
|
|
@@ -3284,8 +4464,8 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3284
4464
|
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
3285
4465
|
]
|
|
3286
4466
|
}
|
|
3287
|
-
)), /* @__PURE__ */
|
|
3288
|
-
|
|
4467
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Parent Account"), /* @__PURE__ */ React62.createElement(
|
|
4468
|
+
Select3,
|
|
3289
4469
|
{
|
|
3290
4470
|
isSearchable: true,
|
|
3291
4471
|
value: parentAccount,
|
|
@@ -3294,49 +4474,49 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3294
4474
|
getOptionValue: (a) => a.id,
|
|
3295
4475
|
options: accountOptions
|
|
3296
4476
|
}
|
|
3297
|
-
)), /* @__PURE__ */
|
|
4477
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ React62.createElement("button", { onClick: save }, "Save")));
|
|
3298
4478
|
};
|
|
3299
4479
|
|
|
3300
4480
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
3301
|
-
import
|
|
4481
|
+
import React63 from "react";
|
|
3302
4482
|
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
3303
|
-
const
|
|
4483
|
+
const classNames20 = [
|
|
3304
4484
|
"Layer__chart-of-accounts-row__table-cell",
|
|
3305
4485
|
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
3306
4486
|
];
|
|
3307
|
-
const className =
|
|
4487
|
+
const className = classNames20.filter((id) => id).join(" ");
|
|
3308
4488
|
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
3309
|
-
return /* @__PURE__ */
|
|
4489
|
+
return /* @__PURE__ */ React63.createElement(React63.Fragment, null, /* @__PURE__ */ React63.createElement(
|
|
3310
4490
|
"div",
|
|
3311
4491
|
{
|
|
3312
4492
|
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
3313
4493
|
},
|
|
3314
4494
|
account.name
|
|
3315
|
-
), /* @__PURE__ */
|
|
4495
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3316
4496
|
"div",
|
|
3317
4497
|
{
|
|
3318
4498
|
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
3319
4499
|
},
|
|
3320
4500
|
"Assets"
|
|
3321
|
-
), /* @__PURE__ */
|
|
4501
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3322
4502
|
"div",
|
|
3323
4503
|
{
|
|
3324
4504
|
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
3325
4505
|
},
|
|
3326
4506
|
"Cash"
|
|
3327
|
-
), /* @__PURE__ */
|
|
4507
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3328
4508
|
"div",
|
|
3329
4509
|
{
|
|
3330
4510
|
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
3331
4511
|
},
|
|
3332
4512
|
centsToDollars(Math.abs(account.balance || 0))
|
|
3333
|
-
), /* @__PURE__ */
|
|
4513
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3334
4514
|
"div",
|
|
3335
4515
|
{
|
|
3336
4516
|
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
3337
4517
|
},
|
|
3338
|
-
/* @__PURE__ */
|
|
3339
|
-
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */
|
|
4518
|
+
/* @__PURE__ */ React63.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
|
|
4519
|
+
), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ React63.createElement(
|
|
3340
4520
|
ChartOfAccountsRow,
|
|
3341
4521
|
{
|
|
3342
4522
|
key: subAccount.id,
|
|
@@ -3350,14 +4530,14 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
|
3350
4530
|
var ChartOfAccounts = () => {
|
|
3351
4531
|
const { data, isLoading } = useChartOfAccounts();
|
|
3352
4532
|
const [showingForm, setShowingForm] = useState14(false);
|
|
3353
|
-
return /* @__PURE__ */
|
|
4533
|
+
return /* @__PURE__ */ React64.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ React64.createElement(React64.Fragment, null, /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ React64.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ React64.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ React64.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ React64.createElement(
|
|
3354
4534
|
"button",
|
|
3355
4535
|
{
|
|
3356
4536
|
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
3357
4537
|
onClick: () => setShowingForm(!showingForm)
|
|
3358
4538
|
},
|
|
3359
4539
|
"Edit Accounts"
|
|
3360
|
-
))), showingForm && /* @__PURE__ */
|
|
4540
|
+
))), showingForm && /* @__PURE__ */ React64.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ React64.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ React64.createElement(
|
|
3361
4541
|
ChartOfAccountsRow,
|
|
3362
4542
|
{
|
|
3363
4543
|
key: account.id,
|
|
@@ -3372,6 +4552,7 @@ export {
|
|
|
3372
4552
|
ChartOfAccounts,
|
|
3373
4553
|
Hello,
|
|
3374
4554
|
LayerProvider,
|
|
3375
|
-
ProfitAndLoss
|
|
4555
|
+
ProfitAndLoss,
|
|
4556
|
+
ProfitAndLossView
|
|
3376
4557
|
};
|
|
3377
4558
|
//# sourceMappingURL=index.js.map
|