@layerfi/components 0.1.4 → 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 +2064 -889
- package/dist/esm/index.js.map +4 -4
- package/dist/index.d.ts +425 -51
- package/dist/index.js +2131 -966
- package/dist/index.js.map +4 -4
- package/dist/styles/index.css +908 -120
- package/dist/styles/index.css.map +3 -3
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -254,6 +254,9 @@ var getBankTransactions = get(
|
|
|
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
|
};
|
|
@@ -660,10 +704,179 @@ function hasSuggestions(categorization) {
|
|
|
660
704
|
}
|
|
661
705
|
|
|
662
706
|
// src/components/BankTransactionListItem/BankTransactionListItem.tsx
|
|
663
|
-
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";
|
|
664
877
|
|
|
665
878
|
// src/components/Button/Button.tsx
|
|
666
|
-
import
|
|
879
|
+
import React10, { useRef as useRef3 } from "react";
|
|
667
880
|
import classNames from "classnames";
|
|
668
881
|
var Button = ({
|
|
669
882
|
className,
|
|
@@ -672,6 +885,7 @@ var Button = ({
|
|
|
672
885
|
leftIcon,
|
|
673
886
|
rightIcon,
|
|
674
887
|
iconOnly,
|
|
888
|
+
iconAsPrimary = false,
|
|
675
889
|
...props
|
|
676
890
|
}) => {
|
|
677
891
|
const buttonRef = useRef3(null);
|
|
@@ -687,6 +901,7 @@ var Button = ({
|
|
|
687
901
|
"Layer__btn",
|
|
688
902
|
`Layer__btn--${variant}`,
|
|
689
903
|
iconOnly ? "Layer__btn--icon-only" : "",
|
|
904
|
+
iconAsPrimary && "Layer__btn--with-primary-icon",
|
|
690
905
|
className
|
|
691
906
|
);
|
|
692
907
|
const startAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
@@ -695,7 +910,7 @@ var Button = ({
|
|
|
695
910
|
const stopAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
|
|
696
911
|
(el) => el.endElement()
|
|
697
912
|
);
|
|
698
|
-
return /* @__PURE__ */
|
|
913
|
+
return /* @__PURE__ */ React10.createElement(
|
|
699
914
|
"button",
|
|
700
915
|
{
|
|
701
916
|
...props,
|
|
@@ -704,16 +919,34 @@ var Button = ({
|
|
|
704
919
|
onMouseLeave: stopAnimation,
|
|
705
920
|
ref: buttonRef
|
|
706
921
|
},
|
|
707
|
-
/* @__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
|
+
))
|
|
708
941
|
);
|
|
709
942
|
};
|
|
710
943
|
|
|
711
944
|
// src/components/Button/SubmitButton.tsx
|
|
712
|
-
import
|
|
945
|
+
import React18 from "react";
|
|
713
946
|
|
|
714
947
|
// src/icons/AlertCircle.tsx
|
|
715
|
-
import * as
|
|
716
|
-
var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
948
|
+
import * as React11 from "react";
|
|
949
|
+
var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createElement(
|
|
717
950
|
"svg",
|
|
718
951
|
{
|
|
719
952
|
viewBox: "0 0 18 18",
|
|
@@ -723,7 +956,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
723
956
|
width: size,
|
|
724
957
|
height: size
|
|
725
958
|
},
|
|
726
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ React11.createElement(
|
|
727
960
|
"path",
|
|
728
961
|
{
|
|
729
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",
|
|
@@ -732,7 +965,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
732
965
|
strokeLinejoin: "round"
|
|
733
966
|
}
|
|
734
967
|
),
|
|
735
|
-
/* @__PURE__ */
|
|
968
|
+
/* @__PURE__ */ React11.createElement(
|
|
736
969
|
"path",
|
|
737
970
|
{
|
|
738
971
|
d: "M9 6V9",
|
|
@@ -741,7 +974,7 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
741
974
|
strokeLinejoin: "round"
|
|
742
975
|
}
|
|
743
976
|
),
|
|
744
|
-
/* @__PURE__ */
|
|
977
|
+
/* @__PURE__ */ React11.createElement(
|
|
745
978
|
"path",
|
|
746
979
|
{
|
|
747
980
|
d: "M9 12H9.0075",
|
|
@@ -754,8 +987,8 @@ var AlertCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React9.createElem
|
|
|
754
987
|
var AlertCircle_default = AlertCircle;
|
|
755
988
|
|
|
756
989
|
// src/icons/Check.tsx
|
|
757
|
-
import * as
|
|
758
|
-
var Check = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
990
|
+
import * as React12 from "react";
|
|
991
|
+
var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
759
992
|
"svg",
|
|
760
993
|
{
|
|
761
994
|
viewBox: "0 0 18 18",
|
|
@@ -765,7 +998,7 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
|
|
|
765
998
|
width: size,
|
|
766
999
|
height: size
|
|
767
1000
|
},
|
|
768
|
-
/* @__PURE__ */
|
|
1001
|
+
/* @__PURE__ */ React12.createElement(
|
|
769
1002
|
"path",
|
|
770
1003
|
{
|
|
771
1004
|
d: "M15 4.5L6.75 12.75L3 9",
|
|
@@ -778,8 +1011,8 @@ var Check = ({ size = 18, ...props }) => /* @__PURE__ */ React10.createElement(
|
|
|
778
1011
|
var Check_default = Check;
|
|
779
1012
|
|
|
780
1013
|
// src/icons/CheckCircle.tsx
|
|
781
|
-
import * as
|
|
782
|
-
var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1014
|
+
import * as React13 from "react";
|
|
1015
|
+
var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React13.createElement(
|
|
783
1016
|
"svg",
|
|
784
1017
|
{
|
|
785
1018
|
viewBox: "0 0 18 18",
|
|
@@ -789,7 +1022,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
789
1022
|
width: size,
|
|
790
1023
|
height: size
|
|
791
1024
|
},
|
|
792
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ React13.createElement(
|
|
793
1026
|
"path",
|
|
794
1027
|
{
|
|
795
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",
|
|
@@ -798,7 +1031,7 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
798
1031
|
strokeLinejoin: "round"
|
|
799
1032
|
}
|
|
800
1033
|
),
|
|
801
|
-
/* @__PURE__ */
|
|
1034
|
+
/* @__PURE__ */ React13.createElement(
|
|
802
1035
|
"path",
|
|
803
1036
|
{
|
|
804
1037
|
d: "M16.5 3L9 10.5075L6.75 8.2575",
|
|
@@ -811,8 +1044,8 @@ var CheckCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React11.createEle
|
|
|
811
1044
|
var CheckCircle_default = CheckCircle;
|
|
812
1045
|
|
|
813
1046
|
// src/icons/Loader.tsx
|
|
814
|
-
import * as
|
|
815
|
-
var Loader = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1047
|
+
import * as React14 from "react";
|
|
1048
|
+
var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React14.createElement(
|
|
816
1049
|
"svg",
|
|
817
1050
|
{
|
|
818
1051
|
viewBox: "0 0 18 18",
|
|
@@ -822,7 +1055,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
822
1055
|
width: size,
|
|
823
1056
|
height: size
|
|
824
1057
|
},
|
|
825
|
-
/* @__PURE__ */
|
|
1058
|
+
/* @__PURE__ */ React14.createElement(
|
|
826
1059
|
"path",
|
|
827
1060
|
{
|
|
828
1061
|
d: "M9 1.5V4.5",
|
|
@@ -831,7 +1064,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
831
1064
|
strokeLinejoin: "round"
|
|
832
1065
|
}
|
|
833
1066
|
),
|
|
834
|
-
/* @__PURE__ */
|
|
1067
|
+
/* @__PURE__ */ React14.createElement(
|
|
835
1068
|
"path",
|
|
836
1069
|
{
|
|
837
1070
|
d: "M9 13.5V16.5",
|
|
@@ -840,7 +1073,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
840
1073
|
strokeLinejoin: "round"
|
|
841
1074
|
}
|
|
842
1075
|
),
|
|
843
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ React14.createElement(
|
|
844
1077
|
"path",
|
|
845
1078
|
{
|
|
846
1079
|
d: "M3.6975 3.6975L5.82 5.82",
|
|
@@ -849,7 +1082,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
849
1082
|
strokeLinejoin: "round"
|
|
850
1083
|
}
|
|
851
1084
|
),
|
|
852
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ React14.createElement(
|
|
853
1086
|
"path",
|
|
854
1087
|
{
|
|
855
1088
|
d: "M12.18 12.18L14.3025 14.3025",
|
|
@@ -858,7 +1091,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
858
1091
|
strokeLinejoin: "round"
|
|
859
1092
|
}
|
|
860
1093
|
),
|
|
861
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ React14.createElement(
|
|
862
1095
|
"path",
|
|
863
1096
|
{
|
|
864
1097
|
d: "M1.5 9H4.5",
|
|
@@ -867,7 +1100,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
867
1100
|
strokeLinejoin: "round"
|
|
868
1101
|
}
|
|
869
1102
|
),
|
|
870
|
-
/* @__PURE__ */
|
|
1103
|
+
/* @__PURE__ */ React14.createElement(
|
|
871
1104
|
"path",
|
|
872
1105
|
{
|
|
873
1106
|
d: "M13.5 9H16.5",
|
|
@@ -876,7 +1109,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
876
1109
|
strokeLinejoin: "round"
|
|
877
1110
|
}
|
|
878
1111
|
),
|
|
879
|
-
/* @__PURE__ */
|
|
1112
|
+
/* @__PURE__ */ React14.createElement(
|
|
880
1113
|
"path",
|
|
881
1114
|
{
|
|
882
1115
|
d: "M3.6975 14.3025L5.82 12.18",
|
|
@@ -885,7 +1118,7 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
885
1118
|
strokeLinejoin: "round"
|
|
886
1119
|
}
|
|
887
1120
|
),
|
|
888
|
-
/* @__PURE__ */
|
|
1121
|
+
/* @__PURE__ */ React14.createElement(
|
|
889
1122
|
"path",
|
|
890
1123
|
{
|
|
891
1124
|
d: "M12.18 5.82L14.3025 3.6975",
|
|
@@ -897,15 +1130,57 @@ var Loader = ({ size = 18, ...props }) => /* @__PURE__ */ React12.createElement(
|
|
|
897
1130
|
);
|
|
898
1131
|
var Loader_default = Loader;
|
|
899
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
|
+
|
|
900
1175
|
// src/components/Tooltip/Tooltip.tsx
|
|
901
|
-
import
|
|
1176
|
+
import React17, {
|
|
902
1177
|
forwardRef,
|
|
903
1178
|
isValidElement,
|
|
904
1179
|
cloneElement
|
|
905
1180
|
} from "react";
|
|
906
1181
|
|
|
907
1182
|
// src/components/Tooltip/useTooltip.ts
|
|
908
|
-
import
|
|
1183
|
+
import React16, { useState as useState3 } from "react";
|
|
909
1184
|
import {
|
|
910
1185
|
useFloating,
|
|
911
1186
|
autoUpdate,
|
|
@@ -919,9 +1194,9 @@ import {
|
|
|
919
1194
|
useInteractions,
|
|
920
1195
|
useTransitionStyles
|
|
921
1196
|
} from "@floating-ui/react";
|
|
922
|
-
var TooltipContext =
|
|
1197
|
+
var TooltipContext = React16.createContext(null);
|
|
923
1198
|
var useTooltipContext = () => {
|
|
924
|
-
const context =
|
|
1199
|
+
const context = React16.useContext(TooltipContext);
|
|
925
1200
|
if (context == null) {
|
|
926
1201
|
throw new Error("Tooltip components must be wrapped in <Tooltip />");
|
|
927
1202
|
}
|
|
@@ -967,11 +1242,13 @@ var useTooltip = ({
|
|
|
967
1242
|
const interactions = useInteractions([hover, focus, dismiss, role]);
|
|
968
1243
|
const { isMounted, styles } = useTransitionStyles(context, {
|
|
969
1244
|
initial: {
|
|
970
|
-
opacity: 0
|
|
1245
|
+
opacity: 0,
|
|
1246
|
+
transform: "scale(0.7)",
|
|
1247
|
+
color: "transparent"
|
|
971
1248
|
},
|
|
972
|
-
duration:
|
|
1249
|
+
duration: 300
|
|
973
1250
|
});
|
|
974
|
-
return
|
|
1251
|
+
return React16.useMemo(
|
|
975
1252
|
() => ({
|
|
976
1253
|
open,
|
|
977
1254
|
setOpen,
|
|
@@ -992,7 +1269,7 @@ var Tooltip = ({
|
|
|
992
1269
|
...options
|
|
993
1270
|
}) => {
|
|
994
1271
|
const tooltip = useTooltip(options);
|
|
995
|
-
return /* @__PURE__ */
|
|
1272
|
+
return /* @__PURE__ */ React17.createElement(TooltipContext.Provider, { value: tooltip }, children);
|
|
996
1273
|
};
|
|
997
1274
|
var TooltipTrigger = forwardRef(function TooltipTrigger2({ children, asChild = false, ...props }, propRef) {
|
|
998
1275
|
const context = useTooltipContext();
|
|
@@ -1009,7 +1286,7 @@ var TooltipTrigger = forwardRef(function TooltipTrigger2({ children, asChild = f
|
|
|
1009
1286
|
})
|
|
1010
1287
|
);
|
|
1011
1288
|
}
|
|
1012
|
-
return /* @__PURE__ */
|
|
1289
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1013
1290
|
"span",
|
|
1014
1291
|
{
|
|
1015
1292
|
ref,
|
|
@@ -1025,18 +1302,17 @@ var TooltipContent = forwardRef(function TooltipContent2({ style, className, ...
|
|
|
1025
1302
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
1026
1303
|
if (!context.open || context.disabled)
|
|
1027
1304
|
return null;
|
|
1028
|
-
return /* @__PURE__ */
|
|
1305
|
+
return /* @__PURE__ */ React17.createElement(FloatingPortal, null, /* @__PURE__ */ React17.createElement(
|
|
1029
1306
|
"div",
|
|
1030
1307
|
{
|
|
1031
1308
|
ref,
|
|
1032
1309
|
className,
|
|
1033
1310
|
style: {
|
|
1034
|
-
...context.
|
|
1035
|
-
...context.floatingStyles,
|
|
1036
|
-
...style
|
|
1311
|
+
...context.floatingStyles
|
|
1037
1312
|
},
|
|
1038
1313
|
...context.getFloatingProps(props)
|
|
1039
|
-
}
|
|
1314
|
+
},
|
|
1315
|
+
/* @__PURE__ */ React17.createElement("div", { className: "Layer__tooltip-content ", style: { ...context.styles } }, props.children)
|
|
1040
1316
|
));
|
|
1041
1317
|
});
|
|
1042
1318
|
|
|
@@ -1044,15 +1320,19 @@ var TooltipContent = forwardRef(function TooltipContent2({ style, className, ...
|
|
|
1044
1320
|
import classNames2 from "classnames";
|
|
1045
1321
|
var buildRightIcon = ({
|
|
1046
1322
|
processing,
|
|
1047
|
-
error
|
|
1323
|
+
error,
|
|
1324
|
+
action
|
|
1048
1325
|
}) => {
|
|
1049
1326
|
if (processing) {
|
|
1050
|
-
return /* @__PURE__ */
|
|
1327
|
+
return /* @__PURE__ */ React18.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
|
|
1051
1328
|
}
|
|
1052
1329
|
if (error) {
|
|
1053
|
-
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));
|
|
1331
|
+
}
|
|
1332
|
+
if (action === "update" /* UPDATE */) {
|
|
1333
|
+
return /* @__PURE__ */ React18.createElement("span", { className: "Layer__pt-2" }, /* @__PURE__ */ React18.createElement(Save_default, { size: 14 }));
|
|
1054
1334
|
}
|
|
1055
|
-
return /* @__PURE__ */
|
|
1335
|
+
return /* @__PURE__ */ React18.createElement("span", null, /* @__PURE__ */ React18.createElement(Check_default, { className: "Layer__btn-icon--on-active", size: 14 }), /* @__PURE__ */ React18.createElement(
|
|
1056
1336
|
CheckCircle_default,
|
|
1057
1337
|
{
|
|
1058
1338
|
className: "Layer__btn-icon--on-inactive",
|
|
@@ -1068,346 +1348,436 @@ var SubmitButton = ({
|
|
|
1068
1348
|
disabled,
|
|
1069
1349
|
error,
|
|
1070
1350
|
children,
|
|
1351
|
+
action = "save" /* SAVE */,
|
|
1071
1352
|
...props
|
|
1072
1353
|
}) => {
|
|
1073
1354
|
const baseClassName = classNames2(
|
|
1074
1355
|
active ? "Layer__btn--active" : "",
|
|
1075
1356
|
className
|
|
1076
1357
|
);
|
|
1077
|
-
return /* @__PURE__ */
|
|
1358
|
+
return /* @__PURE__ */ React18.createElement(
|
|
1078
1359
|
Button,
|
|
1079
1360
|
{
|
|
1080
1361
|
...props,
|
|
1081
1362
|
className: baseClassName,
|
|
1082
1363
|
variant: "primary" /* primary */,
|
|
1083
1364
|
disabled: processing || disabled,
|
|
1084
|
-
rightIcon: buildRightIcon({ processing, error })
|
|
1365
|
+
rightIcon: buildRightIcon({ processing, error, action }),
|
|
1366
|
+
iconAsPrimary: true
|
|
1085
1367
|
},
|
|
1086
1368
|
children
|
|
1087
1369
|
);
|
|
1088
1370
|
};
|
|
1089
1371
|
|
|
1090
|
-
// src/components/
|
|
1091
|
-
import
|
|
1092
|
-
import
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
bankTransaction,
|
|
1100
|
-
name,
|
|
1101
|
-
value,
|
|
1102
|
-
onChange,
|
|
1103
|
-
disabled,
|
|
1104
|
-
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
|
|
1105
1381
|
}) => {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
{
|
|
1109
|
-
|
|
1110
|
-
options: bankTransaction.categorization_flow.suggestions
|
|
1111
|
-
}
|
|
1112
|
-
] : [];
|
|
1113
|
-
const categoryOptions = (categories || []).map((category) => {
|
|
1114
|
-
if (category?.subCategories && category?.subCategories?.length > 0) {
|
|
1115
|
-
return {
|
|
1116
|
-
label: category.display_name,
|
|
1117
|
-
options: category.subCategories
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
return {
|
|
1121
|
-
label: category.display_name,
|
|
1122
|
-
options: [category]
|
|
1123
|
-
};
|
|
1124
|
-
}).filter((x) => x);
|
|
1125
|
-
console.log("categoryOptions", categoryOptions);
|
|
1126
|
-
const options = [...suggestedOptions, ...categoryOptions];
|
|
1127
|
-
return /* @__PURE__ */ React16.createElement(
|
|
1128
|
-
Select,
|
|
1129
|
-
{
|
|
1130
|
-
name,
|
|
1131
|
-
className: `Layer__category-menu Layer__select ${className ?? ""}`,
|
|
1132
|
-
classNamePrefix: "Layer__select",
|
|
1133
|
-
options,
|
|
1134
|
-
isSearchable: true,
|
|
1135
|
-
value,
|
|
1136
|
-
onChange: (newValue) => newValue && onChange(newValue),
|
|
1137
|
-
getOptionLabel: (category) => category.display_name,
|
|
1138
|
-
getOptionValue: (category) => category.stable_name || category.category,
|
|
1139
|
-
menuPortalTarget: document.body,
|
|
1140
|
-
styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
|
|
1141
|
-
components: { DropdownIndicator },
|
|
1142
|
-
isDisabled: disabled
|
|
1143
|
-
}
|
|
1382
|
+
const baseClassName = classNames3(
|
|
1383
|
+
"Layer__icon-btn",
|
|
1384
|
+
`Layer__icon-btn--${active ? "active" : "inactive"}`,
|
|
1385
|
+
className
|
|
1144
1386
|
);
|
|
1387
|
+
return /* @__PURE__ */ React19.createElement("button", { ...props, className: baseClassName }, icon);
|
|
1145
1388
|
};
|
|
1146
1389
|
|
|
1147
|
-
// src/components/
|
|
1148
|
-
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
|
+
};
|
|
1149
1401
|
|
|
1150
|
-
// src/
|
|
1151
|
-
import
|
|
1152
|
-
var
|
|
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
|
+
};
|
|
1427
|
+
|
|
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(
|
|
1153
1437
|
"svg",
|
|
1154
1438
|
{
|
|
1439
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1155
1440
|
viewBox: "0 0 18 18",
|
|
1156
1441
|
fill: "none",
|
|
1157
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1158
1442
|
...props,
|
|
1159
1443
|
width: size,
|
|
1160
1444
|
height: size
|
|
1161
1445
|
},
|
|
1162
|
-
/* @__PURE__ */
|
|
1446
|
+
/* @__PURE__ */ React22.createElement(
|
|
1163
1447
|
"path",
|
|
1164
1448
|
{
|
|
1165
|
-
d: "
|
|
1449
|
+
d: "M3 10.5H7.5V15",
|
|
1166
1450
|
stroke: "currentColor",
|
|
1167
1451
|
strokeLinecap: "round",
|
|
1168
1452
|
strokeLinejoin: "round"
|
|
1169
1453
|
}
|
|
1170
1454
|
),
|
|
1171
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ React22.createElement(
|
|
1172
1456
|
"path",
|
|
1173
1457
|
{
|
|
1174
|
-
d: "
|
|
1458
|
+
d: "M15 7.5H10.5V3",
|
|
1175
1459
|
stroke: "currentColor",
|
|
1176
1460
|
strokeLinecap: "round",
|
|
1177
1461
|
strokeLinejoin: "round"
|
|
1178
1462
|
}
|
|
1179
1463
|
),
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
"path",
|
|
1182
|
-
{
|
|
1183
|
-
d: "M6.75 10.5H11.25",
|
|
1184
|
-
stroke: "currentColor",
|
|
1185
|
-
strokeLinecap: "round",
|
|
1186
|
-
strokeLinejoin: "round"
|
|
1187
|
-
}
|
|
1188
|
-
)
|
|
1189
|
-
);
|
|
1190
|
-
var FolderPlus_default = FolderPlus;
|
|
1191
|
-
|
|
1192
|
-
// src/icons/Link.tsx
|
|
1193
|
-
import * as React18 from "react";
|
|
1194
|
-
var Link = ({ size = 18, ...props }) => /* @__PURE__ */ React18.createElement(
|
|
1195
|
-
"svg",
|
|
1196
|
-
{
|
|
1197
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1198
|
-
viewBox: "0 0 18 18",
|
|
1199
|
-
fill: "none",
|
|
1200
|
-
...props,
|
|
1201
|
-
width: size,
|
|
1202
|
-
height: size
|
|
1203
|
-
},
|
|
1204
|
-
/* @__PURE__ */ React18.createElement(
|
|
1464
|
+
/* @__PURE__ */ React22.createElement(
|
|
1205
1465
|
"path",
|
|
1206
1466
|
{
|
|
1207
|
-
d: "
|
|
1467
|
+
d: "M10.5 7.5L15.75 2.25",
|
|
1208
1468
|
stroke: "currentColor",
|
|
1209
1469
|
strokeLinecap: "round",
|
|
1210
1470
|
strokeLinejoin: "round"
|
|
1211
1471
|
}
|
|
1212
1472
|
),
|
|
1213
|
-
/* @__PURE__ */
|
|
1473
|
+
/* @__PURE__ */ React22.createElement(
|
|
1214
1474
|
"path",
|
|
1215
1475
|
{
|
|
1216
|
-
d: "
|
|
1476
|
+
d: "M2.25 15.75L7.5 10.5",
|
|
1217
1477
|
stroke: "currentColor",
|
|
1218
1478
|
strokeLinecap: "round",
|
|
1219
1479
|
strokeLinejoin: "round"
|
|
1220
1480
|
}
|
|
1221
1481
|
)
|
|
1222
1482
|
);
|
|
1223
|
-
var
|
|
1483
|
+
var MinimizeTwo_default = MinimizeTwo;
|
|
1224
1484
|
|
|
1225
|
-
// src/
|
|
1226
|
-
import
|
|
1227
|
-
|
|
1228
|
-
|
|
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 = [
|
|
1229
1554
|
{
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
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 ? [
|
|
1239
1600
|
{
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
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
|
+
})
|
|
1244
1614
|
}
|
|
1245
|
-
|
|
1246
|
-
/*
|
|
1247
|
-
"path",
|
|
1615
|
+
] : [];
|
|
1616
|
+
const suggestedOptions = bankTransaction?.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? [
|
|
1248
1617
|
{
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1618
|
+
label: "Suggestions",
|
|
1619
|
+
options: bankTransaction.categorization_flow.suggestions.map(
|
|
1620
|
+
(x) => mapCategoryToOption(x)
|
|
1621
|
+
)
|
|
1253
1622
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
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,
|
|
1257
1635
|
{
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
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
|
|
1262
1655
|
}
|
|
1263
|
-
)
|
|
1264
|
-
|
|
1265
|
-
var RefreshCcw_default = RefreshCcw;
|
|
1656
|
+
);
|
|
1657
|
+
};
|
|
1266
1658
|
|
|
1267
|
-
// src/
|
|
1268
|
-
import
|
|
1269
|
-
|
|
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(
|
|
1270
1672
|
"svg",
|
|
1271
1673
|
{
|
|
1272
|
-
viewBox: "0 0 11 11",
|
|
1273
|
-
fill: "none",
|
|
1274
1674
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1675
|
+
viewBox: "0 0 18 18",
|
|
1676
|
+
fill: "none",
|
|
1275
1677
|
...props,
|
|
1276
1678
|
width: size,
|
|
1277
1679
|
height: size
|
|
1278
1680
|
},
|
|
1279
|
-
/* @__PURE__ */
|
|
1280
|
-
"path",
|
|
1281
|
-
{
|
|
1282
|
-
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",
|
|
1283
|
-
stroke: "currentColor",
|
|
1284
|
-
strokeLinecap: "round",
|
|
1285
|
-
strokeLinejoin: "round"
|
|
1286
|
-
},
|
|
1287
|
-
/* @__PURE__ */ React20.createElement(
|
|
1288
|
-
"animate",
|
|
1289
|
-
{
|
|
1290
|
-
attributeName: "d",
|
|
1291
|
-
className: "animateOnHover",
|
|
1292
|
-
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",
|
|
1293
|
-
begin: "indefinite",
|
|
1294
|
-
dur: "400ms",
|
|
1295
|
-
repeatCount: "1",
|
|
1296
|
-
fill: "freeze",
|
|
1297
|
-
calcMode: "linear",
|
|
1298
|
-
keyTimes: "0;0.5;1"
|
|
1299
|
-
}
|
|
1300
|
-
)
|
|
1301
|
-
),
|
|
1302
|
-
/* @__PURE__ */ React20.createElement(
|
|
1303
|
-
"path",
|
|
1304
|
-
{
|
|
1305
|
-
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",
|
|
1306
|
-
stroke: "currentColor",
|
|
1307
|
-
strokeLinecap: "round",
|
|
1308
|
-
strokeLinejoin: "round"
|
|
1309
|
-
},
|
|
1310
|
-
/* @__PURE__ */ React20.createElement(
|
|
1311
|
-
"animate",
|
|
1312
|
-
{
|
|
1313
|
-
attributeName: "d",
|
|
1314
|
-
className: "animateOnHover",
|
|
1315
|
-
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",
|
|
1316
|
-
begin: "indefinite",
|
|
1317
|
-
dur: "400ms",
|
|
1318
|
-
repeatCount: "1",
|
|
1319
|
-
fill: "freeze",
|
|
1320
|
-
calcMode: "linear",
|
|
1321
|
-
keyTimes: "0;0.5;1"
|
|
1322
|
-
}
|
|
1323
|
-
)
|
|
1324
|
-
),
|
|
1325
|
-
/* @__PURE__ */ React20.createElement(
|
|
1326
|
-
"path",
|
|
1327
|
-
{
|
|
1328
|
-
d: "M9.16668 1.83325L3.72168 7.27825",
|
|
1329
|
-
stroke: "currentColor",
|
|
1330
|
-
strokeLinecap: "round",
|
|
1331
|
-
strokeLinejoin: "round"
|
|
1332
|
-
},
|
|
1333
|
-
/* @__PURE__ */ React20.createElement(
|
|
1334
|
-
"animate",
|
|
1335
|
-
{
|
|
1336
|
-
attributeName: "d",
|
|
1337
|
-
className: "animateOnHover",
|
|
1338
|
-
values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
|
|
1339
|
-
begin: "indefinite",
|
|
1340
|
-
dur: "400ms",
|
|
1341
|
-
repeatCount: "1",
|
|
1342
|
-
fill: "freeze",
|
|
1343
|
-
calcMode: "linear",
|
|
1344
|
-
keyTimes: "0;0.5;1"
|
|
1345
|
-
}
|
|
1346
|
-
)
|
|
1347
|
-
),
|
|
1348
|
-
/* @__PURE__ */ React20.createElement(
|
|
1681
|
+
/* @__PURE__ */ React24.createElement(
|
|
1349
1682
|
"path",
|
|
1350
1683
|
{
|
|
1351
|
-
d: "
|
|
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",
|
|
1352
1685
|
stroke: "currentColor",
|
|
1353
1686
|
strokeLinecap: "round",
|
|
1354
1687
|
strokeLinejoin: "round"
|
|
1355
|
-
}
|
|
1356
|
-
/* @__PURE__ */ React20.createElement(
|
|
1357
|
-
"animate",
|
|
1358
|
-
{
|
|
1359
|
-
attributeName: "d",
|
|
1360
|
-
className: "animateOnHover",
|
|
1361
|
-
values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
|
|
1362
|
-
begin: "indefinite",
|
|
1363
|
-
dur: "400ms",
|
|
1364
|
-
repeatCount: "1",
|
|
1365
|
-
fill: "freeze",
|
|
1366
|
-
calcMode: "linear",
|
|
1367
|
-
keyTimes: "0;0.5;1"
|
|
1368
|
-
}
|
|
1369
|
-
)
|
|
1688
|
+
}
|
|
1370
1689
|
),
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
"path",
|
|
1373
|
-
{
|
|
1374
|
-
d: "
|
|
1375
|
-
stroke: "currentColor",
|
|
1376
|
-
strokeLinecap: "round",
|
|
1377
|
-
strokeLinejoin: "round"
|
|
1378
|
-
}
|
|
1379
|
-
/* @__PURE__ */ React20.createElement(
|
|
1380
|
-
"animate",
|
|
1381
|
-
{
|
|
1382
|
-
attributeName: "d",
|
|
1383
|
-
className: "animateOnHover",
|
|
1384
|
-
values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
|
|
1385
|
-
begin: "indefinite",
|
|
1386
|
-
dur: "400ms",
|
|
1387
|
-
repeatCount: "1",
|
|
1388
|
-
fill: "freeze",
|
|
1389
|
-
calcMode: "linear",
|
|
1390
|
-
keyTimes: "0;0.5;1"
|
|
1391
|
-
}
|
|
1392
|
-
)
|
|
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
|
+
}
|
|
1393
1698
|
)
|
|
1394
1699
|
);
|
|
1395
|
-
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
|
+
};
|
|
1396
1757
|
|
|
1397
1758
|
// src/components/Input/Input.tsx
|
|
1398
|
-
import
|
|
1399
|
-
import
|
|
1400
|
-
var Input = ({
|
|
1401
|
-
|
|
1402
|
-
|
|
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));
|
|
1403
1773
|
};
|
|
1404
1774
|
|
|
1405
1775
|
// src/components/Input/InputGroup.tsx
|
|
1406
|
-
import
|
|
1776
|
+
import React29 from "react";
|
|
1407
1777
|
|
|
1408
1778
|
// src/components/Typography/Text.tsx
|
|
1409
|
-
import
|
|
1410
|
-
import
|
|
1779
|
+
import React27, { useRef as useRef6, useState as useState4, useEffect } from "react";
|
|
1780
|
+
import classNames8 from "classnames";
|
|
1411
1781
|
var Text = ({
|
|
1412
1782
|
as: Component = "p",
|
|
1413
1783
|
className,
|
|
@@ -1417,12 +1787,12 @@ var Text = ({
|
|
|
1417
1787
|
withTooltip,
|
|
1418
1788
|
...props
|
|
1419
1789
|
}) => {
|
|
1420
|
-
const baseClassName =
|
|
1790
|
+
const baseClassName = classNames8(
|
|
1421
1791
|
`Layer__text Layer__text--${size} Layer__text--${weight}`,
|
|
1422
1792
|
className
|
|
1423
1793
|
);
|
|
1424
1794
|
if (withTooltip) {
|
|
1425
|
-
return /* @__PURE__ */
|
|
1795
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1426
1796
|
TextWithTooltip,
|
|
1427
1797
|
{
|
|
1428
1798
|
as: Component,
|
|
@@ -1435,7 +1805,7 @@ var Text = ({
|
|
|
1435
1805
|
children
|
|
1436
1806
|
);
|
|
1437
1807
|
}
|
|
1438
|
-
return /* @__PURE__ */
|
|
1808
|
+
return /* @__PURE__ */ React27.createElement(Component, { ...props, className: baseClassName }, children);
|
|
1439
1809
|
};
|
|
1440
1810
|
var TextWithTooltip = ({
|
|
1441
1811
|
as: Component = "p",
|
|
@@ -1447,7 +1817,7 @@ var TextWithTooltip = ({
|
|
|
1447
1817
|
tooltipOptions,
|
|
1448
1818
|
...props
|
|
1449
1819
|
}) => {
|
|
1450
|
-
const textElementRef =
|
|
1820
|
+
const textElementRef = useRef6();
|
|
1451
1821
|
const compareSize = () => {
|
|
1452
1822
|
if (textElementRef.current) {
|
|
1453
1823
|
const compare = textElementRef.current.children[0].scrollWidth > textElementRef.current.children[0].clientWidth;
|
|
@@ -1465,48 +1835,48 @@ var TextWithTooltip = ({
|
|
|
1465
1835
|
[]
|
|
1466
1836
|
);
|
|
1467
1837
|
const [hoverStatus, setHover] = useState4(false);
|
|
1468
|
-
const contentClassName =
|
|
1838
|
+
const contentClassName = classNames8(
|
|
1469
1839
|
"Layer__tooltip",
|
|
1470
1840
|
tooltipOptions?.contentClassName
|
|
1471
1841
|
);
|
|
1472
|
-
return /* @__PURE__ */
|
|
1842
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1473
1843
|
Tooltip,
|
|
1474
1844
|
{
|
|
1475
1845
|
disabled: !hoverStatus,
|
|
1476
1846
|
offset: tooltipOptions?.offset,
|
|
1477
1847
|
shift: tooltipOptions?.shift
|
|
1478
1848
|
},
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
/* @__PURE__ */
|
|
1849
|
+
/* @__PURE__ */ React27.createElement(TooltipTrigger, null, /* @__PURE__ */ React27.createElement(Component, { className, ref: textElementRef, ...props }, children)),
|
|
1850
|
+
/* @__PURE__ */ React27.createElement(TooltipContent, { className: contentClassName }, children)
|
|
1481
1851
|
);
|
|
1482
1852
|
};
|
|
1483
1853
|
|
|
1484
1854
|
// src/components/Typography/Heading.tsx
|
|
1485
|
-
import
|
|
1486
|
-
import
|
|
1855
|
+
import React28 from "react";
|
|
1856
|
+
import classNames9 from "classnames";
|
|
1487
1857
|
var Heading = ({
|
|
1488
1858
|
as: Component = "h2",
|
|
1489
1859
|
className,
|
|
1490
1860
|
children,
|
|
1491
1861
|
size = "primary" /* primary */
|
|
1492
1862
|
}) => {
|
|
1493
|
-
const baseClassName =
|
|
1863
|
+
const baseClassName = classNames9(
|
|
1494
1864
|
`Layer__heading Layer__heading--${size}`,
|
|
1495
1865
|
className
|
|
1496
1866
|
);
|
|
1497
|
-
return /* @__PURE__ */
|
|
1867
|
+
return /* @__PURE__ */ React28.createElement(Component, { className: baseClassName }, children);
|
|
1498
1868
|
};
|
|
1499
1869
|
|
|
1500
1870
|
// src/components/Input/InputGroup.tsx
|
|
1501
|
-
import
|
|
1871
|
+
import classNames10 from "classnames";
|
|
1502
1872
|
var InputGroup = ({
|
|
1503
1873
|
label,
|
|
1504
1874
|
name,
|
|
1505
1875
|
className,
|
|
1506
1876
|
children
|
|
1507
1877
|
}) => {
|
|
1508
|
-
const baseClassName =
|
|
1509
|
-
return /* @__PURE__ */
|
|
1878
|
+
const baseClassName = classNames10("Layer__input-group", className);
|
|
1879
|
+
return /* @__PURE__ */ React29.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ React29.createElement(
|
|
1510
1880
|
Text,
|
|
1511
1881
|
{
|
|
1512
1882
|
as: "label",
|
|
@@ -1519,11 +1889,11 @@ var InputGroup = ({
|
|
|
1519
1889
|
};
|
|
1520
1890
|
|
|
1521
1891
|
// src/components/Input/FileInput.tsx
|
|
1522
|
-
import
|
|
1892
|
+
import React31, { useRef as useRef7 } from "react";
|
|
1523
1893
|
|
|
1524
1894
|
// src/icons/UploadCloud.tsx
|
|
1525
|
-
import * as
|
|
1526
|
-
var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
1895
|
+
import * as React30 from "react";
|
|
1896
|
+
var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React30.createElement(
|
|
1527
1897
|
"svg",
|
|
1528
1898
|
{
|
|
1529
1899
|
viewBox: "0 0 18 18",
|
|
@@ -1533,7 +1903,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1533
1903
|
width: size,
|
|
1534
1904
|
height: size
|
|
1535
1905
|
},
|
|
1536
|
-
/* @__PURE__ */
|
|
1906
|
+
/* @__PURE__ */ React30.createElement(
|
|
1537
1907
|
"path",
|
|
1538
1908
|
{
|
|
1539
1909
|
d: "M12 12L9 9L6 12",
|
|
@@ -1542,7 +1912,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1542
1912
|
strokeLinejoin: "round"
|
|
1543
1913
|
}
|
|
1544
1914
|
),
|
|
1545
|
-
/* @__PURE__ */
|
|
1915
|
+
/* @__PURE__ */ React30.createElement(
|
|
1546
1916
|
"path",
|
|
1547
1917
|
{
|
|
1548
1918
|
d: "M9 9V15.75",
|
|
@@ -1551,7 +1921,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1551
1921
|
strokeLinejoin: "round"
|
|
1552
1922
|
}
|
|
1553
1923
|
),
|
|
1554
|
-
/* @__PURE__ */
|
|
1924
|
+
/* @__PURE__ */ React30.createElement(
|
|
1555
1925
|
"path",
|
|
1556
1926
|
{
|
|
1557
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",
|
|
@@ -1560,7 +1930,7 @@ var UploadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React25.createEle
|
|
|
1560
1930
|
strokeLinejoin: "round"
|
|
1561
1931
|
}
|
|
1562
1932
|
),
|
|
1563
|
-
/* @__PURE__ */
|
|
1933
|
+
/* @__PURE__ */ React30.createElement(
|
|
1564
1934
|
"path",
|
|
1565
1935
|
{
|
|
1566
1936
|
d: "M12 12L9 9L6 12",
|
|
@@ -1574,7 +1944,7 @@ var UploadCloud_default = UploadCloud;
|
|
|
1574
1944
|
|
|
1575
1945
|
// src/components/Input/FileInput.tsx
|
|
1576
1946
|
var FileInput = ({ text = "Upload", onUpload }) => {
|
|
1577
|
-
const hiddenFileInput =
|
|
1947
|
+
const hiddenFileInput = useRef7(null);
|
|
1578
1948
|
const onClick = () => {
|
|
1579
1949
|
if (hiddenFileInput.current) {
|
|
1580
1950
|
hiddenFileInput.current.click();
|
|
@@ -1586,15 +1956,15 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
1586
1956
|
onUpload(fileUploaded);
|
|
1587
1957
|
}
|
|
1588
1958
|
};
|
|
1589
|
-
return /* @__PURE__ */
|
|
1959
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
1590
1960
|
Button,
|
|
1591
1961
|
{
|
|
1592
1962
|
onClick,
|
|
1593
1963
|
variant: "secondary" /* secondary */,
|
|
1594
|
-
|
|
1964
|
+
rightIcon: /* @__PURE__ */ React31.createElement(UploadCloud_default, null)
|
|
1595
1965
|
},
|
|
1596
1966
|
text
|
|
1597
|
-
), /* @__PURE__ */
|
|
1967
|
+
), /* @__PURE__ */ React31.createElement(
|
|
1598
1968
|
"input",
|
|
1599
1969
|
{
|
|
1600
1970
|
type: "file",
|
|
@@ -1605,23 +1975,105 @@ var FileInput = ({ text = "Upload", onUpload }) => {
|
|
|
1605
1975
|
));
|
|
1606
1976
|
};
|
|
1607
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
|
+
|
|
1608
2060
|
// src/components/Textarea/Textarea.tsx
|
|
1609
|
-
import
|
|
1610
|
-
import
|
|
2061
|
+
import React34 from "react";
|
|
2062
|
+
import classNames12 from "classnames";
|
|
1611
2063
|
var Textarea = ({
|
|
1612
2064
|
className,
|
|
1613
2065
|
...props
|
|
1614
2066
|
}) => {
|
|
1615
|
-
const baseClassName =
|
|
1616
|
-
return /* @__PURE__ */
|
|
2067
|
+
const baseClassName = classNames12("Layer__textarea", className);
|
|
2068
|
+
return /* @__PURE__ */ React34.createElement("textarea", { ...props, className: baseClassName });
|
|
1617
2069
|
};
|
|
1618
2070
|
|
|
1619
2071
|
// src/components/Toggle/Toggle.tsx
|
|
1620
|
-
import
|
|
2072
|
+
import React35, {
|
|
1621
2073
|
useEffect as useEffect2,
|
|
1622
2074
|
useState as useState5
|
|
1623
2075
|
} from "react";
|
|
1624
|
-
import
|
|
2076
|
+
import classNames13 from "classnames";
|
|
1625
2077
|
var Toggle = ({
|
|
1626
2078
|
name,
|
|
1627
2079
|
options,
|
|
@@ -1638,7 +2090,7 @@ var Toggle = ({
|
|
|
1638
2090
|
}
|
|
1639
2091
|
});
|
|
1640
2092
|
const selectedValue = selected || options[0].value;
|
|
1641
|
-
const baseClassName =
|
|
2093
|
+
const baseClassName = classNames13(
|
|
1642
2094
|
"Layer__toggle",
|
|
1643
2095
|
`Layer__toggle--${size}`,
|
|
1644
2096
|
initialized ? "Layer__toggle--initialized" : ""
|
|
@@ -1663,7 +2115,7 @@ var Toggle = ({
|
|
|
1663
2115
|
width = c.offsetWidth;
|
|
1664
2116
|
}
|
|
1665
2117
|
});
|
|
1666
|
-
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1);
|
|
2118
|
+
shift2 = shift2 + (size === "medium" /* medium */ ? 2 : 1.5);
|
|
1667
2119
|
setThumbPos({ left: shift2, width });
|
|
1668
2120
|
};
|
|
1669
2121
|
useEffect2(() => {
|
|
@@ -1686,7 +2138,7 @@ var Toggle = ({
|
|
|
1686
2138
|
}
|
|
1687
2139
|
return selectedIndex;
|
|
1688
2140
|
};
|
|
1689
|
-
return /* @__PURE__ */
|
|
2141
|
+
return /* @__PURE__ */ React35.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ React35.createElement(
|
|
1690
2142
|
ToggleOption,
|
|
1691
2143
|
{
|
|
1692
2144
|
...option,
|
|
@@ -1698,7 +2150,7 @@ var Toggle = ({
|
|
|
1698
2150
|
disabled: option.disabled ?? false,
|
|
1699
2151
|
index
|
|
1700
2152
|
}
|
|
1701
|
-
)), /* @__PURE__ */
|
|
2153
|
+
)), /* @__PURE__ */ React35.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
|
|
1702
2154
|
};
|
|
1703
2155
|
var ToggleOption = ({
|
|
1704
2156
|
checked,
|
|
@@ -1711,7 +2163,7 @@ var ToggleOption = ({
|
|
|
1711
2163
|
disabled,
|
|
1712
2164
|
index
|
|
1713
2165
|
}) => {
|
|
1714
|
-
return /* @__PURE__ */
|
|
2166
|
+
return /* @__PURE__ */ React35.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React35.createElement(
|
|
1715
2167
|
"input",
|
|
1716
2168
|
{
|
|
1717
2169
|
type: "radio",
|
|
@@ -1722,10 +2174,25 @@ var ToggleOption = ({
|
|
|
1722
2174
|
disabled: disabled ?? false,
|
|
1723
2175
|
"data-idx": index
|
|
1724
2176
|
}
|
|
1725
|
-
), /* @__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)));
|
|
1726
2178
|
};
|
|
1727
2179
|
|
|
1728
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
|
+
};
|
|
1729
2196
|
var ExpandedBankTransactionRow = forwardRef2(
|
|
1730
2197
|
({
|
|
1731
2198
|
bankTransaction,
|
|
@@ -1733,11 +2200,29 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1733
2200
|
asListItem = false,
|
|
1734
2201
|
submitBtnText = "Save"
|
|
1735
2202
|
}, ref) => {
|
|
1736
|
-
const {
|
|
1737
|
-
|
|
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);
|
|
1738
2217
|
const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
|
|
1739
2218
|
const [rowState, updateRowState] = useState6({
|
|
1740
|
-
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
|
+
}) : [
|
|
1741
2226
|
{
|
|
1742
2227
|
amount: bankTransaction.amount,
|
|
1743
2228
|
inputValue: centsToDollars(bankTransaction.amount),
|
|
@@ -1754,22 +2239,32 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1754
2239
|
{ amount: 0, inputValue: "0.00", category: defaultCategory }
|
|
1755
2240
|
]
|
|
1756
2241
|
});
|
|
1757
|
-
const removeSplit = () =>
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
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
|
+
};
|
|
1761
2256
|
const updateAmounts = (rowNumber) => (event) => {
|
|
1762
2257
|
const newAmount = dollarsToCents(event.target.value) || 0;
|
|
1763
2258
|
const newDisplaying = event.target.value;
|
|
1764
|
-
const splitTotal = rowState.splits.
|
|
1765
|
-
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;
|
|
1766
2261
|
return sum + amount;
|
|
1767
2262
|
}, 0);
|
|
1768
2263
|
const remaining = bankTransaction.amount - splitTotal;
|
|
1769
2264
|
rowState.splits[rowNumber].amount = newAmount;
|
|
1770
2265
|
rowState.splits[rowNumber].inputValue = newDisplaying;
|
|
1771
|
-
rowState.splits[
|
|
1772
|
-
rowState.splits[
|
|
2266
|
+
rowState.splits[0].amount = remaining;
|
|
2267
|
+
rowState.splits[0].inputValue = centsToDollars(remaining);
|
|
1773
2268
|
updateRowState({ ...rowState });
|
|
1774
2269
|
};
|
|
1775
2270
|
const onBlur = (event) => {
|
|
@@ -1786,32 +2281,83 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1786
2281
|
rowState.splits[index].category = newValue;
|
|
1787
2282
|
updateRowState({ ...rowState });
|
|
1788
2283
|
};
|
|
1789
|
-
const save = () =>
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
category: {
|
|
1794
|
-
type: "StableName",
|
|
1795
|
-
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);
|
|
1796
2288
|
}
|
|
1797
|
-
|
|
1798
|
-
type: "Split",
|
|
1799
|
-
entries: rowState.splits.map((split) => ({
|
|
1800
|
-
category: split.category?.stable_name || split.category?.category,
|
|
1801
|
-
amount: split.amount
|
|
1802
|
-
}))
|
|
2289
|
+
return;
|
|
1803
2290
|
}
|
|
1804
|
-
|
|
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
|
+
};
|
|
1805
2308
|
useImperativeHandle(ref, () => ({
|
|
1806
2309
|
save
|
|
1807
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
|
+
}, []);
|
|
1808
2351
|
const className = "Layer__expanded-bank-transaction-row";
|
|
1809
|
-
|
|
2352
|
+
const shouldHide = !isOpen && isOver;
|
|
2353
|
+
return /* @__PURE__ */ React36.createElement(
|
|
1810
2354
|
"span",
|
|
1811
2355
|
{
|
|
1812
|
-
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}
|
|
2356
|
+
className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
|
|
2357
|
+
style: { height },
|
|
2358
|
+
onTransitionEnd: handleTransitionEnd
|
|
1813
2359
|
},
|
|
1814
|
-
/* @__PURE__ */
|
|
2360
|
+
shouldHide ? null : /* @__PURE__ */ React36.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ React36.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React36.createElement(
|
|
1815
2361
|
Toggle,
|
|
1816
2362
|
{
|
|
1817
2363
|
name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
|
|
@@ -1819,81 +2365,129 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1819
2365
|
options: [
|
|
1820
2366
|
{
|
|
1821
2367
|
value: "categorize",
|
|
1822
|
-
label: "Categorize"
|
|
1823
|
-
leftIcon: /* @__PURE__ */ React29.createElement(FolderPlus_default, { size: 15 })
|
|
2368
|
+
label: "Categorize"
|
|
1824
2369
|
},
|
|
1825
2370
|
{
|
|
1826
2371
|
value: "match",
|
|
1827
2372
|
label: "Match",
|
|
1828
|
-
disabled:
|
|
1829
|
-
leftIcon: /* @__PURE__ */ React29.createElement(RefreshCcw_default, { size: 15 })
|
|
2373
|
+
disabled: !hasMatch(bankTransaction)
|
|
1830
2374
|
}
|
|
1831
2375
|
],
|
|
1832
2376
|
selected: purpose,
|
|
1833
2377
|
onChange: onChangePurpose
|
|
1834
2378
|
}
|
|
1835
|
-
)), /* @__PURE__ */
|
|
2379
|
+
)), /* @__PURE__ */ React36.createElement(
|
|
1836
2380
|
"div",
|
|
1837
2381
|
{
|
|
1838
2382
|
className: `${className}__content`,
|
|
1839
2383
|
id: `expanded-${bankTransaction.id}`
|
|
1840
2384
|
},
|
|
1841
|
-
/* @__PURE__ */
|
|
2385
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ React36.createElement(
|
|
1842
2386
|
"div",
|
|
1843
2387
|
{
|
|
1844
|
-
className:
|
|
1845
|
-
|
|
2388
|
+
className: classNames14(
|
|
2389
|
+
`${className}__match`,
|
|
2390
|
+
`${className}__content-panel`,
|
|
2391
|
+
purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
|
|
2392
|
+
)
|
|
1846
2393
|
},
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
{
|
|
1850
|
-
type: "text",
|
|
1851
|
-
name: `split-${index}${asListItem ? "-li" : ""}`,
|
|
1852
|
-
disabled: index + 1 === rowState.splits.length,
|
|
1853
|
-
onChange: updateAmounts(index),
|
|
1854
|
-
value: split.inputValue,
|
|
1855
|
-
onBlur,
|
|
1856
|
-
className: `${className}__split-amount${split.amount < 0 ? "--negative" : ""}`
|
|
1857
|
-
}
|
|
1858
|
-
),
|
|
1859
|
-
/* @__PURE__ */ React29.createElement(
|
|
1860
|
-
CategoryMenu,
|
|
2394
|
+
/* @__PURE__ */ React36.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React36.createElement(
|
|
2395
|
+
MatchForm,
|
|
1861
2396
|
{
|
|
2397
|
+
classNamePrefix: className,
|
|
1862
2398
|
bankTransaction,
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
onChange: (value) => changeCategory(index, value),
|
|
1866
|
-
className: "Layer__category-menu--full"
|
|
2399
|
+
selectedMatchId,
|
|
2400
|
+
setSelectedMatchId
|
|
1867
2401
|
}
|
|
1868
|
-
)
|
|
1869
|
-
)
|
|
1870
|
-
|
|
1871
|
-
{
|
|
1872
|
-
onClick: addSplit,
|
|
1873
|
-
leftIcon: /* @__PURE__ */ React29.createElement(Scissors_default, { size: 14 }),
|
|
1874
|
-
variant: "secondary" /* secondary */
|
|
1875
|
-
},
|
|
1876
|
-
"Split"
|
|
1877
|
-
) : /* @__PURE__ */ React29.createElement(
|
|
1878
|
-
Button,
|
|
2402
|
+
))
|
|
2403
|
+
), /* @__PURE__ */ React36.createElement(
|
|
2404
|
+
"div",
|
|
1879
2405
|
{
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
2406
|
+
className: classNames14(
|
|
2407
|
+
`${className}__splits`,
|
|
2408
|
+
`${className}__content-panel`,
|
|
2409
|
+
purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
|
|
2410
|
+
)
|
|
1883
2411
|
},
|
|
1884
|
-
"
|
|
1885
|
-
|
|
1886
|
-
|
|
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(
|
|
1887
2482
|
InputGroup,
|
|
1888
2483
|
{
|
|
1889
2484
|
className: `${className}__description`,
|
|
1890
|
-
name: "description"
|
|
1891
|
-
label: "Description"
|
|
2485
|
+
name: "description"
|
|
1892
2486
|
},
|
|
1893
|
-
/* @__PURE__ */
|
|
2487
|
+
/* @__PURE__ */ React36.createElement(Textarea, { name: "description", placeholder: "Add description" })
|
|
1894
2488
|
),
|
|
1895
|
-
/* @__PURE__ */
|
|
1896
|
-
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(
|
|
1897
2491
|
SubmitButton,
|
|
1898
2492
|
{
|
|
1899
2493
|
onClick: () => {
|
|
@@ -1913,134 +2507,62 @@ var ExpandedBankTransactionRow = forwardRef2(
|
|
|
1913
2507
|
}
|
|
1914
2508
|
);
|
|
1915
2509
|
|
|
1916
|
-
// src/components/
|
|
1917
|
-
import
|
|
1918
|
-
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
|
+
};
|
|
1919
2521
|
|
|
1920
|
-
// src/components/
|
|
1921
|
-
import
|
|
1922
|
-
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";
|
|
1923
2525
|
var isCredit = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
1924
|
-
var
|
|
1925
|
-
|
|
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,
|
|
1926
2537
|
bankTransaction,
|
|
1927
|
-
isOpen,
|
|
1928
|
-
toggleOpen,
|
|
1929
2538
|
editable
|
|
1930
2539
|
}) => {
|
|
1931
|
-
const expandedRowRef =
|
|
2540
|
+
const expandedRowRef = useRef10(null);
|
|
1932
2541
|
const [removed, setRemoved] = useState7(false);
|
|
1933
|
-
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
2542
|
+
const { categorize: categorizeBankTransaction2, match: matchBankTransaction2 } = useBankTransactions();
|
|
1934
2543
|
const [selectedCategory, setSelectedCategory] = useState7(
|
|
1935
|
-
|
|
2544
|
+
getDefaultSelectedCategory(bankTransaction)
|
|
1936
2545
|
);
|
|
2546
|
+
const [open, setOpen] = useState7(false);
|
|
2547
|
+
const toggleOpen = () => setOpen(!open);
|
|
1937
2548
|
const save = () => {
|
|
1938
|
-
if (
|
|
2549
|
+
if (open && expandedRowRef?.current) {
|
|
1939
2550
|
expandedRowRef?.current?.save();
|
|
1940
|
-
|
|
2551
|
+
setOpen(false);
|
|
1941
2552
|
return;
|
|
1942
2553
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
category: {
|
|
1946
|
-
type: "StableName",
|
|
1947
|
-
stable_name: selectedCategory?.stable_name || selectedCategory?.category || ""
|
|
1948
|
-
}
|
|
1949
|
-
});
|
|
1950
|
-
};
|
|
1951
|
-
if (removed) {
|
|
1952
|
-
return null;
|
|
1953
|
-
}
|
|
1954
|
-
const className = "Layer__bank-transaction-list-item";
|
|
1955
|
-
const openClassName = isOpen ? `${className}--expanded` : "";
|
|
1956
|
-
const rowClassName = classNames9(
|
|
1957
|
-
className,
|
|
1958
|
-
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
1959
|
-
isOpen ? openClassName : ""
|
|
1960
|
-
);
|
|
1961
|
-
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(
|
|
1962
|
-
"span",
|
|
1963
|
-
{
|
|
1964
|
-
className: `${className}__amount-${isCredit(bankTransaction) ? "credit" : "debit"}`
|
|
1965
|
-
},
|
|
1966
|
-
isCredit(bankTransaction) ? "+$" : " $",
|
|
1967
|
-
centsToDollars(bankTransaction.amount)
|
|
1968
|
-
), /* @__PURE__ */ React31.createElement(
|
|
1969
|
-
"div",
|
|
1970
|
-
{
|
|
1971
|
-
onClick: () => toggleOpen(bankTransaction.id),
|
|
1972
|
-
className: "Layer__bank-transaction-row__expand-button"
|
|
1973
|
-
},
|
|
1974
|
-
/* @__PURE__ */ React31.createElement(
|
|
1975
|
-
ChevronDown_default,
|
|
1976
|
-
{
|
|
1977
|
-
className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
1978
|
-
}
|
|
1979
|
-
)
|
|
1980
|
-
)), /* @__PURE__ */ React31.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React31.createElement(
|
|
1981
|
-
ExpandedBankTransactionRow,
|
|
1982
|
-
{
|
|
1983
|
-
ref: expandedRowRef,
|
|
1984
|
-
bankTransaction,
|
|
1985
|
-
close: () => toggleOpen(bankTransaction.id),
|
|
1986
|
-
isOpen,
|
|
1987
|
-
asListItem: true,
|
|
1988
|
-
submitBtnText: editable ? "Approve" : "Save"
|
|
1989
|
-
}
|
|
1990
|
-
)), /* @__PURE__ */ React31.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ React31.createElement(
|
|
1991
|
-
CategoryMenu,
|
|
1992
|
-
{
|
|
1993
|
-
bankTransaction,
|
|
1994
|
-
name: `category-${bankTransaction.id}`,
|
|
1995
|
-
value: selectedCategory,
|
|
1996
|
-
onChange: setSelectedCategory,
|
|
1997
|
-
disabled: bankTransaction.processing
|
|
1998
|
-
}
|
|
1999
|
-
) : null, !editable ? /* @__PURE__ */ React31.createElement(Pill, null, bankTransaction?.category?.display_name) : null, editable && /* @__PURE__ */ React31.createElement(
|
|
2000
|
-
SubmitButton,
|
|
2001
|
-
{
|
|
2002
|
-
onClick: () => {
|
|
2003
|
-
if (!bankTransaction.processing) {
|
|
2004
|
-
save();
|
|
2005
|
-
}
|
|
2006
|
-
},
|
|
2007
|
-
className: "Layer__bank-transaction__submit-btn",
|
|
2008
|
-
processing: bankTransaction.processing,
|
|
2009
|
-
error: bankTransaction.error,
|
|
2010
|
-
iconOnly: true
|
|
2554
|
+
if (!selectedCategory) {
|
|
2555
|
+
return;
|
|
2011
2556
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
// src/components/BankTransactionRow/BankTransactionRow.tsx
|
|
2016
|
-
import React32, { useRef as useRef8, useState as useState8 } from "react";
|
|
2017
|
-
import classNames10 from "classnames";
|
|
2018
|
-
import { parseISO as parseISO3, format as formatTime2 } from "date-fns";
|
|
2019
|
-
var isCredit2 = ({ direction }) => direction === "CREDIT" /* CREDIT */;
|
|
2020
|
-
var BankTransactionRow = ({
|
|
2021
|
-
dateFormat: dateFormat2,
|
|
2022
|
-
bankTransaction,
|
|
2023
|
-
isOpen,
|
|
2024
|
-
toggleOpen,
|
|
2025
|
-
editable
|
|
2026
|
-
}) => {
|
|
2027
|
-
const expandedRowRef = useRef8(null);
|
|
2028
|
-
const [removed, setRemoved] = useState8(false);
|
|
2029
|
-
const { categorize: categorizeBankTransaction2 } = useBankTransactions();
|
|
2030
|
-
const [selectedCategory, setSelectedCategory] = useState8(
|
|
2031
|
-
hasSuggestions(bankTransaction.categorization_flow) ? bankTransaction.categorization_flow.suggestions[0] : void 0
|
|
2032
|
-
);
|
|
2033
|
-
const save = () => {
|
|
2034
|
-
if (isOpen && expandedRowRef?.current) {
|
|
2035
|
-
expandedRowRef?.current?.save();
|
|
2036
|
-
toggleOpen(bankTransaction.id);
|
|
2557
|
+
if (selectedCategory.type === "match") {
|
|
2558
|
+
matchBankTransaction2(bankTransaction.id, selectedCategory.payload.id);
|
|
2037
2559
|
return;
|
|
2038
2560
|
}
|
|
2039
2561
|
categorizeBankTransaction2(bankTransaction.id, {
|
|
2040
2562
|
type: "Category",
|
|
2041
2563
|
category: {
|
|
2042
2564
|
type: "StableName",
|
|
2043
|
-
stable_name: selectedCategory?.stable_name ||
|
|
2565
|
+
stable_name: selectedCategory?.payload.stable_name || ""
|
|
2044
2566
|
}
|
|
2045
2567
|
});
|
|
2046
2568
|
};
|
|
@@ -2048,13 +2570,13 @@ var BankTransactionRow = ({
|
|
|
2048
2570
|
return null;
|
|
2049
2571
|
}
|
|
2050
2572
|
const className = "Layer__bank-transaction-row";
|
|
2051
|
-
const openClassName =
|
|
2052
|
-
const rowClassName =
|
|
2573
|
+
const openClassName = open ? `${className}--expanded` : "";
|
|
2574
|
+
const rowClassName = classNames15(
|
|
2053
2575
|
className,
|
|
2054
2576
|
bankTransaction.recently_categorized ? "Layer__bank-transaction-row--removing" : "",
|
|
2055
|
-
|
|
2577
|
+
open ? openClassName : ""
|
|
2056
2578
|
);
|
|
2057
|
-
return /* @__PURE__ */
|
|
2579
|
+
return /* @__PURE__ */ React38.createElement(React38.Fragment, null, /* @__PURE__ */ React38.createElement(
|
|
2058
2580
|
"tr",
|
|
2059
2581
|
{
|
|
2060
2582
|
className: rowClassName,
|
|
@@ -2064,8 +2586,8 @@ var BankTransactionRow = ({
|
|
|
2064
2586
|
}
|
|
2065
2587
|
}
|
|
2066
2588
|
},
|
|
2067
|
-
/* @__PURE__ */
|
|
2068
|
-
/* @__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(
|
|
2069
2591
|
Text,
|
|
2070
2592
|
{
|
|
2071
2593
|
as: "span",
|
|
@@ -2077,7 +2599,7 @@ var BankTransactionRow = ({
|
|
|
2077
2599
|
},
|
|
2078
2600
|
bankTransaction.counterparty_name ?? bankTransaction.description
|
|
2079
2601
|
))),
|
|
2080
|
-
/* @__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(
|
|
2081
2603
|
Text,
|
|
2082
2604
|
{
|
|
2083
2605
|
as: "span",
|
|
@@ -2086,30 +2608,30 @@ var BankTransactionRow = ({
|
|
|
2086
2608
|
},
|
|
2087
2609
|
bankTransaction.account_name ?? ""
|
|
2088
2610
|
))),
|
|
2089
|
-
/* @__PURE__ */
|
|
2611
|
+
/* @__PURE__ */ React38.createElement(
|
|
2090
2612
|
"td",
|
|
2091
2613
|
{
|
|
2092
|
-
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"}`
|
|
2093
2615
|
},
|
|
2094
|
-
/* @__PURE__ */
|
|
2616
|
+
/* @__PURE__ */ React38.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
|
|
2095
2617
|
),
|
|
2096
|
-
/* @__PURE__ */
|
|
2618
|
+
/* @__PURE__ */ React38.createElement(
|
|
2097
2619
|
"td",
|
|
2098
2620
|
{
|
|
2099
|
-
className:
|
|
2621
|
+
className: classNames15(
|
|
2100
2622
|
"Layer__table-cell",
|
|
2101
2623
|
"Layer__table-cell__category-col",
|
|
2102
2624
|
`${className}__actions-cell`,
|
|
2103
|
-
`${className}__actions-cell--${
|
|
2625
|
+
`${className}__actions-cell--${open ? "open" : "close"}`
|
|
2104
2626
|
)
|
|
2105
2627
|
},
|
|
2106
|
-
/* @__PURE__ */
|
|
2628
|
+
/* @__PURE__ */ React38.createElement(
|
|
2107
2629
|
"span",
|
|
2108
2630
|
{
|
|
2109
2631
|
className: `${className}__actions-container Layer__table-cell-content`
|
|
2110
2632
|
},
|
|
2111
|
-
editable && !
|
|
2112
|
-
|
|
2633
|
+
editable && !open ? /* @__PURE__ */ React38.createElement(
|
|
2634
|
+
CategorySelect,
|
|
2113
2635
|
{
|
|
2114
2636
|
bankTransaction,
|
|
2115
2637
|
name: `category-${bankTransaction.id}`,
|
|
@@ -2118,8 +2640,31 @@ var BankTransactionRow = ({
|
|
|
2118
2640
|
disabled: bankTransaction.processing
|
|
2119
2641
|
}
|
|
2120
2642
|
) : null,
|
|
2121
|
-
!editable && !
|
|
2122
|
-
|
|
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(
|
|
2123
2668
|
SubmitButton,
|
|
2124
2669
|
{
|
|
2125
2670
|
onClick: () => {
|
|
@@ -2130,38 +2675,198 @@ var BankTransactionRow = ({
|
|
|
2130
2675
|
className: "Layer__bank-transaction__submit-btn",
|
|
2131
2676
|
processing: bankTransaction.processing,
|
|
2132
2677
|
error: bankTransaction.error,
|
|
2133
|
-
active:
|
|
2678
|
+
active: open,
|
|
2679
|
+
action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
|
|
2134
2680
|
},
|
|
2135
|
-
editable ? "Approve" : "
|
|
2681
|
+
editable ? "Approve" : "Update"
|
|
2136
2682
|
) : null,
|
|
2137
|
-
/* @__PURE__ */
|
|
2138
|
-
|
|
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,
|
|
2139
2729
|
{
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2143
|
-
/* @__PURE__ */ React32.createElement(
|
|
2144
|
-
ChevronDown_default,
|
|
2145
|
-
{
|
|
2146
|
-
className: `Layer__chevron ${isOpen ? "Layer__chevron__up" : "Layer__chevron__down"}`
|
|
2147
|
-
}
|
|
2148
|
-
)
|
|
2730
|
+
classNamePrefix: "Layer__bank-transaction-list-item",
|
|
2731
|
+
category: bankTransaction.category
|
|
2732
|
+
}
|
|
2149
2733
|
)
|
|
2150
|
-
|
|
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
|
+
}
|
|
2151
2807
|
)
|
|
2152
|
-
), /* @__PURE__ */
|
|
2808
|
+
)), /* @__PURE__ */ React40.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React40.createElement(
|
|
2153
2809
|
ExpandedBankTransactionRow,
|
|
2154
2810
|
{
|
|
2155
2811
|
ref: expandedRowRef,
|
|
2156
2812
|
bankTransaction,
|
|
2157
|
-
close:
|
|
2158
|
-
isOpen
|
|
2813
|
+
close: toggleOpen,
|
|
2814
|
+
isOpen: open,
|
|
2815
|
+
asListItem: true,
|
|
2816
|
+
submitBtnText: editable ? "Approve" : "Save"
|
|
2159
2817
|
}
|
|
2160
|
-
))
|
|
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
|
+
)));
|
|
2161
2841
|
};
|
|
2162
2842
|
|
|
2163
2843
|
// src/components/Container/Container.tsx
|
|
2164
|
-
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
|
+
};
|
|
2165
2870
|
|
|
2166
2871
|
// src/utils/colors.ts
|
|
2167
2872
|
var parseStylesFromThemeConfig = (theme) => {
|
|
@@ -2217,6 +2922,47 @@ var parseColorFromTheme = (colorName, color) => {
|
|
|
2217
2922
|
return {};
|
|
2218
2923
|
}
|
|
2219
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
|
+
};
|
|
2220
2966
|
var rgbToHsl = (color) => {
|
|
2221
2967
|
let r = Number(color.r);
|
|
2222
2968
|
let g = Number(color.g);
|
|
@@ -2247,42 +2993,113 @@ var hexToRgb = (hex) => {
|
|
|
2247
2993
|
b: values[2]
|
|
2248
2994
|
};
|
|
2249
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
|
+
};
|
|
2250
3070
|
|
|
2251
3071
|
// src/components/Container/Container.tsx
|
|
2252
|
-
import
|
|
2253
|
-
var Container = (
|
|
2254
|
-
name,
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
className
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
const styles = parseStylesFromThemeConfig(theme);
|
|
2267
|
-
return /* @__PURE__ */ React33.createElement("div", { className: baseClassName, style: { ...styles } }, children);
|
|
2268
|
-
};
|
|
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
|
+
);
|
|
2269
3086
|
|
|
2270
3087
|
// src/components/Container/Header.tsx
|
|
2271
|
-
import
|
|
2272
|
-
import
|
|
2273
|
-
var Header =
|
|
3088
|
+
import React42, { forwardRef as forwardRef4 } from "react";
|
|
3089
|
+
import classNames18 from "classnames";
|
|
3090
|
+
var Header = forwardRef4(
|
|
2274
3091
|
({ className, children, style }, ref) => {
|
|
2275
|
-
const baseClassName =
|
|
2276
|
-
return /* @__PURE__ */
|
|
3092
|
+
const baseClassName = classNames18("Layer__component-header", className);
|
|
3093
|
+
return /* @__PURE__ */ React42.createElement("header", { ref, className: baseClassName, style }, children);
|
|
2277
3094
|
}
|
|
2278
3095
|
);
|
|
2279
3096
|
|
|
2280
3097
|
// src/components/DataState/DataState.tsx
|
|
2281
|
-
import
|
|
3098
|
+
import React45 from "react";
|
|
2282
3099
|
|
|
2283
3100
|
// src/icons/AlertOctagon.tsx
|
|
2284
|
-
import * as
|
|
2285
|
-
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */
|
|
3101
|
+
import * as React43 from "react";
|
|
3102
|
+
var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2286
3103
|
"svg",
|
|
2287
3104
|
{
|
|
2288
3105
|
viewBox: "0 0 18 18",
|
|
@@ -2292,7 +3109,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
|
|
|
2292
3109
|
width: size,
|
|
2293
3110
|
height: size
|
|
2294
3111
|
},
|
|
2295
|
-
/* @__PURE__ */
|
|
3112
|
+
/* @__PURE__ */ React43.createElement(
|
|
2296
3113
|
"path",
|
|
2297
3114
|
{
|
|
2298
3115
|
d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
|
|
@@ -2301,77 +3118,290 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createEl
|
|
|
2301
3118
|
strokeLinejoin: "round"
|
|
2302
3119
|
}
|
|
2303
3120
|
),
|
|
2304
|
-
/* @__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(
|
|
2305
3296
|
"path",
|
|
2306
3297
|
{
|
|
2307
|
-
d: "
|
|
3298
|
+
d: "M11.25 13.5L6.75 9L11.25 4.5",
|
|
2308
3299
|
stroke: "currentColor",
|
|
2309
3300
|
strokeLinecap: "round",
|
|
2310
3301
|
strokeLinejoin: "round"
|
|
2311
3302
|
}
|
|
2312
|
-
)
|
|
2313
|
-
|
|
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(
|
|
2314
3320
|
"path",
|
|
2315
3321
|
{
|
|
2316
|
-
d: "
|
|
3322
|
+
d: "M6.75 13.5L11.25 9L6.75 4.5",
|
|
2317
3323
|
stroke: "currentColor",
|
|
2318
3324
|
strokeLinecap: "round",
|
|
2319
3325
|
strokeLinejoin: "round"
|
|
2320
3326
|
}
|
|
2321
3327
|
)
|
|
2322
3328
|
);
|
|
2323
|
-
var
|
|
3329
|
+
var ChevronRight_default = ChavronRight;
|
|
2324
3330
|
|
|
2325
|
-
// src/components/
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
};
|
|
2334
|
-
var DataState = ({
|
|
2335
|
-
status,
|
|
2336
|
-
title,
|
|
2337
|
-
description,
|
|
2338
|
-
onRefresh,
|
|
2339
|
-
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
|
|
2340
3339
|
}) => {
|
|
2341
|
-
|
|
2342
|
-
|
|
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",
|
|
2343
3355
|
{
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
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)
|
|
2348
3363
|
},
|
|
2349
|
-
|
|
2350
|
-
),
|
|
2351
|
-
|
|
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",
|
|
2352
3385
|
{
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
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)
|
|
2357
3393
|
},
|
|
2358
|
-
|
|
2359
|
-
))
|
|
2360
|
-
};
|
|
2361
|
-
|
|
2362
|
-
// src/components/Loader/Loader.tsx
|
|
2363
|
-
import React37 from "react";
|
|
2364
|
-
var Loader2 = ({ children }) => {
|
|
2365
|
-
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
|
+
));
|
|
2366
3396
|
};
|
|
2367
3397
|
|
|
2368
3398
|
// src/components/BankTransactions/BankTransactions.tsx
|
|
2369
3399
|
var COMPONENT_NAME = "bank-transactions";
|
|
2370
|
-
var dateFormat = "LLL d, yyyy";
|
|
2371
3400
|
var CategorizedCategories = [
|
|
2372
3401
|
"CATEGORIZED" /* CATEGORIZED */,
|
|
2373
3402
|
"JOURNALING" /* JOURNALING */,
|
|
2374
|
-
"SPLIT" /* SPLIT
|
|
3403
|
+
"SPLIT" /* SPLIT */,
|
|
3404
|
+
"MATCHED" /* MATCHED */
|
|
2375
3405
|
];
|
|
2376
3406
|
var ReviewCategories = [
|
|
2377
3407
|
"READY_FOR_INPUT" /* READY_FOR_INPUT */,
|
|
@@ -2385,18 +3415,27 @@ var filterVisibility = (display) => (bankTransaction) => {
|
|
|
2385
3415
|
return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
|
|
2386
3416
|
};
|
|
2387
3417
|
var BankTransactions = ({
|
|
2388
|
-
asWidget = false
|
|
3418
|
+
asWidget = false,
|
|
3419
|
+
pageSize = 15
|
|
2389
3420
|
}) => {
|
|
2390
3421
|
const [display, setDisplay] = useState9("review" /* review */);
|
|
3422
|
+
const [currentPage, setCurrentPage] = useState9(1);
|
|
2391
3423
|
const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
|
|
2392
|
-
const
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
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
|
+
};
|
|
2398
3436
|
const [shiftStickyHeader, setShiftStickyHeader] = useState9(0);
|
|
2399
|
-
const
|
|
3437
|
+
const [listView, setListView] = useState9(false);
|
|
3438
|
+
const containerRef = useElementSize((_el, _en, size) => {
|
|
2400
3439
|
if (size?.height && size?.height >= 90) {
|
|
2401
3440
|
const newShift = -Math.floor(size.height / 2) + 6;
|
|
2402
3441
|
if (newShift !== shiftStickyHeader) {
|
|
@@ -2405,17 +3444,21 @@ var BankTransactions = ({
|
|
|
2405
3444
|
} else if (size?.height > 0 && shiftStickyHeader !== 0) {
|
|
2406
3445
|
setShiftStickyHeader(0);
|
|
2407
3446
|
}
|
|
3447
|
+
if (size.width > 700 && listView) {
|
|
3448
|
+
setListView(false);
|
|
3449
|
+
} else if (size.width <= 700 && !listView) {
|
|
3450
|
+
setListView(true);
|
|
3451
|
+
}
|
|
2408
3452
|
});
|
|
2409
3453
|
const editable = display === "review" /* review */;
|
|
2410
|
-
return /* @__PURE__ */
|
|
3454
|
+
return /* @__PURE__ */ React50.createElement(Container, { name: COMPONENT_NAME, asWidget, ref: containerRef }, /* @__PURE__ */ React50.createElement(
|
|
2411
3455
|
Header,
|
|
2412
3456
|
{
|
|
2413
|
-
ref: headerRef,
|
|
2414
3457
|
className: "Layer__bank-transactions__header",
|
|
2415
3458
|
style: { top: shiftStickyHeader }
|
|
2416
3459
|
},
|
|
2417
|
-
/* @__PURE__ */
|
|
2418
|
-
/* @__PURE__ */
|
|
3460
|
+
/* @__PURE__ */ React50.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
|
|
3461
|
+
/* @__PURE__ */ React50.createElement(
|
|
2419
3462
|
Toggle,
|
|
2420
3463
|
{
|
|
2421
3464
|
name: "bank-transaction-display",
|
|
@@ -2427,35 +3470,31 @@ var BankTransactions = ({
|
|
|
2427
3470
|
onChange: onCategorizationDisplayChange
|
|
2428
3471
|
}
|
|
2429
3472
|
)
|
|
2430
|
-
), /* @__PURE__ */
|
|
3473
|
+
), !listView && /* @__PURE__ */ React50.createElement(
|
|
2431
3474
|
"table",
|
|
2432
3475
|
{
|
|
2433
3476
|
width: "100%",
|
|
2434
|
-
className: "Layer__table Layer__bank-transactions__table"
|
|
3477
|
+
className: "Layer__table Layer__bank-transactions__table with-cell-separators"
|
|
2435
3478
|
},
|
|
2436
|
-
/* @__PURE__ */
|
|
2437
|
-
/* @__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(
|
|
2438
3481
|
BankTransactionRow,
|
|
2439
3482
|
{
|
|
2440
3483
|
key: bankTransaction.id,
|
|
2441
|
-
dateFormat,
|
|
3484
|
+
dateFormat: DATE_FORMAT,
|
|
2442
3485
|
bankTransaction,
|
|
2443
|
-
isOpen: openRows[bankTransaction.id],
|
|
2444
|
-
toggleOpen,
|
|
2445
3486
|
editable
|
|
2446
3487
|
}
|
|
2447
3488
|
)))
|
|
2448
|
-
), 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(
|
|
2449
3490
|
BankTransactionListItem,
|
|
2450
3491
|
{
|
|
2451
3492
|
key: bankTransaction.id,
|
|
2452
|
-
dateFormat,
|
|
3493
|
+
dateFormat: DATE_FORMAT,
|
|
2453
3494
|
bankTransaction,
|
|
2454
|
-
isOpen: openRows[bankTransaction.id],
|
|
2455
|
-
toggleOpen,
|
|
2456
3495
|
editable
|
|
2457
3496
|
}
|
|
2458
|
-
))), !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(
|
|
2459
3498
|
DataState,
|
|
2460
3499
|
{
|
|
2461
3500
|
status: "allDone" /* allDone */,
|
|
@@ -2464,7 +3503,7 @@ var BankTransactions = ({
|
|
|
2464
3503
|
onRefresh: () => refetch(),
|
|
2465
3504
|
isLoading: isValidating
|
|
2466
3505
|
}
|
|
2467
|
-
)) : null, !isLoading && error ? /* @__PURE__ */
|
|
3506
|
+
)) : null, !isLoading && error ? /* @__PURE__ */ React50.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React50.createElement(
|
|
2468
3507
|
DataState,
|
|
2469
3508
|
{
|
|
2470
3509
|
status: "failed" /* failed */,
|
|
@@ -2473,11 +3512,19 @@ var BankTransactions = ({
|
|
|
2473
3512
|
onRefresh: () => refetch(),
|
|
2474
3513
|
isLoading: isValidating
|
|
2475
3514
|
}
|
|
2476
|
-
)) : 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
|
+
)));
|
|
2477
3524
|
};
|
|
2478
3525
|
|
|
2479
3526
|
// src/components/Hello/Hello.tsx
|
|
2480
|
-
import
|
|
3527
|
+
import React51 from "react";
|
|
2481
3528
|
import useSWR3 from "swr";
|
|
2482
3529
|
var fetcher = (url) => fetch(url).then((res) => res.json());
|
|
2483
3530
|
var Hello = ({ user }) => {
|
|
@@ -2486,17 +3533,22 @@ var Hello = ({ user }) => {
|
|
|
2486
3533
|
fetcher
|
|
2487
3534
|
);
|
|
2488
3535
|
const name = (isLoading ? "..." : data?.name) || "User";
|
|
2489
|
-
return /* @__PURE__ */
|
|
3536
|
+
return /* @__PURE__ */ React51.createElement(React51.Fragment, null, /* @__PURE__ */ React51.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
|
|
2490
3537
|
};
|
|
2491
3538
|
|
|
2492
3539
|
// src/components/ProfitAndLoss/ProfitAndLoss.tsx
|
|
2493
|
-
import
|
|
3540
|
+
import React59, { createContext as createContext2 } from "react";
|
|
2494
3541
|
|
|
2495
3542
|
// src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
|
|
2496
3543
|
import { useState as useState10 } from "react";
|
|
2497
3544
|
import { startOfMonth, endOfMonth, formatISO } from "date-fns";
|
|
2498
3545
|
import useSWR4 from "swr";
|
|
2499
|
-
var useProfitAndLoss = ({
|
|
3546
|
+
var useProfitAndLoss = ({
|
|
3547
|
+
startDate: initialStartDate,
|
|
3548
|
+
endDate: initialEndDate,
|
|
3549
|
+
tagFilter,
|
|
3550
|
+
reportingBasis
|
|
3551
|
+
} = {
|
|
2500
3552
|
startDate: startOfMonth(/* @__PURE__ */ new Date()),
|
|
2501
3553
|
endDate: endOfMonth(/* @__PURE__ */ new Date())
|
|
2502
3554
|
}) => {
|
|
@@ -2510,14 +3562,21 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2510
3562
|
const {
|
|
2511
3563
|
data: rawData,
|
|
2512
3564
|
isLoading,
|
|
2513
|
-
|
|
3565
|
+
isValidating,
|
|
3566
|
+
error: rawError,
|
|
3567
|
+
mutate
|
|
2514
3568
|
} = useSWR4(
|
|
2515
|
-
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}`,
|
|
2516
3572
|
Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
|
|
2517
3573
|
params: {
|
|
2518
3574
|
businessId,
|
|
2519
3575
|
startDate: formatISO(startDate),
|
|
2520
|
-
endDate: formatISO(endDate)
|
|
3576
|
+
endDate: formatISO(endDate),
|
|
3577
|
+
tagKey: tagFilter?.key,
|
|
3578
|
+
tagValues: tagFilter?.values?.join(","),
|
|
3579
|
+
reportingBasis
|
|
2521
3580
|
}
|
|
2522
3581
|
})
|
|
2523
3582
|
);
|
|
@@ -2529,20 +3588,28 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
|
|
|
2529
3588
|
newStartDate && setStartDate(newStartDate);
|
|
2530
3589
|
newEndDate && setEndDate(newEndDate);
|
|
2531
3590
|
};
|
|
3591
|
+
const refetch = () => {
|
|
3592
|
+
mutate();
|
|
3593
|
+
};
|
|
2532
3594
|
return {
|
|
2533
3595
|
data,
|
|
2534
3596
|
isLoading,
|
|
3597
|
+
isValidating,
|
|
2535
3598
|
error: error || rawError,
|
|
2536
3599
|
dateRange: { startDate, endDate },
|
|
3600
|
+
refetch,
|
|
2537
3601
|
changeDateRange
|
|
2538
3602
|
};
|
|
2539
3603
|
};
|
|
2540
3604
|
|
|
2541
3605
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2542
|
-
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);
|
|
2543
3610
|
|
|
2544
3611
|
// src/components/ProfitAndLossChart/Indicator.tsx
|
|
2545
|
-
import
|
|
3612
|
+
import React52, { useEffect as useEffect4 } from "react";
|
|
2546
3613
|
var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
|
|
2547
3614
|
var Indicator = ({
|
|
2548
3615
|
viewBox = {},
|
|
@@ -2553,35 +3620,34 @@ var Indicator = ({
|
|
|
2553
3620
|
if (!className?.match(/selected/)) {
|
|
2554
3621
|
return null;
|
|
2555
3622
|
}
|
|
2556
|
-
const {
|
|
2557
|
-
x: animateTo = 0,
|
|
2558
|
-
y = 0,
|
|
2559
|
-
width = 0,
|
|
2560
|
-
height = 0
|
|
2561
|
-
} = "x" in viewBox ? viewBox : emptyViewBox;
|
|
3623
|
+
const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
|
|
2562
3624
|
const boxWidth = width * 2 + 4;
|
|
2563
3625
|
const multiplier = 1.5;
|
|
2564
3626
|
const xOffset = (boxWidth * multiplier - boxWidth) / 2;
|
|
2565
|
-
|
|
3627
|
+
useEffect4(() => {
|
|
2566
3628
|
setAnimateFrom(animateTo);
|
|
2567
3629
|
}, [animateTo]);
|
|
2568
3630
|
const actualX = animateFrom === -1 ? animateTo : animateFrom;
|
|
2569
|
-
return /* @__PURE__ */
|
|
3631
|
+
return /* @__PURE__ */ React52.createElement(
|
|
2570
3632
|
"rect",
|
|
2571
3633
|
{
|
|
2572
3634
|
className: "Layer__profit-and-loss-chart__selection-indicator",
|
|
3635
|
+
rx: "8",
|
|
3636
|
+
ry: "8",
|
|
2573
3637
|
style: {
|
|
2574
3638
|
width: `${boxWidth * multiplier}px`,
|
|
2575
3639
|
// @ts-expect-error -- y is fine but x apparently isn't!
|
|
2576
3640
|
x: actualX - xOffset,
|
|
2577
|
-
y:
|
|
3641
|
+
y: 5,
|
|
3642
|
+
borderRadius: 8,
|
|
3643
|
+
height: "calc(100% - 10px)"
|
|
2578
3644
|
}
|
|
2579
3645
|
}
|
|
2580
3646
|
);
|
|
2581
3647
|
};
|
|
2582
3648
|
|
|
2583
3649
|
// src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
|
|
2584
|
-
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";
|
|
2585
3651
|
import {
|
|
2586
3652
|
BarChart,
|
|
2587
3653
|
XAxis,
|
|
@@ -2590,11 +3656,14 @@ import {
|
|
|
2590
3656
|
LabelList,
|
|
2591
3657
|
CartesianGrid,
|
|
2592
3658
|
Legend,
|
|
2593
|
-
ResponsiveContainer
|
|
3659
|
+
ResponsiveContainer,
|
|
3660
|
+
Tooltip as Tooltip2,
|
|
3661
|
+
Rectangle
|
|
2594
3662
|
} from "recharts";
|
|
2595
3663
|
var barGap = 4;
|
|
2596
3664
|
var barSize = 20;
|
|
2597
3665
|
var ProfitAndLossChart = () => {
|
|
3666
|
+
const { getColor } = useLayerContext();
|
|
2598
3667
|
const { changeDateRange, dateRange } = useContext2(ProfitAndLoss.Context);
|
|
2599
3668
|
const thisMonth = startOfMonth2(Date.now());
|
|
2600
3669
|
const startSelectionMonth = dateRange.startDate.getMonth();
|
|
@@ -2672,24 +3741,50 @@ var ProfitAndLossChart = () => {
|
|
|
2672
3741
|
endDate: endOfMonth2(thisMonth)
|
|
2673
3742
|
})?.data
|
|
2674
3743
|
);
|
|
2675
|
-
const getMonthName = (pnl) => pnl ? format4(
|
|
3744
|
+
const getMonthName = (pnl) => pnl ? format4(parseISO8(pnl.start_date), "LLL") : "";
|
|
2676
3745
|
const summarizePnL = (pnl) => ({
|
|
2677
3746
|
name: getMonthName(pnl),
|
|
2678
3747
|
revenue: pnl?.income.value || 0,
|
|
2679
|
-
expenses: (pnl?.income.value || 0) - (pnl?.net_profit || 0),
|
|
2680
|
-
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
|
|
2681
3750
|
});
|
|
2682
3751
|
const onClick = ({ activeTooltipIndex }) => {
|
|
2683
3752
|
const selection = monthData[activeTooltipIndex || -1];
|
|
2684
3753
|
if (selection) {
|
|
2685
3754
|
const { start_date: startDate, end_date: endDate } = selection;
|
|
2686
3755
|
changeDateRange({
|
|
2687
|
-
startDate:
|
|
2688
|
-
endDate:
|
|
3756
|
+
startDate: parseISO8(startDate),
|
|
3757
|
+
endDate: parseISO8(endDate)
|
|
2689
3758
|
});
|
|
2690
3759
|
}
|
|
2691
3760
|
};
|
|
2692
|
-
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(
|
|
2693
3788
|
() => monthData.map(summarizePnL),
|
|
2694
3789
|
[
|
|
2695
3790
|
startSelectionMonth,
|
|
@@ -2698,135 +3793,112 @@ var ProfitAndLossChart = () => {
|
|
|
2698
3793
|
]
|
|
2699
3794
|
);
|
|
2700
3795
|
const [animateFrom, setAnimateFrom] = useState11(-1);
|
|
2701
|
-
return /* @__PURE__ */
|
|
2702
|
-
|
|
3796
|
+
return /* @__PURE__ */ React53.createElement(
|
|
3797
|
+
ResponsiveContainer,
|
|
2703
3798
|
{
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
className: "Layer__profit-and-loss-chart"
|
|
3799
|
+
className: "Layer__chart-container",
|
|
3800
|
+
width: "100%",
|
|
3801
|
+
height: "100%",
|
|
3802
|
+
minHeight: 200
|
|
2709
3803
|
},
|
|
2710
|
-
/* @__PURE__ */
|
|
2711
|
-
|
|
2712
|
-
Legend,
|
|
2713
|
-
{
|
|
2714
|
-
verticalAlign: "top",
|
|
2715
|
-
align: "left",
|
|
2716
|
-
payload: [
|
|
2717
|
-
{ value: "Income", type: "circle", id: "IncomeLegend" },
|
|
2718
|
-
{ value: "Expenses", type: "circle", id: "ExpensesLegend" }
|
|
2719
|
-
]
|
|
2720
|
-
}
|
|
2721
|
-
),
|
|
2722
|
-
/* @__PURE__ */ React41.createElement(XAxis, { dataKey: "name", tickLine: false }),
|
|
2723
|
-
/* @__PURE__ */ React41.createElement(
|
|
2724
|
-
Bar,
|
|
3804
|
+
/* @__PURE__ */ React53.createElement(
|
|
3805
|
+
BarChart,
|
|
2725
3806
|
{
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
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"
|
|
2731
3812
|
},
|
|
2732
|
-
/* @__PURE__ */
|
|
2733
|
-
|
|
3813
|
+
/* @__PURE__ */ React53.createElement(
|
|
3814
|
+
Tooltip2,
|
|
2734
3815
|
{
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
animateFrom,
|
|
2739
|
-
setAnimateFrom
|
|
2740
|
-
}
|
|
2741
|
-
)
|
|
3816
|
+
wrapperClassName: "Layer__chart__tooltip-wrapper",
|
|
3817
|
+
content: /* @__PURE__ */ React53.createElement(CustomTooltip, null),
|
|
3818
|
+
cursor: /* @__PURE__ */ React53.createElement(CustomizedCursor, null)
|
|
2742
3819
|
}
|
|
2743
3820
|
),
|
|
2744
|
-
|
|
2745
|
-
|
|
3821
|
+
/* @__PURE__ */ React53.createElement(
|
|
3822
|
+
CartesianGrid,
|
|
2746
3823
|
{
|
|
2747
|
-
|
|
2748
|
-
|
|
3824
|
+
vertical: false,
|
|
3825
|
+
stroke: getColor(200)?.hex ?? "#fff",
|
|
3826
|
+
strokeDasharray: "5 5"
|
|
2749
3827
|
}
|
|
2750
|
-
)
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
Bar,
|
|
2754
|
-
{
|
|
2755
|
-
dataKey: "expenses",
|
|
2756
|
-
barSize,
|
|
2757
|
-
isAnimationActive: false,
|
|
2758
|
-
radius: [barSize / 4, barSize / 4, 0, 0],
|
|
2759
|
-
className: "Layer__profit-and-loss-chart__bar--expenses"
|
|
2760
|
-
},
|
|
2761
|
-
data.map((entry) => /* @__PURE__ */ React41.createElement(
|
|
2762
|
-
Cell,
|
|
3828
|
+
),
|
|
3829
|
+
/* @__PURE__ */ React53.createElement(
|
|
3830
|
+
Legend,
|
|
2763
3831
|
{
|
|
2764
|
-
|
|
2765
|
-
|
|
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
|
+
]
|
|
2766
3847
|
}
|
|
2767
|
-
)
|
|
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
|
+
)
|
|
2768
3896
|
)
|
|
2769
|
-
)
|
|
3897
|
+
);
|
|
2770
3898
|
};
|
|
2771
3899
|
|
|
2772
3900
|
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
2773
|
-
import
|
|
2774
|
-
|
|
2775
|
-
// src/icons/ChevronLeft.tsx
|
|
2776
|
-
import * as React42 from "react";
|
|
2777
|
-
var ChevronLeft = ({
|
|
2778
|
-
strokeColor,
|
|
2779
|
-
size,
|
|
2780
|
-
...props
|
|
2781
|
-
}) => /* @__PURE__ */ React42.createElement(
|
|
2782
|
-
"svg",
|
|
2783
|
-
{
|
|
2784
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2785
|
-
width: size || 24,
|
|
2786
|
-
height: size || 24,
|
|
2787
|
-
fill: "none",
|
|
2788
|
-
viewBox: "0 0 24 24",
|
|
2789
|
-
...props
|
|
2790
|
-
},
|
|
2791
|
-
/* @__PURE__ */ React42.createElement(
|
|
2792
|
-
"path",
|
|
2793
|
-
{
|
|
2794
|
-
stroke: strokeColor ?? "#000",
|
|
2795
|
-
strokeLinecap: "round",
|
|
2796
|
-
strokeLinejoin: "round",
|
|
2797
|
-
strokeWidth: 2,
|
|
2798
|
-
d: "m15 18-6-6 6-6"
|
|
2799
|
-
}
|
|
2800
|
-
)
|
|
2801
|
-
);
|
|
2802
|
-
var ChevronLeft_default = ChevronLeft;
|
|
2803
|
-
|
|
2804
|
-
// src/icons/ChevronRight.tsx
|
|
2805
|
-
import * as React43 from "react";
|
|
2806
|
-
var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
|
|
2807
|
-
"svg",
|
|
2808
|
-
{
|
|
2809
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2810
|
-
width: size || 24,
|
|
2811
|
-
height: size || 24,
|
|
2812
|
-
fill: "none",
|
|
2813
|
-
viewBox: "0 0 24 24",
|
|
2814
|
-
...props
|
|
2815
|
-
},
|
|
2816
|
-
/* @__PURE__ */ React43.createElement(
|
|
2817
|
-
"path",
|
|
2818
|
-
{
|
|
2819
|
-
stroke: "#000",
|
|
2820
|
-
strokeLinecap: "round",
|
|
2821
|
-
strokeLinejoin: "round",
|
|
2822
|
-
strokeWidth: 2,
|
|
2823
|
-
d: "m9 18 6-6-6-6"
|
|
2824
|
-
}
|
|
2825
|
-
)
|
|
2826
|
-
);
|
|
2827
|
-
var ChevronRight_default = ChavronRight;
|
|
2828
|
-
|
|
2829
|
-
// src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
|
|
3901
|
+
import React54, { useContext as useContext3 } from "react";
|
|
2830
3902
|
import { add, endOfMonth as endOfMonth3, format as format5, startOfMonth as startOfMonth3 } from "date-fns";
|
|
2831
3903
|
var ProfitAndLossDatePicker = () => {
|
|
2832
3904
|
const { changeDateRange, dateRange } = useContext3(ProfitAndLoss.Context);
|
|
@@ -2841,28 +3913,28 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2841
3913
|
};
|
|
2842
3914
|
const previousMonth = () => change({ months: -1 });
|
|
2843
3915
|
const nextMonth = () => change({ months: 1 });
|
|
2844
|
-
return /* @__PURE__ */
|
|
3916
|
+
return /* @__PURE__ */ React54.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ React54.createElement(
|
|
2845
3917
|
"button",
|
|
2846
3918
|
{
|
|
2847
3919
|
"aria-label": "View Previous Month",
|
|
2848
3920
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2849
3921
|
onClick: previousMonth
|
|
2850
3922
|
},
|
|
2851
|
-
/* @__PURE__ */
|
|
3923
|
+
/* @__PURE__ */ React54.createElement(
|
|
2852
3924
|
ChevronLeft_default,
|
|
2853
3925
|
{
|
|
2854
3926
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
2855
3927
|
size: 18
|
|
2856
3928
|
}
|
|
2857
3929
|
)
|
|
2858
|
-
), /* @__PURE__ */
|
|
3930
|
+
), /* @__PURE__ */ React54.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ React54.createElement(
|
|
2859
3931
|
"button",
|
|
2860
3932
|
{
|
|
2861
3933
|
"aria-label": "View Next Month",
|
|
2862
3934
|
className: "Layer__profit-and-loss-date-picker__button",
|
|
2863
3935
|
onClick: nextMonth
|
|
2864
3936
|
},
|
|
2865
|
-
/* @__PURE__ */
|
|
3937
|
+
/* @__PURE__ */ React54.createElement(
|
|
2866
3938
|
ChevronRight_default,
|
|
2867
3939
|
{
|
|
2868
3940
|
className: "Layer__profit-and-loss-date-picker__button-icon",
|
|
@@ -2873,46 +3945,74 @@ var ProfitAndLossDatePicker = () => {
|
|
|
2873
3945
|
};
|
|
2874
3946
|
|
|
2875
3947
|
// src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
|
|
2876
|
-
import
|
|
2877
|
-
|
|
2878
|
-
|
|
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);
|
|
2879
3971
|
const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
|
|
2880
3972
|
const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2881
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";
|
|
2882
3974
|
const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
|
|
2883
|
-
return /* @__PURE__ */
|
|
2884
|
-
"
|
|
2885
|
-
{
|
|
2886
|
-
className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
|
|
2887
|
-
},
|
|
2888
|
-
centsToDollars(Math.abs(data?.income?.value ?? NaN))
|
|
2889
|
-
)), /* @__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(
|
|
2890
|
-
"span",
|
|
2891
|
-
{
|
|
2892
|
-
className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
|
|
2893
|
-
},
|
|
2894
|
-
centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
|
|
2895
|
-
)), /* @__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(
|
|
2896
|
-
"span",
|
|
3975
|
+
return /* @__PURE__ */ React56.createElement(
|
|
3976
|
+
"div",
|
|
2897
3977
|
{
|
|
2898
|
-
className: `Layer__profit-and-loss-
|
|
3978
|
+
className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
|
|
2899
3979
|
},
|
|
2900
|
-
|
|
2901
|
-
|
|
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
|
+
);
|
|
2902
4002
|
};
|
|
2903
4003
|
|
|
2904
4004
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
2905
|
-
import
|
|
4005
|
+
import React58, { useContext as useContext5 } from "react";
|
|
2906
4006
|
|
|
2907
4007
|
// src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
|
|
2908
|
-
import
|
|
4008
|
+
import React57, { useState as useState12 } from "react";
|
|
2909
4009
|
var ProfitAndLossRow = ({
|
|
2910
4010
|
variant,
|
|
2911
4011
|
lineItem,
|
|
2912
4012
|
depth = 0,
|
|
2913
4013
|
maxDepth = 1,
|
|
2914
4014
|
direction = "DEBIT" /* DEBIT */,
|
|
2915
|
-
|
|
4015
|
+
lockExpanded = false
|
|
2916
4016
|
}) => {
|
|
2917
4017
|
if (!lineItem) {
|
|
2918
4018
|
return null;
|
|
@@ -2949,12 +4049,20 @@ var ProfitAndLossRow = ({
|
|
|
2949
4049
|
);
|
|
2950
4050
|
displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
|
|
2951
4051
|
displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
|
|
2952
|
-
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(
|
|
2953
4061
|
"div",
|
|
2954
4062
|
{
|
|
2955
4063
|
className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
|
|
2956
4064
|
},
|
|
2957
|
-
/* @__PURE__ */
|
|
4065
|
+
/* @__PURE__ */ React57.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ React57.createElement(
|
|
2958
4066
|
ProfitAndLossRow,
|
|
2959
4067
|
{
|
|
2960
4068
|
key: line_item.display_name,
|
|
@@ -2963,16 +4071,7 @@ var ProfitAndLossRow = ({
|
|
|
2963
4071
|
maxDepth,
|
|
2964
4072
|
direction
|
|
2965
4073
|
}
|
|
2966
|
-
))
|
|
2967
|
-
ProfitAndLossRow,
|
|
2968
|
-
{
|
|
2969
|
-
key: display_name,
|
|
2970
|
-
lineItem: { value, display_name: `Total of ${display_name}` },
|
|
2971
|
-
variant: "summation",
|
|
2972
|
-
depth: depth + 1,
|
|
2973
|
-
maxDepth
|
|
2974
|
-
}
|
|
2975
|
-
))
|
|
4074
|
+
)))
|
|
2976
4075
|
));
|
|
2977
4076
|
};
|
|
2978
4077
|
|
|
@@ -3025,16 +4124,27 @@ var empty_profit_and_loss_report_default = {
|
|
|
3025
4124
|
};
|
|
3026
4125
|
|
|
3027
4126
|
// src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
|
|
3028
|
-
var ProfitAndLossTable = () => {
|
|
4127
|
+
var ProfitAndLossTable = ({ lockExpanded }) => {
|
|
3029
4128
|
const { data: actualData, isLoading } = useContext5(ProfitAndLoss.Context);
|
|
3030
4129
|
const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
|
|
3031
|
-
|
|
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(
|
|
3032
4141
|
ProfitAndLossRow,
|
|
3033
4142
|
{
|
|
3034
4143
|
lineItem: data.cost_of_goods_sold,
|
|
3035
|
-
direction: "DEBIT" /* DEBIT
|
|
4144
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4145
|
+
lockExpanded
|
|
3036
4146
|
}
|
|
3037
|
-
), /* @__PURE__ */
|
|
4147
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3038
4148
|
ProfitAndLossRow,
|
|
3039
4149
|
{
|
|
3040
4150
|
lineItem: {
|
|
@@ -3042,15 +4152,17 @@ var ProfitAndLossTable = () => {
|
|
|
3042
4152
|
display_name: "Gross Profit"
|
|
3043
4153
|
},
|
|
3044
4154
|
variant: "summation",
|
|
3045
|
-
direction: "CREDIT" /* CREDIT
|
|
4155
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4156
|
+
lockExpanded
|
|
3046
4157
|
}
|
|
3047
|
-
), /* @__PURE__ */
|
|
4158
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3048
4159
|
ProfitAndLossRow,
|
|
3049
4160
|
{
|
|
3050
4161
|
lineItem: data.expenses,
|
|
3051
|
-
direction: "DEBIT" /* DEBIT
|
|
4162
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4163
|
+
lockExpanded
|
|
3052
4164
|
}
|
|
3053
|
-
), /* @__PURE__ */
|
|
4165
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3054
4166
|
ProfitAndLossRow,
|
|
3055
4167
|
{
|
|
3056
4168
|
lineItem: {
|
|
@@ -3058,9 +4170,17 @@ var ProfitAndLossTable = () => {
|
|
|
3058
4170
|
display_name: "Profit Before Taxes"
|
|
3059
4171
|
},
|
|
3060
4172
|
variant: "summation",
|
|
3061
|
-
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
|
|
3062
4182
|
}
|
|
3063
|
-
), /* @__PURE__ */
|
|
4183
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3064
4184
|
ProfitAndLossRow,
|
|
3065
4185
|
{
|
|
3066
4186
|
lineItem: {
|
|
@@ -3068,19 +4188,22 @@ var ProfitAndLossTable = () => {
|
|
|
3068
4188
|
display_name: "Net Profit"
|
|
3069
4189
|
},
|
|
3070
4190
|
variant: "summation",
|
|
3071
|
-
direction: "CREDIT" /* CREDIT
|
|
4191
|
+
direction: "CREDIT" /* CREDIT */,
|
|
4192
|
+
lockExpanded
|
|
3072
4193
|
}
|
|
3073
|
-
)), /* @__PURE__ */
|
|
4194
|
+
)), /* @__PURE__ */ React58.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ React58.createElement(
|
|
3074
4195
|
ProfitAndLossRow,
|
|
3075
4196
|
{
|
|
3076
4197
|
lineItem: data.other_outflows,
|
|
3077
|
-
direction: "DEBIT" /* DEBIT
|
|
4198
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4199
|
+
lockExpanded
|
|
3078
4200
|
}
|
|
3079
|
-
), /* @__PURE__ */
|
|
4201
|
+
), /* @__PURE__ */ React58.createElement(
|
|
3080
4202
|
ProfitAndLossRow,
|
|
3081
4203
|
{
|
|
3082
4204
|
lineItem: data.personal_expenses,
|
|
3083
|
-
direction: "DEBIT" /* DEBIT
|
|
4205
|
+
direction: "DEBIT" /* DEBIT */,
|
|
4206
|
+
lockExpanded
|
|
3084
4207
|
}
|
|
3085
4208
|
)));
|
|
3086
4209
|
};
|
|
@@ -3090,17 +4213,20 @@ import { endOfMonth as endOfMonth4, startOfMonth as startOfMonth4 } from "date-f
|
|
|
3090
4213
|
var PNLContext = createContext2({
|
|
3091
4214
|
data: void 0,
|
|
3092
4215
|
isLoading: true,
|
|
4216
|
+
isValidating: false,
|
|
3093
4217
|
error: void 0,
|
|
3094
4218
|
dateRange: {
|
|
3095
4219
|
startDate: startOfMonth4(/* @__PURE__ */ new Date()),
|
|
3096
4220
|
endDate: endOfMonth4(/* @__PURE__ */ new Date())
|
|
3097
4221
|
},
|
|
3098
4222
|
changeDateRange: () => {
|
|
4223
|
+
},
|
|
4224
|
+
refetch: () => {
|
|
3099
4225
|
}
|
|
3100
4226
|
});
|
|
3101
|
-
var ProfitAndLoss = ({ children }) => {
|
|
3102
|
-
const contextData = useProfitAndLoss();
|
|
3103
|
-
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));
|
|
3104
4230
|
};
|
|
3105
4231
|
ProfitAndLoss.Chart = ProfitAndLossChart;
|
|
3106
4232
|
ProfitAndLoss.Context = PNLContext;
|
|
@@ -3108,8 +4234,46 @@ ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
|
|
|
3108
4234
|
ProfitAndLoss.Summaries = ProfitAndLossSummaries;
|
|
3109
4235
|
ProfitAndLoss.Table = ProfitAndLossTable;
|
|
3110
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
|
+
|
|
3111
4275
|
// src/providers/LayerProvider/LayerProvider.tsx
|
|
3112
|
-
import
|
|
4276
|
+
import React61, { useReducer, useEffect as useEffect5 } from "react";
|
|
3113
4277
|
import { add as add2, isBefore } from "date-fns";
|
|
3114
4278
|
import useSWR5, { SWRConfig } from "swr";
|
|
3115
4279
|
var reducer = (state, action) => {
|
|
@@ -3149,6 +4313,7 @@ var LayerProvider = ({
|
|
|
3149
4313
|
revalidateOnReconnect: false,
|
|
3150
4314
|
revalidateIfStale: false
|
|
3151
4315
|
};
|
|
4316
|
+
const colors = buildColorsPalette(theme);
|
|
3152
4317
|
const { url, scope, apiUrl } = LayerEnvironment[environment];
|
|
3153
4318
|
const [state, dispatch] = useReducer(reducer, {
|
|
3154
4319
|
auth: {
|
|
@@ -3160,7 +4325,8 @@ var LayerProvider = ({
|
|
|
3160
4325
|
businessId,
|
|
3161
4326
|
categories: [],
|
|
3162
4327
|
apiUrl,
|
|
3163
|
-
theme
|
|
4328
|
+
theme,
|
|
4329
|
+
colors
|
|
3164
4330
|
});
|
|
3165
4331
|
const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR5(
|
|
3166
4332
|
businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && isBefore(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
|
|
@@ -3172,7 +4338,7 @@ var LayerProvider = ({
|
|
|
3172
4338
|
}),
|
|
3173
4339
|
defaultSWRConfig
|
|
3174
4340
|
) : { data: void 0 };
|
|
3175
|
-
|
|
4341
|
+
useEffect5(() => {
|
|
3176
4342
|
if (businessAccessToken) {
|
|
3177
4343
|
dispatch({
|
|
3178
4344
|
type: "LayerContext.setAuth" /* setAuth */,
|
|
@@ -3197,28 +4363,36 @@ var LayerProvider = ({
|
|
|
3197
4363
|
});
|
|
3198
4364
|
}
|
|
3199
4365
|
}, [businessAccessToken, auth?.access_token]);
|
|
3200
|
-
|
|
4366
|
+
useSWR5(
|
|
3201
4367
|
businessId && auth?.access_token && `categories-${businessId}`,
|
|
3202
4368
|
Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
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
|
+
}
|
|
3211
4379
|
}
|
|
3212
|
-
|
|
4380
|
+
);
|
|
3213
4381
|
const setTheme = (theme2) => dispatch({
|
|
3214
4382
|
type: "LayerContext.setTheme" /* setTheme */,
|
|
3215
4383
|
payload: { theme: theme2 }
|
|
3216
4384
|
});
|
|
3217
|
-
|
|
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));
|
|
3218
4392
|
};
|
|
3219
4393
|
|
|
3220
4394
|
// src/components/ChartOfAccounts/ChartOfAccounts.tsx
|
|
3221
|
-
import
|
|
4395
|
+
import React64, { useState as useState14 } from "react";
|
|
3222
4396
|
|
|
3223
4397
|
// src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
|
|
3224
4398
|
import useSWR6 from "swr";
|
|
@@ -3238,12 +4412,12 @@ var useChartOfAccounts = () => {
|
|
|
3238
4412
|
};
|
|
3239
4413
|
|
|
3240
4414
|
// src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
|
|
3241
|
-
import
|
|
3242
|
-
import
|
|
4415
|
+
import React62, { useMemo as useMemo4, useState as useState13 } from "react";
|
|
4416
|
+
import Select3 from "react-select";
|
|
3243
4417
|
var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
|
|
3244
4418
|
var ChartOfAccountsNewForm = () => {
|
|
3245
4419
|
const { data, create: createAccount2 } = useChartOfAccounts();
|
|
3246
|
-
const accountOptions =
|
|
4420
|
+
const accountOptions = useMemo4(
|
|
3247
4421
|
() => flattenAccounts(data?.accounts || []).sort(
|
|
3248
4422
|
(a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
|
|
3249
4423
|
),
|
|
@@ -3266,22 +4440,22 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3266
4440
|
description
|
|
3267
4441
|
});
|
|
3268
4442
|
};
|
|
3269
|
-
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(
|
|
3270
4444
|
"input",
|
|
3271
4445
|
{
|
|
3272
4446
|
name: "name",
|
|
3273
4447
|
value: name,
|
|
3274
4448
|
onChange: (event) => setName(event.target.value)
|
|
3275
4449
|
}
|
|
3276
|
-
)), /* @__PURE__ */
|
|
4450
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Description"), /* @__PURE__ */ React62.createElement(
|
|
3277
4451
|
"input",
|
|
3278
4452
|
{
|
|
3279
4453
|
name: "description",
|
|
3280
4454
|
value: description,
|
|
3281
4455
|
onChange: (event) => setDescription(event.target.value)
|
|
3282
4456
|
}
|
|
3283
|
-
)), /* @__PURE__ */
|
|
3284
|
-
|
|
4457
|
+
)), /* @__PURE__ */ React62.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React62.createElement("span", null, "Normality"), /* @__PURE__ */ React62.createElement(
|
|
4458
|
+
Select3,
|
|
3285
4459
|
{
|
|
3286
4460
|
isSearchable: false,
|
|
3287
4461
|
onChange: (value) => value && setNormality(value.value),
|
|
@@ -3290,8 +4464,8 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3290
4464
|
{ label: "Debit", value: "DEBIT" /* DEBIT */ }
|
|
3291
4465
|
]
|
|
3292
4466
|
}
|
|
3293
|
-
)), /* @__PURE__ */
|
|
3294
|
-
|
|
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,
|
|
3295
4469
|
{
|
|
3296
4470
|
isSearchable: true,
|
|
3297
4471
|
value: parentAccount,
|
|
@@ -3300,49 +4474,49 @@ var ChartOfAccountsNewForm = () => {
|
|
|
3300
4474
|
getOptionValue: (a) => a.id,
|
|
3301
4475
|
options: accountOptions
|
|
3302
4476
|
}
|
|
3303
|
-
)), /* @__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")));
|
|
3304
4478
|
};
|
|
3305
4479
|
|
|
3306
4480
|
// src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
|
|
3307
|
-
import
|
|
4481
|
+
import React63 from "react";
|
|
3308
4482
|
var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
3309
|
-
const
|
|
4483
|
+
const classNames20 = [
|
|
3310
4484
|
"Layer__chart-of-accounts-row__table-cell",
|
|
3311
4485
|
depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
|
|
3312
4486
|
];
|
|
3313
|
-
const className =
|
|
4487
|
+
const className = classNames20.filter((id) => id).join(" ");
|
|
3314
4488
|
const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
|
|
3315
|
-
return /* @__PURE__ */
|
|
4489
|
+
return /* @__PURE__ */ React63.createElement(React63.Fragment, null, /* @__PURE__ */ React63.createElement(
|
|
3316
4490
|
"div",
|
|
3317
4491
|
{
|
|
3318
4492
|
className: `${className} Layer__chart-of-accounts-row__table-cell--name`
|
|
3319
4493
|
},
|
|
3320
4494
|
account.name
|
|
3321
|
-
), /* @__PURE__ */
|
|
4495
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3322
4496
|
"div",
|
|
3323
4497
|
{
|
|
3324
4498
|
className: `${className} Layer__chart-of-accounts-row__table-cell--type`
|
|
3325
4499
|
},
|
|
3326
4500
|
"Assets"
|
|
3327
|
-
), /* @__PURE__ */
|
|
4501
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3328
4502
|
"div",
|
|
3329
4503
|
{
|
|
3330
4504
|
className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
|
|
3331
4505
|
},
|
|
3332
4506
|
"Cash"
|
|
3333
|
-
), /* @__PURE__ */
|
|
4507
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3334
4508
|
"div",
|
|
3335
4509
|
{
|
|
3336
4510
|
className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
|
|
3337
4511
|
},
|
|
3338
4512
|
centsToDollars(Math.abs(account.balance || 0))
|
|
3339
|
-
), /* @__PURE__ */
|
|
4513
|
+
), /* @__PURE__ */ React63.createElement(
|
|
3340
4514
|
"div",
|
|
3341
4515
|
{
|
|
3342
4516
|
className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
|
|
3343
4517
|
},
|
|
3344
|
-
/* @__PURE__ */
|
|
3345
|
-
), (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(
|
|
3346
4520
|
ChartOfAccountsRow,
|
|
3347
4521
|
{
|
|
3348
4522
|
key: subAccount.id,
|
|
@@ -3356,14 +4530,14 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
|
|
|
3356
4530
|
var ChartOfAccounts = () => {
|
|
3357
4531
|
const { data, isLoading } = useChartOfAccounts();
|
|
3358
4532
|
const [showingForm, setShowingForm] = useState14(false);
|
|
3359
|
-
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(
|
|
3360
4534
|
"button",
|
|
3361
4535
|
{
|
|
3362
4536
|
className: "Layer__chart-of-accounts__edit-accounts-button",
|
|
3363
4537
|
onClick: () => setShowingForm(!showingForm)
|
|
3364
4538
|
},
|
|
3365
4539
|
"Edit Accounts"
|
|
3366
|
-
))), 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(
|
|
3367
4541
|
ChartOfAccountsRow,
|
|
3368
4542
|
{
|
|
3369
4543
|
key: account.id,
|
|
@@ -3378,6 +4552,7 @@ export {
|
|
|
3378
4552
|
ChartOfAccounts,
|
|
3379
4553
|
Hello,
|
|
3380
4554
|
LayerProvider,
|
|
3381
|
-
ProfitAndLoss
|
|
4555
|
+
ProfitAndLoss,
|
|
4556
|
+
ProfitAndLossView
|
|
3382
4557
|
};
|
|
3383
4558
|
//# sourceMappingURL=index.js.map
|