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