@layerfi/components 0.1.48 → 0.1.50

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/dist/esm/index.js CHANGED
@@ -793,12 +793,12 @@ var useBankTransactions = (params) => {
793
793
  }
794
794
  if (!prevData?.meta?.pagination?.cursor) {
795
795
  return [
796
- businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}`,
796
+ businessId && auth?.access_token && `bank-transactions-${businessId}`,
797
797
  void 0
798
798
  ];
799
799
  }
800
800
  return [
801
- businessId && auth?.access_token && `bank-transactions${filters?.categorizationStatus ? `-scope-${filters?.categorizationStatus}` : ""}-${businessId}-${prevData.meta.pagination.cursor}`,
801
+ businessId && auth?.access_token && `bank-transactions-${businessId}-${prevData.meta.pagination.cursor}`,
802
802
  prevData.meta.pagination.cursor
803
803
  ];
804
804
  };
@@ -817,8 +817,7 @@ var useBankTransactions = (params) => {
817
817
  return Layer.getBankTransactions(apiUrl, auth?.access_token, {
818
818
  params: {
819
819
  businessId,
820
- cursor: nextCursor,
821
- categorized: filters?.categorizationStatus ? filters?.categorizationStatus === "categorized" /* categorized */ ? "true" : "false" : ""
820
+ cursor: nextCursor
822
821
  }
823
822
  }).call(false);
824
823
  }
@@ -987,13 +986,6 @@ var useBankTransactions = (params) => {
987
986
  mutate(updatedData, { revalidate: false });
988
987
  };
989
988
  const removeAfterCategorize = (bankTransaction) => {
990
- const updatedData = rawResponseData?.map((page) => {
991
- return {
992
- ...page,
993
- data: page.data?.filter((bt) => bt.id !== bankTransaction.id)
994
- };
995
- });
996
- mutate(updatedData, { revalidate: false });
997
989
  };
998
990
  const refetch = () => {
999
991
  mutate();
@@ -8723,10 +8715,10 @@ var Quickbooks = () => {
8723
8715
  };
8724
8716
 
8725
8717
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
8726
- import React125, { createContext as createContext6 } from "react";
8718
+ import React131, { createContext as createContext7 } from "react";
8727
8719
 
8728
8720
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8729
- import { useMemo as useMemo7, useState as useState27 } from "react";
8721
+ import { useMemo as useMemo8, useState as useState28 } from "react";
8730
8722
 
8731
8723
  // src/utils/profitAndLossUtils.ts
8732
8724
  var doesLineItemQualifies = (item) => {
@@ -8781,17 +8773,175 @@ var applyShare = (items, total) => {
8781
8773
  });
8782
8774
  };
8783
8775
 
8784
- // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8785
- import { useEffect as useEffect21 } from "react";
8786
- import { startOfMonth as startOfMonth5, endOfMonth as endOfMonth4, formatISO } from "date-fns";
8776
+ // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
8777
+ import { useEffect as useEffect21, useMemo as useMemo7, useState as useState27 } from "react";
8778
+ import { startOfMonth as startOfMonth5, sub } from "date-fns";
8787
8779
  import useSWR3 from "swr";
8780
+ var buildDates = ({ currentDate }) => {
8781
+ return {
8782
+ startYear: startOfMonth5(currentDate).getFullYear() - 1,
8783
+ startMonth: startOfMonth5(currentDate).getMonth() + 1,
8784
+ endYear: startOfMonth5(currentDate).getFullYear(),
8785
+ endMonth: startOfMonth5(currentDate).getMonth() + 1
8786
+ };
8787
+ };
8788
+ var buildMonthsArray = (startDate, endDate) => {
8789
+ if (startDate >= endDate) {
8790
+ return [];
8791
+ }
8792
+ var dates = [];
8793
+ for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
8794
+ dates.push(new Date(d));
8795
+ }
8796
+ return dates;
8797
+ };
8798
+ var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
8799
+ currentDate: startOfMonth5(Date.now())
8800
+ }) => {
8801
+ const {
8802
+ businessId,
8803
+ auth,
8804
+ apiUrl,
8805
+ syncTimestamps,
8806
+ read,
8807
+ readTimestamps,
8808
+ hasBeenTouched
8809
+ } = useLayerContext();
8810
+ const [date, setDate] = useState27(currentDate);
8811
+ const [loaded, setLoaded] = useState27("initial");
8812
+ const [data, setData] = useState27([]);
8813
+ const { startYear, startMonth, endYear, endMonth } = useMemo7(() => {
8814
+ return buildDates({ currentDate: date });
8815
+ }, [date, businessId, tagFilter, reportingBasis]);
8816
+ const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
8817
+ ","
8818
+ )}-${reportingBasis}`;
8819
+ const {
8820
+ data: rawData,
8821
+ isLoading,
8822
+ isValidating,
8823
+ error,
8824
+ mutate
8825
+ } = useSWR3(
8826
+ queryKey,
8827
+ Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
8828
+ params: {
8829
+ businessId,
8830
+ startYear: startYear.toString(),
8831
+ startMonth: startMonth.toString(),
8832
+ endYear: endYear.toString(),
8833
+ endMonth: endMonth.toString(),
8834
+ tagKey: tagFilter?.key,
8835
+ tagValues: tagFilter?.values?.join(","),
8836
+ reportingBasis
8837
+ }
8838
+ })
8839
+ );
8840
+ useEffect21(() => {
8841
+ const newData = data.slice();
8842
+ const newPeriod = buildMonthsArray(sub(date, { years: 1 }), date);
8843
+ if (newData && newPeriod) {
8844
+ newPeriod.forEach((x) => {
8845
+ if (!newData?.find(
8846
+ (n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
8847
+ )) {
8848
+ newData.push({
8849
+ year: x.getFullYear(),
8850
+ month: x.getMonth() + 1,
8851
+ income: 0,
8852
+ costOfGoodsSold: 0,
8853
+ grossProfit: 0,
8854
+ operatingExpenses: 0,
8855
+ profitBeforeTaxes: 0,
8856
+ taxes: 0,
8857
+ netProfit: 0,
8858
+ fullyCategorized: false,
8859
+ totalExpenses: 0,
8860
+ uncategorizedInflows: 0,
8861
+ uncategorizedOutflows: 0,
8862
+ uncategorized_transactions: 0,
8863
+ isLoading: true
8864
+ });
8865
+ }
8866
+ });
8867
+ }
8868
+ if (newData) {
8869
+ setData(
8870
+ newData.sort(
8871
+ (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
8872
+ )
8873
+ );
8874
+ }
8875
+ }, [startYear, startMonth]);
8876
+ useEffect21(() => {
8877
+ const newData = rawData?.data?.months?.slice();
8878
+ if (data && newData) {
8879
+ data.forEach((x) => {
8880
+ if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
8881
+ newData.push({ ...x });
8882
+ }
8883
+ });
8884
+ }
8885
+ if (newData) {
8886
+ setData(
8887
+ newData.sort(
8888
+ (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
8889
+ )
8890
+ );
8891
+ }
8892
+ }, [rawData]);
8893
+ useEffect21(() => {
8894
+ if (isLoading && loaded === "initial") {
8895
+ setLoaded("loading");
8896
+ return;
8897
+ }
8898
+ if (!isLoading && rawData) {
8899
+ setLoaded("complete");
8900
+ }
8901
+ }, [data, isLoading]);
8902
+ const pullData = (date2) => setDate(date2);
8903
+ useEffect21(() => {
8904
+ if (queryKey && (isLoading || isValidating)) {
8905
+ read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
8906
+ }
8907
+ }, [isLoading, isValidating]);
8908
+ useEffect21(() => {
8909
+ if (queryKey && hasBeenTouched(queryKey)) {
8910
+ mutate();
8911
+ }
8912
+ }, [
8913
+ syncTimestamps,
8914
+ startYear,
8915
+ startMonth,
8916
+ endYear,
8917
+ endMonth,
8918
+ tagFilter,
8919
+ reportingBasis
8920
+ ]);
8921
+ const refetch = () => {
8922
+ mutate();
8923
+ };
8924
+ return {
8925
+ data,
8926
+ isLoading,
8927
+ loaded,
8928
+ error,
8929
+ pullData,
8930
+ refetch
8931
+ };
8932
+ };
8933
+
8934
+ // src/hooks/useProfitAndLoss/useProfitAndLossQuery.tsx
8935
+ import { useEffect as useEffect22 } from "react";
8936
+ import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth4, formatISO } from "date-fns";
8937
+ import useSWR4 from "swr";
8788
8938
  var useProfitAndLossQuery = ({
8789
8939
  startDate,
8790
8940
  endDate,
8791
8941
  tagFilter,
8792
8942
  reportingBasis
8793
8943
  } = {
8794
- startDate: startOfMonth5(/* @__PURE__ */ new Date()),
8944
+ startDate: startOfMonth6(/* @__PURE__ */ new Date()),
8795
8945
  endDate: endOfMonth4(/* @__PURE__ */ new Date())
8796
8946
  }) => {
8797
8947
  const { auth, businessId, apiUrl, syncTimestamps, read, hasBeenTouched } = useLayerContext();
@@ -8804,7 +8954,7 @@ var useProfitAndLossQuery = ({
8804
8954
  isValidating,
8805
8955
  error: rawError,
8806
8956
  mutate
8807
- } = useSWR3(
8957
+ } = useSWR4(
8808
8958
  queryKey,
8809
8959
  Layer.getProfitAndLoss(apiUrl, auth?.access_token, {
8810
8960
  params: {
@@ -8820,12 +8970,12 @@ var useProfitAndLossQuery = ({
8820
8970
  const refetch = () => {
8821
8971
  mutate();
8822
8972
  };
8823
- useEffect21(() => {
8973
+ useEffect22(() => {
8824
8974
  if (queryKey && (isLoading || isValidating)) {
8825
8975
  read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
8826
8976
  }
8827
8977
  }, [isLoading, isValidating]);
8828
- useEffect21(() => {
8978
+ useEffect22(() => {
8829
8979
  if (queryKey && hasBeenTouched(queryKey)) {
8830
8980
  refetch();
8831
8981
  }
@@ -8842,33 +8992,36 @@ var useProfitAndLossQuery = ({
8842
8992
  };
8843
8993
 
8844
8994
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
8845
- import { startOfMonth as startOfMonth6, endOfMonth as endOfMonth5 } from "date-fns";
8995
+ import { startOfMonth as startOfMonth7, endOfMonth as endOfMonth5 } from "date-fns";
8846
8996
  var useProfitAndLoss = ({
8847
8997
  startDate: initialStartDate,
8848
8998
  endDate: initialEndDate,
8849
8999
  tagFilter,
8850
9000
  reportingBasis
8851
9001
  } = {
8852
- startDate: startOfMonth6(/* @__PURE__ */ new Date()),
9002
+ startDate: startOfMonth7(/* @__PURE__ */ new Date()),
8853
9003
  endDate: endOfMonth5(/* @__PURE__ */ new Date())
8854
9004
  }) => {
8855
- const [startDate, setStartDate] = useState27(
8856
- initialStartDate || startOfMonth6(Date.now())
9005
+ const [startDate, setStartDate] = useState28(
9006
+ initialStartDate || startOfMonth7(Date.now())
8857
9007
  );
8858
- const [endDate, setEndDate] = useState27(
9008
+ const [endDate, setEndDate] = useState28(
8859
9009
  initialEndDate || endOfMonth5(Date.now())
8860
9010
  );
8861
- const [filters, setFilters] = useState27({
9011
+ const [filters, setFilters] = useState28({
8862
9012
  expenses: void 0,
8863
9013
  revenue: void 0
8864
9014
  });
8865
- const [sidebarScope, setSidebarScope] = useState27(void 0);
9015
+ const [sidebarScope, setSidebarScope] = useState28(void 0);
8866
9016
  const { data, isLoading, isValidating, error, refetch } = useProfitAndLossQuery({
8867
9017
  startDate,
8868
9018
  endDate,
8869
9019
  tagFilter,
8870
9020
  reportingBasis
8871
9021
  });
9022
+ const { data: summaryData } = useProfitAndLossLTM({
9023
+ currentDate: startDate ? startDate : startOfMonth7(/* @__PURE__ */ new Date())
9024
+ });
8872
9025
  const changeDateRange = ({
8873
9026
  startDate: newStartDate,
8874
9027
  endDate: newEndDate
@@ -8895,7 +9048,7 @@ var useProfitAndLoss = ({
8895
9048
  }
8896
9049
  });
8897
9050
  };
8898
- const { filteredDataRevenue, filteredTotalRevenue } = useMemo7(() => {
9051
+ const { filteredDataRevenue, filteredTotalRevenue } = useMemo8(() => {
8899
9052
  if (!data) {
8900
9053
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
8901
9054
  }
@@ -8909,6 +9062,19 @@ var useProfitAndLoss = ({
8909
9062
  }
8910
9063
  return x;
8911
9064
  });
9065
+ const month = startDate.getMonth() + 1;
9066
+ const year = startDate.getFullYear();
9067
+ const found = summaryData.find((x) => x.month === month && x.year === year);
9068
+ if (found && (found.uncategorizedInflows ?? 0) > 0) {
9069
+ filtered.push({
9070
+ name: "uncategorized",
9071
+ display_name: "Uncategorized",
9072
+ value: found.uncategorizedInflows,
9073
+ type: "Uncategorized",
9074
+ share: 0,
9075
+ hidden: false
9076
+ });
9077
+ }
8912
9078
  const sorted = filtered.sort((a, b) => {
8913
9079
  switch (filters["revenue"]?.sortBy) {
8914
9080
  case "category":
@@ -8931,8 +9097,8 @@ var useProfitAndLoss = ({
8931
9097
  const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
8932
9098
  const withShare = applyShare(sorted, total);
8933
9099
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
8934
- }, [data, startDate, filters, sidebarScope]);
8935
- const { filteredDataExpenses, filteredTotalExpenses } = useMemo7(() => {
9100
+ }, [data, startDate, filters, sidebarScope, summaryData]);
9101
+ const { filteredDataExpenses, filteredTotalExpenses } = useMemo8(() => {
8936
9102
  if (!data) {
8937
9103
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
8938
9104
  }
@@ -8946,6 +9112,19 @@ var useProfitAndLoss = ({
8946
9112
  }
8947
9113
  return x;
8948
9114
  });
9115
+ const month = startDate.getMonth() + 1;
9116
+ const year = startDate.getFullYear();
9117
+ const found = summaryData.find((x) => x.month === month && x.year === year);
9118
+ if (found && (found.uncategorizedOutflows ?? 0) > 0) {
9119
+ filtered.push({
9120
+ name: "uncategorized",
9121
+ display_name: "Uncategorized",
9122
+ value: found.uncategorizedOutflows,
9123
+ type: "Uncategorized",
9124
+ share: 0,
9125
+ hidden: false
9126
+ });
9127
+ }
8949
9128
  const sorted = filtered.sort((a, b) => {
8950
9129
  switch (filters["expenses"]?.sortBy) {
8951
9130
  case "category":
@@ -8968,7 +9147,7 @@ var useProfitAndLoss = ({
8968
9147
  const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
8969
9148
  const withShare = applyShare(sorted, total);
8970
9149
  return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
8971
- }, [data, startDate, filters, sidebarScope]);
9150
+ }, [data, startDate, filters, sidebarScope, summaryData]);
8972
9151
  return {
8973
9152
  data,
8974
9153
  filteredDataRevenue,
@@ -8992,201 +9171,43 @@ var useProfitAndLoss = ({
8992
9171
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
8993
9172
  import React112, { useContext as useContext12, useEffect as useEffect24, useMemo as useMemo9, useState as useState30 } from "react";
8994
9173
 
8995
- // src/hooks/useProfitAndLoss/useProfitAndLossLTM.tsx
8996
- import { useEffect as useEffect22, useMemo as useMemo8, useState as useState28 } from "react";
8997
- import { startOfMonth as startOfMonth7, sub } from "date-fns";
8998
- import useSWR4 from "swr";
8999
- var buildDates = ({ currentDate }) => {
9000
- return {
9001
- startYear: startOfMonth7(currentDate).getFullYear() - 1,
9002
- startMonth: startOfMonth7(currentDate).getMonth() + 1,
9003
- endYear: startOfMonth7(currentDate).getFullYear(),
9004
- endMonth: startOfMonth7(currentDate).getMonth() + 1
9005
- };
9006
- };
9007
- var buildMonthsArray = (startDate, endDate) => {
9008
- if (startDate >= endDate) {
9009
- return [];
9010
- }
9011
- var dates = [];
9012
- for (var d = startDate; d <= endDate; d.setMonth(d.getMonth() + 1)) {
9013
- dates.push(new Date(d));
9014
- }
9015
- return dates;
9016
- };
9017
- var useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
9018
- currentDate: startOfMonth7(Date.now())
9174
+ // src/components/ProfitAndLossChart/Indicator.tsx
9175
+ import React111, { useEffect as useEffect23, useState as useState29 } from "react";
9176
+ var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
9177
+ var Indicator = ({
9178
+ className,
9179
+ animateFrom,
9180
+ setAnimateFrom,
9181
+ customCursorSize,
9182
+ setCustomCursorSize,
9183
+ viewBox = {}
9019
9184
  }) => {
9020
- const {
9021
- businessId,
9022
- auth,
9023
- apiUrl,
9024
- syncTimestamps,
9025
- read,
9026
- readTimestamps,
9027
- hasBeenTouched
9028
- } = useLayerContext();
9029
- const [date, setDate] = useState28(currentDate);
9030
- const [loaded, setLoaded] = useState28("initial");
9031
- const [data, setData] = useState28([]);
9032
- const { startYear, startMonth, endYear, endMonth } = useMemo8(() => {
9033
- return buildDates({ currentDate: date });
9034
- }, [date, businessId, tagFilter, reportingBasis]);
9035
- const queryKey = businessId && Boolean(startYear) && Boolean(startMonth) && Boolean(endYear) && Boolean(endMonth) && auth?.access_token && `profit-and-loss-summaries-${businessId}-${startYear.toString()}-${startMonth.toString()}-${tagFilter?.key}-${tagFilter?.values?.join(
9036
- ","
9037
- )}-${reportingBasis}`;
9038
- const {
9039
- data: rawData,
9040
- isLoading,
9041
- isValidating,
9042
- error,
9043
- mutate
9044
- } = useSWR4(
9045
- queryKey,
9046
- Layer.getProfitAndLossSummaries(apiUrl, auth?.access_token, {
9047
- params: {
9048
- businessId,
9049
- startYear: startYear.toString(),
9050
- startMonth: startMonth.toString(),
9051
- endYear: endYear.toString(),
9052
- endMonth: endMonth.toString(),
9053
- tagKey: tagFilter?.key,
9054
- tagValues: tagFilter?.values?.join(","),
9055
- reportingBasis
9056
- }
9057
- })
9058
- );
9059
- useEffect22(() => {
9060
- const newData = data.slice();
9061
- const newPeriod = buildMonthsArray(sub(date, { years: 1 }), date);
9062
- if (newData && newPeriod) {
9063
- newPeriod.forEach((x) => {
9064
- if (!newData?.find(
9065
- (n) => x.getMonth() + 1 === n.month && x.getFullYear() === n.year
9066
- )) {
9067
- newData.push({
9068
- year: x.getFullYear(),
9069
- month: x.getMonth() + 1,
9070
- income: 0,
9071
- costOfGoodsSold: 0,
9072
- grossProfit: 0,
9073
- operatingExpenses: 0,
9074
- profitBeforeTaxes: 0,
9075
- taxes: 0,
9076
- netProfit: 0,
9077
- fullyCategorized: false,
9078
- totalExpenses: 0,
9079
- uncategorizedInflows: 0,
9080
- uncategorizedOutflows: 0,
9081
- uncategorized_transactions: 0,
9082
- isLoading: true
9083
- });
9084
- }
9085
- });
9086
- }
9087
- if (newData) {
9088
- setData(
9089
- newData.sort(
9090
- (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
9091
- )
9092
- );
9093
- }
9094
- }, [startYear, startMonth]);
9095
- useEffect22(() => {
9096
- const newData = rawData?.data?.months?.slice();
9097
- if (data && newData) {
9098
- data.forEach((x) => {
9099
- if (!newData?.find((n) => x.month === n.month && x.year === n.year)) {
9100
- newData.push({ ...x });
9101
- }
9102
- });
9103
- }
9104
- if (newData) {
9105
- setData(
9106
- newData.sort(
9107
- (a, b) => Number(new Date(a.year, a.month, 1)) - Number(new Date(b.year, b.month, 1))
9108
- )
9109
- );
9110
- }
9111
- }, [rawData]);
9112
- useEffect22(() => {
9113
- if (isLoading && loaded === "initial") {
9114
- setLoaded("loading");
9115
- return;
9116
- }
9117
- if (!isLoading && rawData) {
9118
- setLoaded("complete");
9119
- }
9120
- }, [data, isLoading]);
9121
- const pullData = (date2) => setDate(date2);
9122
- useEffect22(() => {
9123
- if (queryKey && (isLoading || isValidating)) {
9124
- read("PROFIT_AND_LOSS" /* PROFIT_AND_LOSS */, queryKey);
9125
- }
9126
- }, [isLoading, isValidating]);
9127
- useEffect22(() => {
9128
- if (queryKey && hasBeenTouched(queryKey)) {
9129
- mutate();
9130
- }
9131
- }, [
9132
- syncTimestamps,
9133
- startYear,
9134
- startMonth,
9135
- endYear,
9136
- endMonth,
9137
- tagFilter,
9138
- reportingBasis
9139
- ]);
9140
- const refetch = () => {
9141
- mutate();
9142
- };
9143
- return {
9144
- data,
9145
- isLoading,
9146
- loaded,
9147
- error,
9148
- pullData,
9149
- refetch
9150
- };
9151
- };
9152
-
9153
- // src/components/ProfitAndLossChart/Indicator.tsx
9154
- import React111, { useEffect as useEffect23, useState as useState29 } from "react";
9155
- var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
9156
- var Indicator = ({
9157
- className,
9158
- animateFrom,
9159
- setAnimateFrom,
9160
- customCursorSize,
9161
- setCustomCursorSize,
9162
- viewBox = {}
9163
- }) => {
9164
- if (!className?.match(/selected/)) {
9165
- return null;
9166
- }
9167
- const [opacityIndicator, setOpacityIndicator] = useState29(0);
9168
- const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
9169
- const margin = width > 12 ? 12 : 6;
9170
- const boxWidth = width + margin;
9171
- const xOffset = boxWidth / 2;
9172
- const borderRadius = 6;
9173
- const rectWidth = `${boxWidth}px`;
9174
- const rectHeight = "calc(100% - 38px)";
9175
- useEffect23(() => {
9176
- if (Math.abs(animateTo - animateFrom) < 30) {
9177
- setOpacityIndicator(0);
9178
- }
9179
- setAnimateFrom(animateTo);
9180
- setTimeout(() => {
9181
- setOpacityIndicator(1);
9182
- }, 200);
9183
- }, [animateTo]);
9184
- const rectRef = (ref) => {
9185
- if (ref) {
9186
- const refRectWidth = ref.getBoundingClientRect().width;
9187
- const refRectHeight = ref.getBoundingClientRect().height;
9188
- if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
9189
- setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
9185
+ if (!className?.match(/selected/)) {
9186
+ return null;
9187
+ }
9188
+ const [opacityIndicator, setOpacityIndicator] = useState29(0);
9189
+ const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
9190
+ const margin = width > 12 ? 12 : 6;
9191
+ const boxWidth = width + margin;
9192
+ const xOffset = boxWidth / 2;
9193
+ const borderRadius = 6;
9194
+ const rectWidth = `${boxWidth}px`;
9195
+ const rectHeight = "calc(100% - 38px)";
9196
+ useEffect23(() => {
9197
+ if (Math.abs(animateTo - animateFrom) < 30) {
9198
+ setOpacityIndicator(0);
9199
+ }
9200
+ setAnimateFrom(animateTo);
9201
+ setTimeout(() => {
9202
+ setOpacityIndicator(1);
9203
+ }, 200);
9204
+ }, [animateTo]);
9205
+ const rectRef = (ref) => {
9206
+ if (ref) {
9207
+ const refRectWidth = ref.getBoundingClientRect().width;
9208
+ const refRectHeight = ref.getBoundingClientRect().height;
9209
+ if (customCursorSize.width !== refRectWidth || customCursorSize.height !== refRectHeight) {
9210
+ setCustomCursorSize(refRectWidth, refRectHeight, actualX - xOffset);
9190
9211
  }
9191
9212
  }
9192
9213
  };
@@ -10148,6 +10169,12 @@ var mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
10148
10169
  let colorIndex = 0;
10149
10170
  return data.map((obj) => {
10150
10171
  const type = obj.type;
10172
+ if (type === "Uncategorized") {
10173
+ return {
10174
+ color: "#EEEEF0",
10175
+ opacity: 1
10176
+ };
10177
+ }
10151
10178
  if (!typeToColor[type]) {
10152
10179
  typeToColor[type] = colorList[colorIndex % colorList.length];
10153
10180
  colorIndex++;
@@ -10162,6 +10189,57 @@ var mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
10162
10189
  };
10163
10190
  });
10164
10191
  };
10192
+ var ValueIcon = ({
10193
+ item,
10194
+ typeColorMapping,
10195
+ idx
10196
+ }) => {
10197
+ if (item.type === "Uncategorized") {
10198
+ return /* @__PURE__ */ React116.createElement(
10199
+ "svg",
10200
+ {
10201
+ viewBox: "0 0 12 12",
10202
+ fill: "none",
10203
+ xmlns: "http://www.w3.org/2000/svg",
10204
+ width: "12",
10205
+ height: "12"
10206
+ },
10207
+ /* @__PURE__ */ React116.createElement("defs", null, /* @__PURE__ */ React116.createElement(
10208
+ "pattern",
10209
+ {
10210
+ id: "layer-pie-dots-pattern-legend",
10211
+ x: "0",
10212
+ y: "0",
10213
+ width: "3",
10214
+ height: "3",
10215
+ patternUnits: "userSpaceOnUse"
10216
+ },
10217
+ /* @__PURE__ */ React116.createElement("rect", { width: "1", height: "1", opacity: 0.76 })
10218
+ )),
10219
+ /* @__PURE__ */ React116.createElement("rect", { width: "12", height: "12", id: "layer-pie-dots-pattern-bg", rx: "2" }),
10220
+ /* @__PURE__ */ React116.createElement(
10221
+ "rect",
10222
+ {
10223
+ x: "1",
10224
+ y: "1",
10225
+ width: "10",
10226
+ height: "10",
10227
+ fill: "url(#layer-pie-dots-pattern-legend)"
10228
+ }
10229
+ )
10230
+ );
10231
+ }
10232
+ return /* @__PURE__ */ React116.createElement(
10233
+ "div",
10234
+ {
10235
+ className: "share-icon",
10236
+ style: {
10237
+ background: typeColorMapping[idx].color,
10238
+ opacity: typeColorMapping[idx].opacity
10239
+ }
10240
+ }
10241
+ );
10242
+ };
10165
10243
  var DetailedTable = ({
10166
10244
  filteredData,
10167
10245
  sidebarScope,
@@ -10223,13 +10301,11 @@ var DetailedTable = ({
10223
10301
  /* @__PURE__ */ React116.createElement("td", { className: "type-col" }, item.type),
10224
10302
  /* @__PURE__ */ React116.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
10225
10303
  /* @__PURE__ */ React116.createElement("td", { className: "share-col" }, /* @__PURE__ */ React116.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ React116.createElement(
10226
- "div",
10304
+ ValueIcon,
10227
10305
  {
10228
- className: "share-icon",
10229
- style: {
10230
- background: typeColorMapping[idx].color,
10231
- opacity: typeColorMapping[idx].opacity
10232
- }
10306
+ item,
10307
+ typeColorMapping,
10308
+ idx
10233
10309
  }
10234
10310
  )))
10235
10311
  );
@@ -10237,6 +10313,7 @@ var DetailedTable = ({
10237
10313
  };
10238
10314
 
10239
10315
  // src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
10316
+ import classNames43 from "classnames";
10240
10317
  import {
10241
10318
  PieChart,
10242
10319
  Pie,
@@ -10277,7 +10354,32 @@ var DetailedChart = ({
10277
10354
  }, [filteredData, isLoading]);
10278
10355
  const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
10279
10356
  const typeColorMapping = mapTypesToColors(chartData, chartColorsList);
10280
- return /* @__PURE__ */ React117.createElement("div", { className: "chart-field" }, /* @__PURE__ */ React117.createElement("div", { className: "header--tablet" }, showDatePicker && /* @__PURE__ */ React117.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ React117.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React117.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React117.createElement(PieChart, null, !isLoading && !noValue ? /* @__PURE__ */ React117.createElement(
10357
+ return /* @__PURE__ */ React117.createElement("div", { className: "chart-field" }, /* @__PURE__ */ React117.createElement("div", { className: "header--tablet" }, showDatePicker && /* @__PURE__ */ React117.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ React117.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React117.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React117.createElement(PieChart, null, /* @__PURE__ */ React117.createElement("defs", null, /* @__PURE__ */ React117.createElement(
10358
+ "pattern",
10359
+ {
10360
+ id: "layer-pie-stripe-pattern",
10361
+ x: "0",
10362
+ y: "0",
10363
+ width: "4",
10364
+ height: "4",
10365
+ patternTransform: "rotate(45)",
10366
+ patternUnits: "userSpaceOnUse"
10367
+ },
10368
+ /* @__PURE__ */ React117.createElement("rect", { width: "4", height: "4", opacity: 0.16 }),
10369
+ /* @__PURE__ */ React117.createElement("line", { x1: "0", y: "0", x2: "0", y2: "4", strokeWidth: "2" })
10370
+ ), /* @__PURE__ */ React117.createElement(
10371
+ "pattern",
10372
+ {
10373
+ id: "layer-pie-dots-pattern",
10374
+ x: "0",
10375
+ y: "0",
10376
+ width: "3",
10377
+ height: "3",
10378
+ patternUnits: "userSpaceOnUse"
10379
+ },
10380
+ /* @__PURE__ */ React117.createElement("rect", { width: "3", height: "3", opacity: 0.46, className: "bg" }),
10381
+ /* @__PURE__ */ React117.createElement("rect", { width: "1", height: "1", opacity: 0.56 })
10382
+ )), !isLoading && !noValue ? /* @__PURE__ */ React117.createElement(
10281
10383
  Pie,
10282
10384
  {
10283
10385
  data: chartData,
@@ -10303,8 +10405,14 @@ var DetailedChart = ({
10303
10405
  Cell2,
10304
10406
  {
10305
10407
  key: `cell-${index}`,
10306
- className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
10307
- style: { fill },
10408
+ className: classNames43(
10409
+ "Layer__profit-and-loss-detailed-charts__pie",
10410
+ hoveredItem && active ? "active" : "inactive",
10411
+ entry.type === "Uncategorized" && "Layer__profit-and-loss-detailed-charts__pie--border"
10412
+ ),
10413
+ style: {
10414
+ fill: entry.type === "Uncategorized" && fill ? "url(#layer-pie-dots-pattern)" : fill
10415
+ },
10308
10416
  opacity: typeColorMapping[index].opacity,
10309
10417
  onMouseEnter: () => setHoveredItem(entry.name),
10310
10418
  onMouseLeave: () => setHoveredItem(void 0)
@@ -10660,7 +10768,7 @@ var MiniChart = ({ data }) => {
10660
10768
  };
10661
10769
 
10662
10770
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
10663
- import classNames43 from "classnames";
10771
+ import classNames44 from "classnames";
10664
10772
  var CHART_PLACEHOLDER = [
10665
10773
  {
10666
10774
  name: "placeholder",
@@ -10719,7 +10827,7 @@ var ProfitAndLossSummaries = ({
10719
10827
  /* @__PURE__ */ React121.createElement(
10720
10828
  "div",
10721
10829
  {
10722
- className: classNames43(
10830
+ className: classNames44(
10723
10831
  "Layer__profit-and-loss-summaries__summary",
10724
10832
  actionable && "Layer__actionable",
10725
10833
  "Layer__profit-and-loss-summaries__summary--income",
@@ -10741,7 +10849,7 @@ var ProfitAndLossSummaries = ({
10741
10849
  /* @__PURE__ */ React121.createElement(
10742
10850
  "div",
10743
10851
  {
10744
- className: classNames43(
10852
+ className: classNames44(
10745
10853
  "Layer__profit-and-loss-summaries__summary",
10746
10854
  actionable && "Layer__actionable",
10747
10855
  "Layer__profit-and-loss-summaries__summary--expenses",
@@ -10765,7 +10873,7 @@ var ProfitAndLossSummaries = ({
10765
10873
  /* @__PURE__ */ React121.createElement(
10766
10874
  "div",
10767
10875
  {
10768
- className: classNames43(
10876
+ className: classNames44(
10769
10877
  "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit",
10770
10878
  actionable && "Layer__actionable"
10771
10879
  )
@@ -10781,15 +10889,91 @@ var ProfitAndLossSummaries = ({
10781
10889
  );
10782
10890
  };
10783
10891
 
10784
- // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
10785
- import React124, { useContext as useContext16 } from "react";
10892
+ // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
10893
+ import React130 from "react";
10894
+
10895
+ // src/contexts/TableContext/TableContext.tsx
10896
+ import React122, { createContext as createContext6, useState as useState32 } from "react";
10897
+ var defaultValue = {
10898
+ expandedRows: [],
10899
+ setExpandedRows: () => {
10900
+ },
10901
+ expandAllRows: () => {
10902
+ },
10903
+ expandedAllRows: false,
10904
+ setExpandedAllRows: () => {
10905
+ }
10906
+ };
10907
+ var TableContext = createContext6(defaultValue);
10908
+ var TableProvider = ({ children }) => {
10909
+ const [expandedRows, setExpandedRowsState] = useState32([]);
10910
+ const [expandedAllRows, setExpandedAllRows] = useState32(false);
10911
+ const toggleRow = (rowKey) => {
10912
+ setExpandedRowsState((prevRows) => {
10913
+ const rows = [...prevRows];
10914
+ if (rows.includes(rowKey)) {
10915
+ rows.splice(rows.indexOf(rowKey), 1);
10916
+ } else {
10917
+ rows.push(rowKey);
10918
+ }
10919
+ return rows;
10920
+ });
10921
+ };
10922
+ const expandAllRows = (rowKeys) => {
10923
+ setExpandedRowsState(rowKeys);
10924
+ };
10925
+ const contextValue = {
10926
+ expandedRows,
10927
+ setExpandedRows: toggleRow,
10928
+ expandAllRows,
10929
+ expandedAllRows,
10930
+ setExpandedAllRows
10931
+ };
10932
+ return /* @__PURE__ */ React122.createElement(TableContext.Provider, { value: contextValue }, children);
10933
+ };
10934
+
10935
+ // src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
10936
+ import React129, { useContext as useContext17, useEffect as useEffect27 } from "react";
10786
10937
 
10787
- // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
10788
- import React123, { useState as useState32 } from "react";
10938
+ // src/hooks/useTableExpandRow/useTableExpandRow.tsx
10939
+ import { useContext as useContext16 } from "react";
10940
+ var useTableExpandRow = () => {
10941
+ const {
10942
+ expandedAllRows,
10943
+ setExpandedAllRows,
10944
+ expandAllRows,
10945
+ expandedRows,
10946
+ setExpandedRows
10947
+ } = useContext16(TableContext);
10948
+ const toggleAllRows = () => {
10949
+ if (expandedAllRows) {
10950
+ setIsOpen([]);
10951
+ return setExpandedAllRows(false);
10952
+ } else {
10953
+ return setExpandedAllRows(true);
10954
+ }
10955
+ };
10956
+ const setIsOpen = (rowKey, withoutAllRowsUpdate) => {
10957
+ if (!withoutAllRowsUpdate && expandedAllRows) {
10958
+ setExpandedAllRows(false);
10959
+ }
10960
+ if (Array.isArray(rowKey)) {
10961
+ return expandAllRows(rowKey);
10962
+ }
10963
+ return setExpandedRows(rowKey);
10964
+ };
10965
+ const isOpen = (rowKey) => expandedRows.includes(rowKey);
10966
+ return {
10967
+ isOpen,
10968
+ setIsOpen,
10969
+ expandedAllRows,
10970
+ toggleAllRows
10971
+ };
10972
+ };
10789
10973
 
10790
10974
  // src/icons/PieChart.tsx
10791
- import * as React122 from "react";
10792
- var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElement(
10975
+ import * as React123 from "react";
10976
+ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React123.createElement(
10793
10977
  "svg",
10794
10978
  {
10795
10979
  xmlns: "http://www.w3.org/2000/svg",
@@ -10799,7 +10983,7 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10799
10983
  width: size,
10800
10984
  height: size
10801
10985
  },
10802
- /* @__PURE__ */ React122.createElement("g", null, /* @__PURE__ */ React122.createElement(
10986
+ /* @__PURE__ */ React123.createElement("g", null, /* @__PURE__ */ React123.createElement(
10803
10987
  "path",
10804
10988
  {
10805
10989
  d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
@@ -10807,7 +10991,7 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10807
10991
  strokeLinecap: "round",
10808
10992
  strokeLinejoin: "round"
10809
10993
  }
10810
- ), /* @__PURE__ */ React122.createElement(
10994
+ ), /* @__PURE__ */ React123.createElement(
10811
10995
  "path",
10812
10996
  {
10813
10997
  d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
@@ -10819,96 +11003,139 @@ var PieChart3 = ({ size = 12, ...props }) => /* @__PURE__ */ React122.createElem
10819
11003
  );
10820
11004
  var PieChart_default = PieChart3;
10821
11005
 
10822
- // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
10823
- var ProfitAndLossRow = ({
10824
- variant,
10825
- lineItem,
10826
- depth = 0,
10827
- maxDepth = 8,
10828
- direction = "DEBIT" /* DEBIT */,
10829
- lockExpanded = false,
10830
- scope,
10831
- setSidebarScope,
10832
- defaultExpanded = false
11006
+ // src/components/TableBody/TableBody.tsx
11007
+ import React124 from "react";
11008
+ var TableBody = ({ children }) => {
11009
+ return /* @__PURE__ */ React124.createElement("tbody", { className: "Layer__table-body" }, children);
11010
+ };
11011
+
11012
+ // src/components/TableCell/TableCell.tsx
11013
+ import React125 from "react";
11014
+ import classNames45 from "classnames";
11015
+ var TableCell = ({
11016
+ children,
11017
+ isHeaderCell,
11018
+ isCurrency,
11019
+ primary,
11020
+ withExpandIcon = false,
11021
+ fullWidth
10833
11022
  }) => {
10834
- if (!lineItem) {
10835
- return null;
10836
- }
10837
- const { value, display_name, line_items } = lineItem;
10838
- const [expanded, setExpanded] = useState32(lockExpanded || defaultExpanded);
10839
- const amount = value ?? 0;
11023
+ const amount = typeof children === "number" ? children : 0;
11024
+ const isPositive = amount >= 0;
10840
11025
  const amountString = centsToDollars(Math.abs(amount));
10841
- const labelClasses = [
10842
- "Layer__profit-and-loss-row",
10843
- "Layer__profit-and-loss-row__label"
10844
- ];
10845
- const valueClasses = [
10846
- "Layer__profit-and-loss-row",
10847
- "Layer__profit-and-loss-row__value"
10848
- ];
10849
- const positive = amount === 0 || direction === "CREDIT" /* CREDIT */ && amount > 0 || direction === "DEBIT" /* DEBIT */ && amount < 0;
10850
- valueClasses.push(
10851
- positive ? "Layer__profit-and-loss-row__value--amount-positive" : "Layer__profit-and-loss-row__value--amount-negative"
10852
- );
10853
- labelClasses.push(`Layer__profit-and-loss-row__label--depth-${depth}`);
10854
- valueClasses.push(`Layer__profit-and-loss-row__value--depth-${depth}`);
10855
- variant && labelClasses.push(`Layer__profit-and-loss-row__label--variant-${variant}`);
10856
- variant && valueClasses.push(`Layer__profit-and-loss-row__value--variant-${variant}`);
10857
- const toggleExpanded = () => setExpanded(!expanded);
10858
- const canGoDeeper = depth < maxDepth;
10859
- const hasChildren = (line_items?.length ?? 0) > 0;
10860
- const displayChildren = hasChildren && canGoDeeper;
10861
- labelClasses.push(
10862
- `Layer__profit-and-loss-row__label--display-children-${displayChildren}`
10863
- );
10864
- valueClasses.push(
10865
- `Layer__profit-and-loss-row__value--display-children-${displayChildren}`
10866
- );
10867
- displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
10868
- displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
10869
- return /* @__PURE__ */ React123.createElement(React123.Fragment, null, /* @__PURE__ */ React123.createElement(
10870
- "div",
11026
+ const cellClassNames = classNames45(
11027
+ "Layer__table-cell",
11028
+ (primary || isHeaderCell) && "Layer__table-cell--primary",
11029
+ isCurrency && "Layer__table-cell-amount",
11030
+ isCurrency && isPositive && "Layer__table-cell-amount--positive",
11031
+ isCurrency && !isPositive && "Layer__table-cell-amount--negative"
11032
+ );
11033
+ if (isHeaderCell) {
11034
+ return /* @__PURE__ */ React125.createElement("th", { className: cellClassNames }, /* @__PURE__ */ React125.createElement("span", { className: "Layer__table-cell-content" }, children));
11035
+ }
11036
+ return /* @__PURE__ */ React125.createElement(
11037
+ "td",
10871
11038
  {
10872
- className: labelClasses.join(" "),
10873
- onClick: () => !lockExpanded && toggleExpanded(),
10874
- style: {
10875
- paddingLeft: depth === 0 && !hasChildren ? 28 : 16 * (depth + 1) + 2
10876
- }
11039
+ className: cellClassNames,
11040
+ style: fullWidth ? { width: "100%" } : void 0
10877
11041
  },
10878
- /* @__PURE__ */ React123.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ React123.createElement(
11042
+ /* @__PURE__ */ React125.createElement("span", { className: "Layer__table-cell-content" }, withExpandIcon && /* @__PURE__ */ React125.createElement(
10879
11043
  ChevronDownFill_default,
10880
11044
  {
10881
- size: 16,
10882
- className: "Layer__profit-and-loss-row__label__chevron"
11045
+ className: "Layer__table-row--expand-icon",
11046
+ size: 16
10883
11047
  }
10884
- ) : null, /* @__PURE__ */ React123.createElement(Text, null, display_name)),
10885
- setSidebarScope && /* @__PURE__ */ React123.createElement(
10886
- "span",
10887
- {
10888
- className: "Layer__profit-and-loss-row__detailed-chart-btn",
10889
- onClick: (e) => {
10890
- e.stopPropagation();
10891
- setSidebarScope && setSidebarScope(scope ?? "expenses");
11048
+ ), isCurrency ? amountString : children, " ")
11049
+ );
11050
+ };
11051
+
11052
+ // src/components/TableHead/TableHead.tsx
11053
+ import React126 from "react";
11054
+ var TableHead = ({ children }) => {
11055
+ return /* @__PURE__ */ React126.createElement("thead", { className: "Layer__table-header" }, children);
11056
+ };
11057
+
11058
+ // src/components/TableRow/TableRow.tsx
11059
+ import React127 from "react";
11060
+ import classNames46 from "classnames";
11061
+ var TableRow = ({
11062
+ rowKey,
11063
+ children,
11064
+ depth = 0,
11065
+ expandable = false,
11066
+ isExpanded = false,
11067
+ handleExpand,
11068
+ variant = expandable ? "expandable" : "default",
11069
+ withDivider,
11070
+ withDividerPosition = "top",
11071
+ isHeadRow = false
11072
+ }) => {
11073
+ const toggleExpanded = () => {
11074
+ if (variant === "summation" || !expandable)
11075
+ return;
11076
+ handleExpand && handleExpand();
11077
+ };
11078
+ const rowClassNames = classNames46([
11079
+ "Layer__table-row",
11080
+ !isHeadRow && `Layer__table-row--depth-${depth}`,
11081
+ !isHeadRow && `Layer__table-row--variant-${variant}`,
11082
+ !isHeadRow && expandable && (isExpanded ? "Layer__table-row--expanded" : "Layer__table-row--collapsed")
11083
+ ]);
11084
+ return /* @__PURE__ */ React127.createElement(React127.Fragment, null, withDivider && withDividerPosition === "top" && /* @__PURE__ */ React127.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ React127.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })), /* @__PURE__ */ React127.createElement("tr", { "data-key": rowKey, className: rowClassNames, onClick: toggleExpanded }, children), withDivider && withDividerPosition === "bottom" && /* @__PURE__ */ React127.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ React127.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })));
11085
+ };
11086
+
11087
+ // src/components/Table/Table.tsx
11088
+ import React128, { useEffect as useEffect26, useRef as useRef15 } from "react";
11089
+ import classNames47 from "classnames";
11090
+ var Table = ({
11091
+ componentName,
11092
+ children,
11093
+ borderCollapse = "separate",
11094
+ bottomSpacing = true
11095
+ }) => {
11096
+ const tableRef = useRef15(null);
11097
+ const prevChildrenRef = useRef15([]);
11098
+ useEffect26(() => {
11099
+ if (tableRef.current) {
11100
+ const tbody = tableRef.current.querySelector("tbody");
11101
+ const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
11102
+ const prevChildrenArray = prevChildrenRef.current;
11103
+ const currentChildren = rows.map(
11104
+ (child) => child.getAttribute("data-key") && {
11105
+ key: child.getAttribute("data-key"),
11106
+ child
10892
11107
  }
10893
- },
10894
- /* @__PURE__ */ React123.createElement(PieChart_default, null)
10895
- )
10896
- ), /* @__PURE__ */ React123.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ React123.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ React123.createElement(
10897
- "div",
10898
- {
10899
- className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
10900
- },
10901
- /* @__PURE__ */ React123.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ React123.createElement(
10902
- ProfitAndLossRow,
10903
- {
10904
- key: line_item.display_name,
10905
- lineItem: line_item,
10906
- depth: depth + 1,
10907
- maxDepth,
10908
- direction
10909
- }
10910
- )))
10911
- ));
11108
+ );
11109
+ const newChildrenKeys = [];
11110
+ const newChildrenArray = currentChildren.filter((el) => {
11111
+ if (el && el.key) {
11112
+ newChildrenKeys.push(el.key);
11113
+ }
11114
+ return el && el.key && !prevChildrenArray.includes(el.key);
11115
+ });
11116
+ newChildrenArray.forEach((row, index) => {
11117
+ const rowKey = row && row.key;
11118
+ if (rowKey && !row.child.classList.contains("Layer__table-empty-row")) {
11119
+ row.child.classList.add("Layer__table-row--anim-starting-state");
11120
+ setTimeout(() => {
11121
+ row.child.classList.add("Layer__table-row--anim-complete-state");
11122
+ row.child.classList.remove("Layer__table-row--anim-starting-state");
11123
+ }, 15 * index);
11124
+ }
11125
+ });
11126
+ prevChildrenRef.current = newChildrenKeys;
11127
+ }
11128
+ }, [children]);
11129
+ const tableWrapperClassNames = classNames47(
11130
+ "Layer__table-wrapper",
11131
+ bottomSpacing && "Layer__table-wrapper--bottom-spacing"
11132
+ );
11133
+ const tableClassNames = classNames47(
11134
+ "Layer__table",
11135
+ componentName && `Layer__${componentName}__table`,
11136
+ borderCollapse && `Layer__table__${borderCollapse}-rows`
11137
+ );
11138
+ return /* @__PURE__ */ React128.createElement("div", { className: tableWrapperClassNames }, /* @__PURE__ */ React128.createElement("table", { className: tableClassNames, ref: tableRef }, children));
10912
11139
  };
10913
11140
 
10914
11141
  // src/components/ProfitAndLossTable/empty_profit_and_loss_report.ts
@@ -10959,10 +11186,9 @@ var empty_profit_and_loss_report_default = {
10959
11186
  fully_categorized: false
10960
11187
  };
10961
11188
 
10962
- // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
10963
- import classNames44 from "classnames";
10964
- var ProfitAndLossTable = ({
10965
- lockExpanded,
11189
+ // src/components/ProfitAndLossTable/ProfitAndLossTableComponent.tsx
11190
+ import classNames48 from "classnames";
11191
+ var ProfitAndLossTableComponent = ({
10966
11192
  asContainer,
10967
11193
  stringOverrides
10968
11194
  }) => {
@@ -10970,135 +11196,134 @@ var ProfitAndLossTable = ({
10970
11196
  data: actualData,
10971
11197
  isLoading,
10972
11198
  setSidebarScope
10973
- } = useContext16(ProfitAndLoss.Context);
11199
+ } = useContext17(ProfitAndLoss.Context);
11200
+ const { isOpen, setIsOpen } = useTableExpandRow();
11201
+ useEffect27(() => {
11202
+ setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
11203
+ }, []);
10974
11204
  const currentData = Array.isArray(actualData) ? actualData[actualData.length - 1] : actualData;
10975
11205
  const data = !currentData || isLoading ? empty_profit_and_loss_report_default : currentData;
10976
11206
  if (isLoading || actualData === void 0) {
10977
- return /* @__PURE__ */ React124.createElement(
11207
+ return /* @__PURE__ */ React129.createElement(
10978
11208
  "div",
10979
11209
  {
10980
- className: classNames44(
11210
+ className: classNames48(
10981
11211
  "Layer__profit-and-loss-table__loader-container",
10982
11212
  asContainer && "Layer__component-container"
10983
11213
  )
10984
11214
  },
10985
- /* @__PURE__ */ React124.createElement(Loader2, null)
11215
+ /* @__PURE__ */ React129.createElement(Loader2, null)
10986
11216
  );
10987
11217
  }
10988
- return /* @__PURE__ */ React124.createElement(React124.Fragment, null, /* @__PURE__ */ React124.createElement(
10989
- "div",
10990
- {
10991
- className: classNames44(
10992
- "Layer__profit-and-loss-table Layer__profit-and-loss-table--main",
10993
- asContainer && "Layer__component-container"
10994
- )
10995
- },
10996
- /* @__PURE__ */ React124.createElement(
10997
- ProfitAndLossRow,
10998
- {
10999
- lineItem: data.income,
11000
- direction: "CREDIT" /* CREDIT */,
11001
- lockExpanded,
11002
- scope: "revenue",
11003
- setSidebarScope,
11004
- defaultExpanded: true
11005
- }
11006
- ),
11007
- /* @__PURE__ */ React124.createElement(
11008
- ProfitAndLossRow,
11009
- {
11010
- lineItem: data.cost_of_goods_sold,
11011
- direction: "DEBIT" /* DEBIT */,
11012
- lockExpanded,
11013
- scope: "expenses",
11014
- setSidebarScope,
11015
- defaultExpanded: true
11016
- }
11017
- ),
11018
- /* @__PURE__ */ React124.createElement(
11019
- ProfitAndLossRow,
11020
- {
11021
- lineItem: {
11022
- value: data.gross_profit,
11023
- display_name: stringOverrides?.grossProfitLabel || "Gross Profit"
11024
- },
11025
- variant: "summation",
11026
- direction: "CREDIT" /* CREDIT */,
11027
- lockExpanded,
11028
- scope: "revenue",
11029
- setSidebarScope,
11030
- defaultExpanded: true
11031
- }
11032
- ),
11033
- /* @__PURE__ */ React124.createElement(
11034
- ProfitAndLossRow,
11035
- {
11036
- lineItem: data.expenses,
11037
- direction: "DEBIT" /* DEBIT */,
11038
- lockExpanded,
11039
- scope: "expenses",
11040
- setSidebarScope,
11041
- defaultExpanded: true
11042
- }
11043
- ),
11044
- /* @__PURE__ */ React124.createElement(
11045
- ProfitAndLossRow,
11046
- {
11047
- lineItem: {
11048
- value: data.profit_before_taxes,
11049
- display_name: stringOverrides?.profitBeforeTaxesLabel || "Profit Before Taxes"
11050
- },
11051
- variant: "summation",
11052
- direction: "CREDIT" /* CREDIT */,
11053
- lockExpanded,
11054
- scope: "revenue",
11055
- setSidebarScope,
11056
- defaultExpanded: true
11057
- }
11058
- ),
11059
- /* @__PURE__ */ React124.createElement(
11060
- ProfitAndLossRow,
11061
- {
11062
- lineItem: data.taxes,
11063
- direction: "DEBIT" /* DEBIT */,
11064
- lockExpanded,
11065
- scope: "expenses",
11066
- setSidebarScope,
11067
- defaultExpanded: true
11068
- }
11069
- ),
11070
- /* @__PURE__ */ React124.createElement(
11071
- ProfitAndLossRow,
11218
+ const renderLineItem = (lineItem, depth, rowKey, rowIndex, scope, setSidebarScope2, variant) => {
11219
+ const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
11220
+ const expanded = expandable ? isOpen(rowKey) : true;
11221
+ return /* @__PURE__ */ React129.createElement(React129.Fragment, { key: rowKey + "-" + rowIndex }, /* @__PURE__ */ React129.createElement(
11222
+ TableRow,
11072
11223
  {
11073
- lineItem: {
11074
- value: data.net_profit,
11075
- display_name: stringOverrides?.netProfitLabel || "Net Profit"
11224
+ rowKey: rowKey + "-" + rowIndex,
11225
+ expandable,
11226
+ isExpanded: expanded,
11227
+ depth,
11228
+ variant: variant ? variant : expandable ? "expandable" : "default",
11229
+ handleExpand: () => setIsOpen(rowKey)
11230
+ },
11231
+ /* @__PURE__ */ React129.createElement(
11232
+ TableCell,
11233
+ {
11234
+ primary: true,
11235
+ withExpandIcon: expandable,
11236
+ fullWidth: !!setSidebarScope2
11076
11237
  },
11077
- variant: "summation",
11078
- direction: "CREDIT" /* CREDIT */,
11079
- lockExpanded
11080
- }
11081
- )
11082
- ), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ React124.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ React124.createElement(
11083
- ProfitAndLossRow,
11238
+ lineItem.display_name,
11239
+ " ",
11240
+ setSidebarScope2 && /* @__PURE__ */ React129.createElement(
11241
+ "span",
11242
+ {
11243
+ className: "Layer__profit-and-loss-row__detailed-chart-btn",
11244
+ onClick: (e) => {
11245
+ e.stopPropagation();
11246
+ setSidebarScope2 && setSidebarScope2(scope ?? "expenses");
11247
+ }
11248
+ },
11249
+ /* @__PURE__ */ React129.createElement(PieChart_default, null)
11250
+ )
11251
+ ),
11252
+ /* @__PURE__ */ React129.createElement(TableCell, { isCurrency: true, primary: true }, lineItem.value)
11253
+ ), expanded && lineItem.line_items ? lineItem.line_items.map(
11254
+ (child, i) => renderLineItem(
11255
+ child,
11256
+ depth + 1,
11257
+ child.display_name + "-" + rowIndex,
11258
+ i
11259
+ )
11260
+ ) : null);
11261
+ };
11262
+ return /* @__PURE__ */ React129.createElement(Table, { borderCollapse: "collapse", bottomSpacing: false }, /* @__PURE__ */ React129.createElement(TableBody, null, renderLineItem(
11263
+ data.income,
11264
+ 0,
11265
+ "income",
11266
+ 0,
11267
+ "revenue",
11268
+ setSidebarScope
11269
+ ), renderLineItem(
11270
+ data.cost_of_goods_sold,
11271
+ 0,
11272
+ "cost_of_goods_sold",
11273
+ 1,
11274
+ "expenses",
11275
+ setSidebarScope
11276
+ ), renderLineItem(
11084
11277
  {
11085
- lineItem: data.other_outflows,
11086
- direction: "DEBIT" /* DEBIT */,
11087
- lockExpanded
11088
- }
11089
- ), /* @__PURE__ */ React124.createElement(
11090
- ProfitAndLossRow,
11278
+ value: data.gross_profit,
11279
+ display_name: stringOverrides?.grossProfitLabel || "Gross Profit"
11280
+ },
11281
+ 0,
11282
+ "gross_profit",
11283
+ 2,
11284
+ "revenue",
11285
+ setSidebarScope,
11286
+ "summation"
11287
+ ), renderLineItem(
11288
+ data.expenses,
11289
+ 0,
11290
+ "expenses",
11291
+ 3,
11292
+ "expenses",
11293
+ setSidebarScope
11294
+ ), renderLineItem(
11091
11295
  {
11092
- lineItem: data.personal_expenses,
11093
- direction: "DEBIT" /* DEBIT */,
11094
- lockExpanded
11095
- }
11096
- )) : null);
11296
+ value: data.profit_before_taxes,
11297
+ display_name: stringOverrides?.profitBeforeTaxesLabel || "Profit Before Taxes"
11298
+ },
11299
+ 0,
11300
+ "profit_before_taxes",
11301
+ 4,
11302
+ "revenue",
11303
+ setSidebarScope,
11304
+ "summation"
11305
+ ), renderLineItem(data.taxes, 0, "taxes", 5, "expenses", setSidebarScope), renderLineItem(
11306
+ {
11307
+ value: data.net_profit,
11308
+ display_name: stringOverrides?.netProfitLabel || "Net Profit"
11309
+ },
11310
+ 0,
11311
+ "net_profit",
11312
+ 5,
11313
+ void 0,
11314
+ void 0,
11315
+ "summation"
11316
+ ), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ React129.createElement(React129.Fragment, null, renderLineItem(data.other_outflows, 0, "other_outflows", 6), renderLineItem(data.personal_expenses, 0, "personal_expenses", 7)) : null));
11317
+ };
11318
+
11319
+ // src/components/ProfitAndLossTable/ProfitAndLossTableWithProvider.tsx
11320
+ var ProfitAndLossTableWithProvider = (props) => {
11321
+ return /* @__PURE__ */ React130.createElement(TableProvider, null, /* @__PURE__ */ React130.createElement(ProfitAndLossTableComponent, { ...props }));
11097
11322
  };
11098
11323
 
11099
11324
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
11100
11325
  import { endOfMonth as endOfMonth8, startOfMonth as startOfMonth10 } from "date-fns";
11101
- var PNLContext = createContext6({
11326
+ var PNLContext = createContext7({
11102
11327
  data: void 0,
11103
11328
  filteredDataRevenue: [],
11104
11329
  filteredTotalRevenue: void 0,
@@ -11123,81 +11348,41 @@ var PNLContext = createContext6({
11123
11348
  setFilterTypes: () => {
11124
11349
  },
11125
11350
  filters: {
11126
- expenses: void 0,
11127
- revenue: void 0
11128
- }
11129
- });
11130
- var ProfitAndLoss = ({
11131
- children,
11132
- tagFilter,
11133
- reportingBasis,
11134
- asContainer = true
11135
- }) => {
11136
- const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
11137
- return /* @__PURE__ */ React125.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ React125.createElement(Container, { name: "profit-and-loss" }, children) : children);
11138
- };
11139
- ProfitAndLoss.Chart = ProfitAndLossChart;
11140
- ProfitAndLoss.Context = PNLContext;
11141
- ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
11142
- ProfitAndLoss.Summaries = ProfitAndLossSummaries;
11143
- ProfitAndLoss.Table = ProfitAndLossTable;
11144
- ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
11145
-
11146
- // src/components/BalanceSheet/BalanceSheet.tsx
11147
- import React138, { useEffect as useEffect30, useState as useState35 } from "react";
11148
-
11149
- // src/contexts/BalanceSheetContext/BalanceSheetContext.tsx
11150
- import { createContext as createContext7 } from "react";
11151
- var BalanceSheetContext = createContext7({
11152
- data: void 0,
11153
- isLoading: false,
11154
- error: void 0,
11155
- refetch: () => {
11156
- }
11157
- });
11158
-
11159
- // src/contexts/TableContext/TableContext.tsx
11160
- import React126, { createContext as createContext8, useState as useState33 } from "react";
11161
- var defaultValue = {
11162
- expandedRows: [],
11163
- setExpandedRows: () => {
11164
- },
11165
- expandAllRows: () => {
11166
- },
11167
- expandedAllRows: false,
11168
- setExpandedAllRows: () => {
11169
- }
11170
- };
11171
- var TableContext = createContext8(defaultValue);
11172
- var TableProvider = ({ children }) => {
11173
- const [expandedRows, setExpandedRowsState] = useState33([]);
11174
- const [expandedAllRows, setExpandedAllRows] = useState33(false);
11175
- const toggleRow = (rowKey) => {
11176
- setExpandedRowsState((prevRows) => {
11177
- const rows = [...prevRows];
11178
- if (rows.includes(rowKey)) {
11179
- rows.splice(rows.indexOf(rowKey), 1);
11180
- } else {
11181
- rows.push(rowKey);
11182
- }
11183
- return rows;
11184
- });
11185
- };
11186
- const expandAllRows = (rowKeys) => {
11187
- setExpandedRowsState(rowKeys);
11188
- };
11189
- const contextValue = {
11190
- expandedRows,
11191
- setExpandedRows: toggleRow,
11192
- expandAllRows,
11193
- expandedAllRows,
11194
- setExpandedAllRows
11195
- };
11196
- return /* @__PURE__ */ React126.createElement(TableContext.Provider, { value: contextValue }, children);
11351
+ expenses: void 0,
11352
+ revenue: void 0
11353
+ }
11354
+ });
11355
+ var ProfitAndLoss = ({
11356
+ children,
11357
+ tagFilter,
11358
+ reportingBasis,
11359
+ asContainer = true
11360
+ }) => {
11361
+ const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
11362
+ return /* @__PURE__ */ React131.createElement(PNLContext.Provider, { value: contextData }, asContainer ? /* @__PURE__ */ React131.createElement(Container, { name: "profit-and-loss" }, children) : children);
11197
11363
  };
11364
+ ProfitAndLoss.Chart = ProfitAndLossChart;
11365
+ ProfitAndLoss.Context = PNLContext;
11366
+ ProfitAndLoss.DatePicker = ProfitAndLossDatePicker;
11367
+ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
11368
+ ProfitAndLoss.Table = ProfitAndLossTableWithProvider;
11369
+ ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
11370
+
11371
+ // src/components/BalanceSheet/BalanceSheet.tsx
11372
+ import React138, { useEffect as useEffect31, useState as useState34 } from "react";
11373
+
11374
+ // src/contexts/BalanceSheetContext/BalanceSheetContext.tsx
11375
+ import { createContext as createContext8 } from "react";
11376
+ var BalanceSheetContext = createContext8({
11377
+ data: void 0,
11378
+ isLoading: false,
11379
+ error: void 0,
11380
+ refetch: () => {
11381
+ }
11382
+ });
11198
11383
 
11199
11384
  // src/hooks/useBalanceSheet/useBalanceSheet.tsx
11200
- import { useEffect as useEffect26 } from "react";
11385
+ import { useEffect as useEffect28 } from "react";
11201
11386
  import { format as format3, startOfDay } from "date-fns";
11202
11387
  import useSWR5 from "swr";
11203
11388
  var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
@@ -11216,12 +11401,12 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
11216
11401
  const refetch = () => {
11217
11402
  mutate();
11218
11403
  };
11219
- useEffect26(() => {
11404
+ useEffect28(() => {
11220
11405
  if (queryKey && (isLoading || isValidating)) {
11221
11406
  read("BALANCE_SHEET" /* BALANCE_SHEET */, queryKey);
11222
11407
  }
11223
11408
  }, [isLoading, isValidating]);
11224
- useEffect26(() => {
11409
+ useEffect28(() => {
11225
11410
  if (queryKey && hasBeenTouched(queryKey)) {
11226
11411
  refetch();
11227
11412
  }
@@ -11230,12 +11415,12 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
11230
11415
  };
11231
11416
 
11232
11417
  // src/components/BalanceSheetDatePicker/BalanceSheetDatePicker.tsx
11233
- import React127 from "react";
11418
+ import React132 from "react";
11234
11419
  var BalanceSheetDatePicker = ({
11235
11420
  effectiveDate,
11236
11421
  setEffectiveDate
11237
11422
  }) => {
11238
- return /* @__PURE__ */ React127.createElement(React127.Fragment, null, /* @__PURE__ */ React127.createElement(
11423
+ return /* @__PURE__ */ React132.createElement(React132.Fragment, null, /* @__PURE__ */ React132.createElement(
11239
11424
  DatePicker,
11240
11425
  {
11241
11426
  selected: effectiveDate,
@@ -11246,181 +11431,14 @@ var BalanceSheetDatePicker = ({
11246
11431
  };
11247
11432
 
11248
11433
  // src/components/BalanceSheetExpandAllButton/BalanceSheetExpandAllButton.tsx
11249
- import React128 from "react";
11250
-
11251
- // src/hooks/useTableExpandRow/useTableExpandRow.tsx
11252
- import { useContext as useContext17 } from "react";
11253
- var useTableExpandRow = () => {
11254
- const {
11255
- expandedAllRows,
11256
- setExpandedAllRows,
11257
- expandAllRows,
11258
- expandedRows,
11259
- setExpandedRows
11260
- } = useContext17(TableContext);
11261
- const toggleAllRows = () => {
11262
- if (expandedAllRows) {
11263
- setIsOpen([]);
11264
- return setExpandedAllRows(false);
11265
- } else {
11266
- return setExpandedAllRows(true);
11267
- }
11268
- };
11269
- const setIsOpen = (rowKey, withoutAllRowsUpdate) => {
11270
- if (!withoutAllRowsUpdate && expandedAllRows) {
11271
- setExpandedAllRows(false);
11272
- }
11273
- if (Array.isArray(rowKey)) {
11274
- return expandAllRows(rowKey);
11275
- }
11276
- return setExpandedRows(rowKey);
11277
- };
11278
- const isOpen = (rowKey) => expandedRows.includes(rowKey);
11279
- return {
11280
- isOpen,
11281
- setIsOpen,
11282
- expandedAllRows,
11283
- toggleAllRows
11284
- };
11285
- };
11286
-
11287
- // src/components/BalanceSheetExpandAllButton/BalanceSheetExpandAllButton.tsx
11434
+ import React133 from "react";
11288
11435
  var BalanceSheetExpandAllButton = () => {
11289
11436
  const { expandedAllRows, toggleAllRows } = useTableExpandRow();
11290
- return /* @__PURE__ */ React128.createElement(Button, { onClick: () => toggleAllRows(), variant: "secondary" /* secondary */ }, !expandedAllRows ? "Expand all rows" : "Collapse all rows");
11291
- };
11292
-
11293
- // src/components/BalanceSheetTable/BalanceSheetTable.tsx
11294
- import React134, { useEffect as useEffect28 } from "react";
11295
-
11296
- // src/components/TableBody/TableBody.tsx
11297
- import React129 from "react";
11298
- var TableBody = ({ children }) => {
11299
- return /* @__PURE__ */ React129.createElement("tbody", { className: "Layer__table-body" }, children);
11300
- };
11301
-
11302
- // src/components/TableCell/TableCell.tsx
11303
- import React130 from "react";
11304
- import classNames45 from "classnames";
11305
- var TableCell = ({
11306
- children,
11307
- isHeaderCell,
11308
- isCurrency,
11309
- primary,
11310
- withExpandIcon = false
11311
- }) => {
11312
- const amount = typeof children === "number" ? children : 0;
11313
- const isPositive = amount >= 0;
11314
- const amountString = centsToDollars(Math.abs(amount));
11315
- const cellClassNames = classNames45(
11316
- "Layer__table-cell",
11317
- (primary || isHeaderCell) && "Layer__table-cell--primary",
11318
- isCurrency && "Layer__table-cell-amount",
11319
- isCurrency && isPositive && "Layer__table-cell-amount--positive",
11320
- isCurrency && !isPositive && "Layer__table-cell-amount--negative"
11321
- );
11322
- if (isHeaderCell) {
11323
- return /* @__PURE__ */ React130.createElement("th", { className: cellClassNames }, /* @__PURE__ */ React130.createElement("span", { className: "Layer__table-cell-content" }, children));
11324
- }
11325
- return /* @__PURE__ */ React130.createElement("td", { className: cellClassNames }, /* @__PURE__ */ React130.createElement("span", { className: "Layer__table-cell-content" }, withExpandIcon && /* @__PURE__ */ React130.createElement(
11326
- ChevronDownFill_default,
11327
- {
11328
- className: "Layer__table-row--expand-icon",
11329
- size: 16
11330
- }
11331
- ), isCurrency ? amountString : children, " "));
11332
- };
11333
-
11334
- // src/components/TableHead/TableHead.tsx
11335
- import React131 from "react";
11336
- var TableHead = ({ children }) => {
11337
- return /* @__PURE__ */ React131.createElement("thead", { className: "Layer__table-header" }, children);
11338
- };
11339
-
11340
- // src/components/TableRow/TableRow.tsx
11341
- import React132 from "react";
11342
- import classNames46 from "classnames";
11343
- var TableRow = ({
11344
- rowKey,
11345
- children,
11346
- depth = 0,
11347
- expandable = false,
11348
- isExpanded = false,
11349
- handleExpand,
11350
- variant = expandable ? "expandable" : "default",
11351
- withDivider,
11352
- withDividerPosition = "top",
11353
- isHeadRow = false
11354
- }) => {
11355
- const toggleExpanded = () => {
11356
- if (variant === "summation" || !expandable)
11357
- return;
11358
- handleExpand && handleExpand();
11359
- };
11360
- const rowClassNames = classNames46([
11361
- "Layer__table-row",
11362
- !isHeadRow && `Layer__table-row--depth-${depth}`,
11363
- !isHeadRow && `Layer__table-row--variant-${variant}`,
11364
- !isHeadRow && expandable && (isExpanded ? "Layer__table-row--expanded" : "Layer__table-row--collapsed")
11365
- ]);
11366
- return /* @__PURE__ */ React132.createElement(React132.Fragment, null, withDivider && withDividerPosition === "top" && /* @__PURE__ */ React132.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ React132.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })), /* @__PURE__ */ React132.createElement("tr", { "data-key": rowKey, className: rowClassNames, onClick: toggleExpanded }, children), withDivider && withDividerPosition === "bottom" && /* @__PURE__ */ React132.createElement("tr", { className: "Layer__table-empty-row" }, /* @__PURE__ */ React132.createElement("td", { colSpan: Array.isArray(children) ? children.length : 1 })));
11367
- };
11368
-
11369
- // src/components/Table/Table.tsx
11370
- import React133, { useEffect as useEffect27, useRef as useRef15 } from "react";
11371
- import classNames47 from "classnames";
11372
- var Table = ({
11373
- componentName,
11374
- children,
11375
- borderCollapse = "separate",
11376
- bottomSpacing = true
11377
- }) => {
11378
- const tableRef = useRef15(null);
11379
- const prevChildrenRef = useRef15([]);
11380
- useEffect27(() => {
11381
- if (tableRef.current) {
11382
- const tbody = tableRef.current.querySelector("tbody");
11383
- const rows = tbody ? Array.from(tbody.querySelectorAll("tr")) : [];
11384
- const prevChildrenArray = prevChildrenRef.current;
11385
- const currentChildren = rows.map(
11386
- (child) => child.getAttribute("data-key") && {
11387
- key: child.getAttribute("data-key"),
11388
- child
11389
- }
11390
- );
11391
- const newChildrenKeys = [];
11392
- const newChildrenArray = currentChildren.filter((el) => {
11393
- if (el && el.key) {
11394
- newChildrenKeys.push(el.key);
11395
- }
11396
- return el && el.key && !prevChildrenArray.includes(el.key);
11397
- });
11398
- newChildrenArray.forEach((row, index) => {
11399
- const rowKey = row && row.key;
11400
- if (rowKey && !row.child.classList.contains("Layer__table-empty-row")) {
11401
- row.child.classList.add("Layer__table-row--anim-starting-state");
11402
- setTimeout(() => {
11403
- row.child.classList.add("Layer__table-row--anim-complete-state");
11404
- row.child.classList.remove("Layer__table-row--anim-starting-state");
11405
- }, 15 * index);
11406
- }
11407
- });
11408
- prevChildrenRef.current = newChildrenKeys;
11409
- }
11410
- }, [children]);
11411
- const tableWrapperClassNames = classNames47(
11412
- "Layer__table-wrapper",
11413
- bottomSpacing && "Layer__table-wrapper--bottom-spacing"
11414
- );
11415
- const tableClassNames = classNames47(
11416
- "Layer__table",
11417
- componentName && `Layer__${componentName}__table`,
11418
- borderCollapse && `Layer__table__${borderCollapse}-rows`
11419
- );
11420
- return /* @__PURE__ */ React133.createElement("div", { className: tableWrapperClassNames }, /* @__PURE__ */ React133.createElement("table", { className: tableClassNames, ref: tableRef }, children));
11437
+ return /* @__PURE__ */ React133.createElement(Button, { onClick: () => toggleAllRows(), variant: "secondary" /* secondary */ }, !expandedAllRows ? "Expand all rows" : "Collapse all rows");
11421
11438
  };
11422
11439
 
11423
11440
  // src/components/BalanceSheetTable/BalanceSheetTable.tsx
11441
+ import React134, { useEffect as useEffect29 } from "react";
11424
11442
  var BalanceSheetTable = ({
11425
11443
  data,
11426
11444
  config,
@@ -11428,12 +11446,12 @@ var BalanceSheetTable = ({
11428
11446
  }) => {
11429
11447
  const { isOpen, setIsOpen, expandedAllRows } = useTableExpandRow();
11430
11448
  const allRowKeys = [];
11431
- useEffect28(() => {
11449
+ useEffect29(() => {
11432
11450
  if (expandedAllRows) {
11433
11451
  setIsOpen(allRowKeys, true);
11434
11452
  }
11435
11453
  }, [expandedAllRows]);
11436
- useEffect28(() => {
11454
+ useEffect29(() => {
11437
11455
  setIsOpen(["assets"]);
11438
11456
  }, []);
11439
11457
  const renderLineItem = (lineItem, depth = 0, rowKey, rowIndex) => {
@@ -11498,8 +11516,8 @@ var ViewHeader = ({ title, controls }) => {
11498
11516
  };
11499
11517
 
11500
11518
  // src/components/Panel/Panel.tsx
11501
- import React136, { useEffect as useEffect29, useState as useState34 } from "react";
11502
- import classNames48 from "classnames";
11519
+ import React136, { useEffect as useEffect30, useState as useState33 } from "react";
11520
+ import classNames49 from "classnames";
11503
11521
  var Panel = ({
11504
11522
  children,
11505
11523
  className,
@@ -11509,20 +11527,20 @@ var Panel = ({
11509
11527
  parentRef,
11510
11528
  defaultSidebarHeight = false
11511
11529
  }) => {
11512
- const [sidebarHeight, setSidebarHeight] = useState34(0);
11513
- useEffect29(() => {
11530
+ const [sidebarHeight, setSidebarHeight] = useState33(0);
11531
+ useEffect30(() => {
11514
11532
  if (parentRef?.current?.offsetHeight) {
11515
11533
  setSidebarHeight(parentRef?.current?.offsetHeight - 1);
11516
11534
  }
11517
11535
  }, [parentRef?.current?.offsetHeight, sidebarIsOpen]);
11518
- const sidebarClass = classNames48(
11536
+ const sidebarClass = classNames49(
11519
11537
  "Layer__panel__sidebar",
11520
11538
  defaultSidebarHeight && "Layer__panel__sidebar--default"
11521
11539
  );
11522
11540
  return /* @__PURE__ */ React136.createElement(
11523
11541
  "div",
11524
11542
  {
11525
- className: classNames48(
11543
+ className: classNames49(
11526
11544
  "Layer__panel",
11527
11545
  className,
11528
11546
  sidebarIsOpen && "Layer__panel--open"
@@ -11543,7 +11561,7 @@ var Panel = ({
11543
11561
  };
11544
11562
 
11545
11563
  // src/components/View/View.tsx
11546
- import classNames49 from "classnames";
11564
+ import classNames50 from "classnames";
11547
11565
  var View = ({
11548
11566
  title,
11549
11567
  children,
@@ -11555,7 +11573,7 @@ var View = ({
11555
11573
  }) => {
11556
11574
  const { theme } = useLayerContext();
11557
11575
  const styles = parseStylesFromThemeConfig(theme);
11558
- const viewClassNames = classNames49(
11576
+ const viewClassNames = classNames50(
11559
11577
  "Layer__view",
11560
11578
  type === "panel" && "Layer__view--panel",
11561
11579
  viewClassName
@@ -11596,9 +11614,9 @@ var BalanceSheetView = ({
11596
11614
  asWidget = false,
11597
11615
  stringOverrides
11598
11616
  }) => {
11599
- const [effectiveDate, setEffectiveDate] = useState35(startOfDay2(/* @__PURE__ */ new Date()));
11617
+ const [effectiveDate, setEffectiveDate] = useState34(startOfDay2(/* @__PURE__ */ new Date()));
11600
11618
  const { data, isLoading, refetch } = useBalanceSheet(effectiveDate);
11601
- useEffect30(() => {
11619
+ useEffect31(() => {
11602
11620
  const d1 = effectiveDate && format4(startOfDay2(effectiveDate), "yyyy-MM-dd'T'HH:mm:ssXXX");
11603
11621
  const d2 = data?.effective_date && format4(
11604
11622
  startOfDay2(
@@ -11657,7 +11675,7 @@ var BalanceSheetView = ({
11657
11675
  };
11658
11676
 
11659
11677
  // src/components/StatementOfCashFlow/StatementOfCashFlow.tsx
11660
- import React140, { useState as useState36 } from "react";
11678
+ import React140, { useState as useState35 } from "react";
11661
11679
 
11662
11680
  // src/contexts/StatementOfCashContext/StatementOfCashFlowContext.tsx
11663
11681
  import { createContext as createContext9 } from "react";
@@ -11670,7 +11688,7 @@ var StatementOfCashFlowContext = createContext9({
11670
11688
  });
11671
11689
 
11672
11690
  // src/hooks/useStatementOfCashFlow/useStatementOfCashFlow.tsx
11673
- import { useEffect as useEffect31 } from "react";
11691
+ import { useEffect as useEffect32 } from "react";
11674
11692
  import { format as format5, startOfDay as startOfDay3 } from "date-fns";
11675
11693
  import useSWR6 from "swr";
11676
11694
  var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate = /* @__PURE__ */ new Date()) => {
@@ -11694,12 +11712,12 @@ var useStatementOfCashFlow = (startDate = /* @__PURE__ */ new Date(), endDate =
11694
11712
  const refetch = () => {
11695
11713
  mutate();
11696
11714
  };
11697
- useEffect31(() => {
11715
+ useEffect32(() => {
11698
11716
  if (queryKey && (isLoading || isValidating)) {
11699
11717
  read("STATEMENT_OF_CASH_FLOWS" /* STATEMENT_OF_CASH_FLOWS */, queryKey);
11700
11718
  }
11701
11719
  }, [isLoading, isValidating]);
11702
- useEffect31(() => {
11720
+ useEffect32(() => {
11703
11721
  if (queryKey && hasBeenTouched(queryKey)) {
11704
11722
  refetch();
11705
11723
  }
@@ -11815,10 +11833,10 @@ var StatementOfCashFlow = ({ stringOverrides }) => {
11815
11833
  return /* @__PURE__ */ React140.createElement(StatementOfCashFlowContext.Provider, { value: cashContextData }, /* @__PURE__ */ React140.createElement(StatementOfCashFlowView, { stringOverrides }));
11816
11834
  };
11817
11835
  var StatementOfCashFlowView = ({ stringOverrides }) => {
11818
- const [startDate, setStartDate] = useState36(
11836
+ const [startDate, setStartDate] = useState35(
11819
11837
  startOfDay4(subWeeks(/* @__PURE__ */ new Date(), 4))
11820
11838
  );
11821
- const [endDate, setEndDate] = useState36(startOfDay4(/* @__PURE__ */ new Date()));
11839
+ const [endDate, setEndDate] = useState35(startOfDay4(/* @__PURE__ */ new Date()));
11822
11840
  const { data, isLoading, refetch } = useStatementOfCashFlow(
11823
11841
  startDate,
11824
11842
  endDate
@@ -11860,7 +11878,7 @@ var StatementOfCashFlowView = ({ stringOverrides }) => {
11860
11878
  };
11861
11879
 
11862
11880
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
11863
- import React155, { useContext as useContext25, useState as useState43 } from "react";
11881
+ import React155, { useContext as useContext25, useState as useState42 } from "react";
11864
11882
 
11865
11883
  // src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
11866
11884
  import { createContext as createContext10 } from "react";
@@ -11919,7 +11937,7 @@ var LedgerAccountsContext = createContext11({
11919
11937
  });
11920
11938
 
11921
11939
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
11922
- import { useEffect as useEffect32, useState as useState37 } from "react";
11940
+ import { useEffect as useEffect33, useState as useState36 } from "react";
11923
11941
 
11924
11942
  // src/components/ChartOfAccountsForm/constants.ts
11925
11943
  var LEDGER_ACCOUNT_TYPES = [
@@ -12216,13 +12234,13 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
12216
12234
  syncTimestamps,
12217
12235
  hasBeenTouched
12218
12236
  } = useLayerContext();
12219
- const [form, setForm] = useState37();
12220
- const [sendingForm, setSendingForm] = useState37(false);
12221
- const [apiError, setApiError] = useState37(void 0);
12222
- const [startDate, setStartDate] = useState37(
12237
+ const [form, setForm] = useState36();
12238
+ const [sendingForm, setSendingForm] = useState36(false);
12239
+ const [apiError, setApiError] = useState36(void 0);
12240
+ const [startDate, setStartDate] = useState36(
12223
12241
  initialStartDate ?? startOfMonth12(Date.now())
12224
12242
  );
12225
- const [endDate, setEndDate] = useState37(
12243
+ const [endDate, setEndDate] = useState36(
12226
12244
  initialEndDate ?? endOfMonth10(Date.now())
12227
12245
  );
12228
12246
  const queryKey = businessId && auth?.access_token && `chart-of-accounts-${businessId}-${startDate?.valueOf()}-${endDate?.valueOf()}`;
@@ -12403,12 +12421,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
12403
12421
  newEndDate && setEndDate(newEndDate);
12404
12422
  };
12405
12423
  const refetch = () => mutate();
12406
- useEffect32(() => {
12424
+ useEffect33(() => {
12407
12425
  if (queryKey && (isLoading || isValidating)) {
12408
12426
  read("CHART_OF_ACCOUNTS" /* CHART_OF_ACCOUNTS */, queryKey);
12409
12427
  }
12410
12428
  }, [isLoading, isValidating]);
12411
- useEffect32(() => {
12429
+ useEffect33(() => {
12412
12430
  if (queryKey && hasBeenTouched(queryKey)) {
12413
12431
  refetch();
12414
12432
  }
@@ -12434,12 +12452,12 @@ var useChartOfAccounts = ({ withDates, startDate: initialStartDate, endDate: ini
12434
12452
  };
12435
12453
 
12436
12454
  // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
12437
- import { useEffect as useEffect33, useState as useState38 } from "react";
12455
+ import { useEffect as useEffect34, useState as useState37 } from "react";
12438
12456
  import useSWR8 from "swr";
12439
12457
  var useLedgerAccounts = () => {
12440
12458
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
12441
- const [accountId, setAccountId] = useState38();
12442
- const [selectedEntryId, setSelectedEntryId] = useState38();
12459
+ const [accountId, setAccountId] = useState37();
12460
+ const [selectedEntryId, setSelectedEntryId] = useState37();
12443
12461
  const queryKey = businessId && accountId && auth?.access_token && `ledger-accounts-lines-${businessId}-${accountId}`;
12444
12462
  const { data, isLoading, isValidating, error, mutate } = useSWR8(
12445
12463
  queryKey,
@@ -12464,12 +12482,12 @@ var useLedgerAccounts = () => {
12464
12482
  setSelectedEntryId(void 0);
12465
12483
  mutateEntryData();
12466
12484
  };
12467
- useEffect33(() => {
12485
+ useEffect34(() => {
12468
12486
  if (queryKey && (isLoading || isValidating)) {
12469
12487
  read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
12470
12488
  }
12471
12489
  }, [isLoading, isValidating]);
12472
- useEffect33(() => {
12490
+ useEffect34(() => {
12473
12491
  if (queryKey && hasBeenTouched(queryKey)) {
12474
12492
  refetch();
12475
12493
  }
@@ -12493,7 +12511,7 @@ var useLedgerAccounts = () => {
12493
12511
  };
12494
12512
 
12495
12513
  // src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
12496
- import React147, { useContext as useContext21, useState as useState40 } from "react";
12514
+ import React147, { useContext as useContext21, useState as useState39 } from "react";
12497
12515
 
12498
12516
  // src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
12499
12517
  import React141, { useContext as useContext18 } from "react";
@@ -12518,7 +12536,7 @@ var ChartOfAccountsDatePicker = () => {
12518
12536
  };
12519
12537
 
12520
12538
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
12521
- import React143, { useContext as useContext19, useEffect as useEffect34, useState as useState39 } from "react";
12539
+ import React143, { useContext as useContext19, useEffect as useEffect35, useState as useState38 } from "react";
12522
12540
 
12523
12541
  // src/icons/Edit2.tsx
12524
12542
  import * as React142 from "react";
@@ -12545,7 +12563,7 @@ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React142.createElement(
12545
12563
  var Edit2_default = Edit2;
12546
12564
 
12547
12565
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
12548
- import classNames50 from "classnames";
12566
+ import classNames51 from "classnames";
12549
12567
  var INDENTATION = 24;
12550
12568
  var EXPANDED_STYLE2 = {
12551
12569
  height: 52,
@@ -12579,7 +12597,7 @@ var ChartOfAccountsRow = ({
12579
12597
  const { form, editAccount } = useContext19(ChartOfAccountsContext);
12580
12598
  const { setAccountId } = useContext19(LedgerAccountsContext);
12581
12599
  const baseStyle = view === "desktop" ? EXPANDED_STYLE2 : EXPANDED_MOBILE_STYLE;
12582
- const [isOpen, setIsOpen] = useState39(defaultOpen);
12600
+ const [isOpen, setIsOpen] = useState38(defaultOpen);
12583
12601
  const style = expanded ? {
12584
12602
  ...baseStyle,
12585
12603
  transitionDelay: `${15 * index}ms`
@@ -12587,20 +12605,20 @@ var ChartOfAccountsRow = ({
12587
12605
  ...COLLAPSED_STYLE2,
12588
12606
  transitionDelay: `${acountsLength - 15 * index}ms`
12589
12607
  };
12590
- const [showComponent, setShowComponent] = useState39(false);
12591
- const [prevExpandedAll, setPrevExpandedAll] = useState39(expandAll);
12592
- useEffect34(() => {
12608
+ const [showComponent, setShowComponent] = useState38(false);
12609
+ const [prevExpandedAll, setPrevExpandedAll] = useState38(expandAll);
12610
+ useEffect35(() => {
12593
12611
  const timeoutId = setTimeout(() => {
12594
12612
  setShowComponent(true);
12595
12613
  }, cumulativeIndex * 50);
12596
12614
  return () => clearTimeout(timeoutId);
12597
12615
  }, []);
12598
- useEffect34(() => {
12616
+ useEffect35(() => {
12599
12617
  if (prevExpandedAll !== expandAll && expandAll) {
12600
12618
  setIsOpen(expandAll === "collapsed" ? false : true);
12601
12619
  }
12602
12620
  }, [expandAll]);
12603
- const baseClass = classNames50(
12621
+ const baseClass = classNames51(
12604
12622
  "Layer__table-row",
12605
12623
  isOpen ? "Layer__table-row--expanded" : "Layer__table-row--collapsed",
12606
12624
  !expanded && "Layer__table-row--hidden",
@@ -12608,11 +12626,11 @@ var ChartOfAccountsRow = ({
12608
12626
  form?.accountId === account.id && "Layer__table-row--active",
12609
12627
  !showComponent && "Layer__table-row--anim-starting-state"
12610
12628
  );
12611
- const desktopRowClass = classNames50(
12629
+ const desktopRowClass = classNames51(
12612
12630
  baseClass,
12613
12631
  "Layer__chart-of-accounts__row---desktop"
12614
12632
  );
12615
- const mobileRowClass = classNames50(
12633
+ const mobileRowClass = classNames51(
12616
12634
  baseClass,
12617
12635
  "Layer__chart-of-accounts__row---mobile"
12618
12636
  );
@@ -12953,7 +12971,7 @@ var ChartOfAccountsTable = ({
12953
12971
  stringOverrides
12954
12972
  }) => {
12955
12973
  const { data, isLoading, addAccount, error, isValidating, refetch, form } = useContext21(ChartOfAccountsContext);
12956
- const [expandAll, setExpandAll] = useState40();
12974
+ const [expandAll, setExpandAll] = useState39();
12957
12975
  let cumulativeIndex = 0;
12958
12976
  const accountsLength = data?.accounts.length ?? 0;
12959
12977
  return /* @__PURE__ */ React147.createElement(
@@ -13047,9 +13065,9 @@ var ChartOfAccountsTable = ({
13047
13065
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
13048
13066
  import React154, {
13049
13067
  useContext as useContext24,
13050
- useEffect as useEffect36,
13068
+ useEffect as useEffect37,
13051
13069
  useMemo as useMemo15,
13052
- useState as useState42
13070
+ useState as useState41
13053
13071
  } from "react";
13054
13072
 
13055
13073
  // src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
@@ -13057,9 +13075,9 @@ import React152, { useContext as useContext22, useMemo as useMemo14 } from "reac
13057
13075
 
13058
13076
  // src/components/Card/Card.tsx
13059
13077
  import React148 from "react";
13060
- import classNames51 from "classnames";
13078
+ import classNames52 from "classnames";
13061
13079
  var Card = ({ children, className }) => {
13062
- return /* @__PURE__ */ React148.createElement("div", { className: classNames51("Layer__card", className) }, children);
13080
+ return /* @__PURE__ */ React148.createElement("div", { className: classNames52("Layer__card", className) }, children);
13063
13081
  };
13064
13082
 
13065
13083
  // src/components/DateTime/DateTime.tsx
@@ -13101,14 +13119,14 @@ var DateTime = ({
13101
13119
 
13102
13120
  // src/components/DetailsList/DetailsList.tsx
13103
13121
  import React150 from "react";
13104
- import classNames52 from "classnames";
13122
+ import classNames53 from "classnames";
13105
13123
  var DetailsList = ({
13106
13124
  title,
13107
13125
  children,
13108
13126
  className,
13109
13127
  actions
13110
13128
  }) => {
13111
- return /* @__PURE__ */ React150.createElement("div", { className: classNames52("Layer__details-list", className) }, title && /* @__PURE__ */ React150.createElement(Header, null, /* @__PURE__ */ React150.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ React150.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ React150.createElement("ul", { className: "Layer__details-list__list" }, children));
13129
+ return /* @__PURE__ */ React150.createElement("div", { className: classNames53("Layer__details-list", className) }, title && /* @__PURE__ */ React150.createElement(Header, null, /* @__PURE__ */ React150.createElement(Heading, { size: "secondary" /* secondary */ }, title), actions && /* @__PURE__ */ React150.createElement("div", { className: "Layer__details-list__actions" }, actions)), /* @__PURE__ */ React150.createElement("ul", { className: "Layer__details-list__list" }, children));
13112
13130
  };
13113
13131
 
13114
13132
  // src/components/DetailsList/DetailsListItem.tsx
@@ -13240,8 +13258,8 @@ var LedgerAccountEntryDetails = ({ stringOverrides }) => {
13240
13258
  };
13241
13259
 
13242
13260
  // src/components/LedgerAccount/LedgerAccountRow.tsx
13243
- import React153, { useContext as useContext23, useEffect as useEffect35, useState as useState41 } from "react";
13244
- import classNames53 from "classnames";
13261
+ import React153, { useContext as useContext23, useEffect as useEffect36, useState as useState40 } from "react";
13262
+ import classNames54 from "classnames";
13245
13263
  import { parseISO as parseISO14, format as formatTime10 } from "date-fns";
13246
13264
  var LedgerAccountRow = ({
13247
13265
  row,
@@ -13250,8 +13268,8 @@ var LedgerAccountRow = ({
13250
13268
  view
13251
13269
  }) => {
13252
13270
  const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext23(LedgerAccountsContext);
13253
- const [showComponent, setShowComponent] = useState41(false);
13254
- useEffect35(() => {
13271
+ const [showComponent, setShowComponent] = useState40(false);
13272
+ useEffect36(() => {
13255
13273
  if (initialLoad) {
13256
13274
  const timeoutId = setTimeout(() => {
13257
13275
  setShowComponent(true);
@@ -13265,7 +13283,7 @@ var LedgerAccountRow = ({
13265
13283
  return /* @__PURE__ */ React153.createElement(
13266
13284
  "tr",
13267
13285
  {
13268
- className: classNames53(
13286
+ className: classNames54(
13269
13287
  "Layer__table-row",
13270
13288
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13271
13289
  initialLoad && "initial-load",
@@ -13298,7 +13316,7 @@ var LedgerAccountRow = ({
13298
13316
  return /* @__PURE__ */ React153.createElement(
13299
13317
  "tr",
13300
13318
  {
13301
- className: classNames53(
13319
+ className: classNames54(
13302
13320
  "Layer__table-row",
13303
13321
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13304
13322
  initialLoad && "initial-load",
@@ -13327,7 +13345,7 @@ var LedgerAccountRow = ({
13327
13345
  return /* @__PURE__ */ React153.createElement(
13328
13346
  "tr",
13329
13347
  {
13330
- className: classNames53(
13348
+ className: classNames54(
13331
13349
  "Layer__table-row",
13332
13350
  row.entry_id === selectedEntryId && "Layer__table-row--active",
13333
13351
  initialLoad && "initial-load",
@@ -13353,15 +13371,15 @@ var LedgerAccountRow = ({
13353
13371
  };
13354
13372
 
13355
13373
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
13356
- import classNames54 from "classnames";
13374
+ import classNames55 from "classnames";
13357
13375
  var LedgerAccount = ({
13358
13376
  containerRef,
13359
13377
  pageSize = 15,
13360
13378
  view,
13361
13379
  stringOverrides
13362
13380
  }) => {
13363
- const [currentPage, setCurrentPage] = useState42(1);
13364
- const [initialLoad, setInitialLoad] = useState42(true);
13381
+ const [currentPage, setCurrentPage] = useState41(1);
13382
+ const [initialLoad, setInitialLoad] = useState41(true);
13365
13383
  const { data: accountData } = useContext24(ChartOfAccountsContext);
13366
13384
  const {
13367
13385
  data: rawData,
@@ -13374,7 +13392,7 @@ var LedgerAccount = ({
13374
13392
  closeSelectedEntry,
13375
13393
  refetch
13376
13394
  } = useContext24(LedgerAccountsContext);
13377
- useEffect36(() => {
13395
+ useEffect37(() => {
13378
13396
  if (!isLoading) {
13379
13397
  const timeoutLoad = setTimeout(() => {
13380
13398
  setInitialLoad(false);
@@ -13382,7 +13400,7 @@ var LedgerAccount = ({
13382
13400
  return () => clearTimeout(timeoutLoad);
13383
13401
  }
13384
13402
  }, [isLoading]);
13385
- const baseClassName = classNames54(
13403
+ const baseClassName = classNames55(
13386
13404
  "Layer__ledger-account__index",
13387
13405
  accountId && "open"
13388
13406
  );
@@ -13488,7 +13506,7 @@ var ChartOfAccountsContent = ({
13488
13506
  stringOverrides
13489
13507
  }) => {
13490
13508
  const { accountId } = useContext25(LedgerAccountsContext);
13491
- const [view, setView] = useState43("desktop");
13509
+ const [view, setView] = useState42("desktop");
13492
13510
  const containerRef = useElementSize((_a, _b, { width }) => {
13493
13511
  if (width) {
13494
13512
  if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
@@ -13514,7 +13532,7 @@ var ChartOfAccountsContent = ({
13514
13532
  };
13515
13533
 
13516
13534
  // src/components/Journal/Journal.tsx
13517
- import React162, { useState as useState47 } from "react";
13535
+ import React162, { useState as useState46 } from "react";
13518
13536
 
13519
13537
  // src/contexts/JournalContext/JournalContext.tsx
13520
13538
  import { createContext as createContext12 } from "react";
@@ -13551,7 +13569,7 @@ var JournalContext = createContext12({
13551
13569
  });
13552
13570
 
13553
13571
  // src/hooks/useJournal/useJournal.tsx
13554
- import { useEffect as useEffect37, useState as useState44 } from "react";
13572
+ import { useEffect as useEffect38, useState as useState43 } from "react";
13555
13573
 
13556
13574
  // src/utils/journal.ts
13557
13575
  var getAccountIdentifierPayload = (journalLineItem) => {
@@ -13582,11 +13600,11 @@ var useJournal = () => {
13582
13600
  syncTimestamps,
13583
13601
  hasBeenTouched
13584
13602
  } = useLayerContext();
13585
- const [selectedEntryId, setSelectedEntryId] = useState44();
13586
- const [form, setForm] = useState44();
13587
- const [addingEntry, setAddingEntry] = useState44(false);
13588
- const [sendingForm, setSendingForm] = useState44(false);
13589
- const [apiError, setApiError] = useState44(void 0);
13603
+ const [selectedEntryId, setSelectedEntryId] = useState43();
13604
+ const [form, setForm] = useState43();
13605
+ const [addingEntry, setAddingEntry] = useState43(false);
13606
+ const [sendingForm, setSendingForm] = useState43(false);
13607
+ const [apiError, setApiError] = useState43(void 0);
13590
13608
  const queryKey = businessId && auth?.access_token && `journal-lines-${businessId}`;
13591
13609
  const { data, isLoading, isValidating, error, mutate } = useSWR9(
13592
13610
  queryKey,
@@ -13812,12 +13830,12 @@ var useJournal = () => {
13812
13830
  }
13813
13831
  });
13814
13832
  };
13815
- useEffect37(() => {
13833
+ useEffect38(() => {
13816
13834
  if (queryKey && (isLoading || isValidating)) {
13817
13835
  read("JOURNAL" /* JOURNAL */, queryKey);
13818
13836
  }
13819
13837
  }, [isLoading, isValidating]);
13820
- useEffect37(() => {
13838
+ useEffect38(() => {
13821
13839
  if (queryKey && hasBeenTouched(queryKey)) {
13822
13840
  refetch();
13823
13841
  }
@@ -13848,11 +13866,11 @@ var useJournal = () => {
13848
13866
  };
13849
13867
 
13850
13868
  // src/components/JournalTable/JournalTable.tsx
13851
- import React161, { useContext as useContext31, useMemo as useMemo17, useState as useState46 } from "react";
13869
+ import React161, { useContext as useContext31, useMemo as useMemo17, useState as useState45 } from "react";
13852
13870
 
13853
13871
  // src/components/JournalRow/JournalRow.tsx
13854
- import React156, { useContext as useContext26, useEffect as useEffect38, useState as useState45 } from "react";
13855
- import classNames55 from "classnames";
13872
+ import React156, { useContext as useContext26, useEffect as useEffect39, useState as useState44 } from "react";
13873
+ import classNames56 from "classnames";
13856
13874
  import { parseISO as parseISO15, format as formatTime11 } from "date-fns";
13857
13875
  var INDENTATION2 = 24;
13858
13876
  var EXPANDED_STYLE3 = {
@@ -13890,7 +13908,7 @@ var JournalRow = ({
13890
13908
  selectedEntries = false
13891
13909
  }) => {
13892
13910
  const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = useContext26(JournalContext);
13893
- const [isOpen, setIsOpen] = useState45(index === 0 ? true : defaultOpen);
13911
+ const [isOpen, setIsOpen] = useState44(index === 0 ? true : defaultOpen);
13894
13912
  const style = expanded ? {
13895
13913
  ...EXPANDED_STYLE3,
13896
13914
  transitionDelay: `${15 * index}ms`
@@ -13898,8 +13916,8 @@ var JournalRow = ({
13898
13916
  ...COLLAPSED_STYLE3,
13899
13917
  transitionDelay: `${lineItemsLength - 15 * index}ms`
13900
13918
  };
13901
- const [showComponent, setShowComponent] = useState45(false);
13902
- const baseClass = classNames55(
13919
+ const [showComponent, setShowComponent] = useState44(false);
13920
+ const baseClass = classNames56(
13903
13921
  "Layer__journal-table-row",
13904
13922
  rowId(row) === selectedEntryId && "Layer__table-row--active",
13905
13923
  initialLoad && "initial-load",
@@ -13907,7 +13925,7 @@ var JournalRow = ({
13907
13925
  showComponent ? "show" : "Layer__table-row--anim-starting-state",
13908
13926
  isOpen && "Layer__journal__table-row--expanded"
13909
13927
  );
13910
- const journalEntryLineClass = classNames55(
13928
+ const journalEntryLineClass = classNames56(
13911
13929
  "Layer__journal-entry-table-row",
13912
13930
  selectedEntries && "Layer__table-row--active",
13913
13931
  initialLoad && "initial-load",
@@ -13916,7 +13934,7 @@ var JournalRow = ({
13916
13934
  "Layer__journal-line__table-row",
13917
13935
  !expanded && "Layer__table-row--hidden"
13918
13936
  );
13919
- useEffect38(() => {
13937
+ useEffect39(() => {
13920
13938
  if (initialLoad) {
13921
13939
  const timeoutId = setTimeout(() => {
13922
13940
  setShowComponent(true);
@@ -14384,7 +14402,7 @@ var JournalTable = ({
14384
14402
  config,
14385
14403
  stringOverrides
14386
14404
  }) => {
14387
- const [currentPage, setCurrentPage] = useState46(1);
14405
+ const [currentPage, setCurrentPage] = useState45(1);
14388
14406
  const {
14389
14407
  data: rawData,
14390
14408
  isLoading,
@@ -14457,7 +14475,7 @@ var JournalContent = ({
14457
14475
  config = JOURNAL_CONFIG,
14458
14476
  stringOverrides
14459
14477
  }) => {
14460
- const [view, setView] = useState47("desktop");
14478
+ const [view, setView] = useState46("desktop");
14461
14479
  const containerRef = useElementSize((_a, _b, { width }) => {
14462
14480
  if (width) {
14463
14481
  if (width >= BREAKPOINTS.TABLET && view !== "desktop") {
@@ -14484,9 +14502,9 @@ var JournalContent = ({
14484
14502
  import React169, {
14485
14503
  createContext as createContext14,
14486
14504
  useContext as useContext36,
14487
- useEffect as useEffect42,
14505
+ useEffect as useEffect43,
14488
14506
  useMemo as useMemo19,
14489
- useState as useState51
14507
+ useState as useState50
14490
14508
  } from "react";
14491
14509
 
14492
14510
  // src/contexts/TasksContext/TasksContext.tsx
@@ -14503,10 +14521,10 @@ var TasksContext = createContext13({
14503
14521
  });
14504
14522
 
14505
14523
  // src/hooks/useTasks/useTasks.tsx
14506
- import { useEffect as useEffect39, useState as useState48 } from "react";
14524
+ import { useEffect as useEffect40, useState as useState47 } from "react";
14507
14525
  import useSWR10 from "swr";
14508
14526
  var useTasks = () => {
14509
- const [loadedStatus, setLoadedStatus] = useState48("initial");
14527
+ const [loadedStatus, setLoadedStatus] = useState47("initial");
14510
14528
  const { auth, businessId, apiUrl, read, syncTimestamps, hasBeenTouched } = useLayerContext();
14511
14529
  const queryKey = businessId && auth?.access_token && `tasks-${businessId}`;
14512
14530
  const { data, isLoading, isValidating, error, mutate } = useSWR10(
@@ -14515,7 +14533,7 @@ var useTasks = () => {
14515
14533
  params: { businessId }
14516
14534
  })
14517
14535
  );
14518
- useEffect39(() => {
14536
+ useEffect40(() => {
14519
14537
  if (isLoading && loadedStatus === "initial") {
14520
14538
  setLoadedStatus("loading");
14521
14539
  } else if (!isLoading && loadedStatus === "loading") {
@@ -14535,12 +14553,12 @@ var useTasks = () => {
14535
14553
  body: data2
14536
14554
  }).then(() => refetch());
14537
14555
  };
14538
- useEffect39(() => {
14556
+ useEffect40(() => {
14539
14557
  if (queryKey && (isLoading || isValidating)) {
14540
14558
  read("TASKS" /* TASKS */, queryKey);
14541
14559
  }
14542
14560
  }, [isLoading, isValidating]);
14543
- useEffect39(() => {
14561
+ useEffect40(() => {
14544
14562
  if (queryKey && hasBeenTouched(queryKey)) {
14545
14563
  refetch();
14546
14564
  }
@@ -14696,7 +14714,7 @@ var TasksHeader = ({
14696
14714
  };
14697
14715
 
14698
14716
  // src/components/TasksList/TasksList.tsx
14699
- import React167, { useContext as useContext34, useMemo as useMemo18, useState as useState50 } from "react";
14717
+ import React167, { useContext as useContext34, useMemo as useMemo18, useState as useState49 } from "react";
14700
14718
 
14701
14719
  // src/icons/SmileIcon.tsx
14702
14720
  import * as React165 from "react";
@@ -14750,30 +14768,30 @@ var SmileIcon = ({ size = 12, ...props }) => /* @__PURE__ */ React165.createElem
14750
14768
  var SmileIcon_default = SmileIcon;
14751
14769
 
14752
14770
  // src/components/TasksListItem/TasksListItem.tsx
14753
- import React166, { useContext as useContext33, useEffect as useEffect40, useState as useState49 } from "react";
14754
- import classNames56 from "classnames";
14771
+ import React166, { useContext as useContext33, useEffect as useEffect41, useState as useState48 } from "react";
14772
+ import classNames57 from "classnames";
14755
14773
  var TasksListItem = ({
14756
14774
  task,
14757
14775
  goToNextPageIfAllComplete,
14758
14776
  defaultOpen
14759
14777
  }) => {
14760
- const [isOpen, setIsOpen] = useState49(defaultOpen);
14761
- const [userResponse, setUserResponse] = useState49(task.user_response || "");
14778
+ const [isOpen, setIsOpen] = useState48(defaultOpen);
14779
+ const [userResponse, setUserResponse] = useState48(task.user_response || "");
14762
14780
  const { submitResponseToTask: submitResponseToTask2 } = useContext33(TasksContext);
14763
- const taskBodyClassName = classNames56(
14781
+ const taskBodyClassName = classNames57(
14764
14782
  "Layer__tasks-list-item__body",
14765
14783
  isOpen && "Layer__tasks-list-item__body--expanded",
14766
14784
  isComplete(task.status) && "Layer__tasks-list-item--completed"
14767
14785
  );
14768
- const taskHeadClassName = classNames56(
14786
+ const taskHeadClassName = classNames57(
14769
14787
  "Layer__tasks-list-item__head-info",
14770
14788
  isComplete(task.status) ? "Layer__tasks-list-item--completed" : "Layer__tasks-list-item--pending"
14771
14789
  );
14772
- const taskItemClassName = classNames56(
14790
+ const taskItemClassName = classNames57(
14773
14791
  "Layer__tasks-list-item",
14774
14792
  isOpen && "Layer__tasks-list-item__expanded"
14775
14793
  );
14776
- useEffect40(() => {
14794
+ useEffect41(() => {
14777
14795
  setIsOpen(defaultOpen);
14778
14796
  }, [defaultOpen]);
14779
14797
  return /* @__PURE__ */ React166.createElement("div", { className: "Layer__tasks-list-item-wrapper" }, /* @__PURE__ */ React166.createElement("div", { className: taskItemClassName }, /* @__PURE__ */ React166.createElement(
@@ -14830,7 +14848,7 @@ var TasksList = ({ pageSize = 10 }) => {
14830
14848
  tasks || [],
14831
14849
  pageSize
14832
14850
  ).findIndex((page) => page.some((task) => !isComplete(task.status)));
14833
- const [currentPage, setCurrentPage] = useState50(
14851
+ const [currentPage, setCurrentPage] = useState49(
14834
14852
  firstPageWithIincompleteTasks === -1 ? 1 : firstPageWithIincompleteTasks + 1
14835
14853
  );
14836
14854
  const sortedTasks = useMemo18(() => {
@@ -14868,7 +14886,7 @@ var TasksList = ({ pageSize = 10 }) => {
14868
14886
 
14869
14887
  // src/components/TasksPending/TasksPending.tsx
14870
14888
  import React168, { useContext as useContext35 } from "react";
14871
- import classNames57 from "classnames";
14889
+ import classNames58 from "classnames";
14872
14890
  import { format as format6 } from "date-fns";
14873
14891
  import { Cell as Cell4, Pie as Pie3, PieChart as PieChart4 } from "recharts";
14874
14892
  var TasksPending = () => {
@@ -14884,7 +14902,7 @@ var TasksPending = () => {
14884
14902
  value: data?.filter((task) => !isComplete(task.status)).length
14885
14903
  }
14886
14904
  ];
14887
- const taskStatusClassName = classNames57(
14905
+ const taskStatusClassName = classNames58(
14888
14906
  completedTasks && completedTasks > 0 ? "Layer__tasks-pending-bar__status--done" : "Layer__tasks-pending-bar__status--pending"
14889
14907
  );
14890
14908
  return /* @__PURE__ */ React168.createElement("div", { className: "Layer__tasks-pending" }, /* @__PURE__ */ React168.createElement(Text, { size: "lg" /* lg */ }, format6(Date.now(), "MMMM")), /* @__PURE__ */ React168.createElement("div", { className: "Layer__tasks-pending-bar" }, /* @__PURE__ */ React168.createElement(Text, { size: "sm" /* sm */ }, /* @__PURE__ */ React168.createElement("span", { className: taskStatusClassName }, completedTasks), "/", data?.length, " done"), /* @__PURE__ */ React168.createElement(PieChart4, { width: 24, height: 24, className: "mini-chart" }, /* @__PURE__ */ React168.createElement(
@@ -14918,7 +14936,7 @@ var TasksPending = () => {
14918
14936
  };
14919
14937
 
14920
14938
  // src/components/Tasks/Tasks.tsx
14921
- import classNames58 from "classnames";
14939
+ import classNames59 from "classnames";
14922
14940
  var UseTasksContext = createContext14({
14923
14941
  data: void 0,
14924
14942
  isLoading: void 0,
@@ -14971,10 +14989,10 @@ var TasksComponent = ({
14971
14989
  }
14972
14990
  return false;
14973
14991
  }, [data, isLoading]);
14974
- const [open, setOpen] = useState51(
14992
+ const [open, setOpen] = useState50(
14975
14993
  defaultCollapsed || collapsedWhenComplete ? false : true
14976
14994
  );
14977
- useEffect42(() => {
14995
+ useEffect43(() => {
14978
14996
  if (allComplete && open && collapsedWhenComplete && loadedStatus === "complete") {
14979
14997
  setOpen(false);
14980
14998
  }
@@ -14990,7 +15008,7 @@ var TasksComponent = ({
14990
15008
  ), /* @__PURE__ */ React169.createElement(
14991
15009
  "div",
14992
15010
  {
14993
- className: classNames58(
15011
+ className: classNames59(
14994
15012
  "Layer__tasks__content",
14995
15013
  !open && "Layer__tasks__content--collapsed"
14996
15014
  )
@@ -15089,14 +15107,14 @@ var BookkeepingUpsellBar = ({
15089
15107
  };
15090
15108
 
15091
15109
  // src/views/BookkeepingOverview/BookkeepingOverview.tsx
15092
- import React173, { useState as useState52 } from "react";
15093
- import classNames59 from "classnames";
15110
+ import React173, { useState as useState51 } from "react";
15111
+ import classNames60 from "classnames";
15094
15112
  var BookkeepingOverview = ({
15095
15113
  title,
15096
15114
  // deprecated
15097
15115
  stringOverrides
15098
15116
  }) => {
15099
- const [pnlToggle, setPnlToggle] = useState52("expenses");
15117
+ const [pnlToggle, setPnlToggle] = useState51("expenses");
15100
15118
  const [width] = useWindowSize();
15101
15119
  return /* @__PURE__ */ React173.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React173.createElement(TasksProvider, null, /* @__PURE__ */ React173.createElement(
15102
15120
  View,
@@ -15150,7 +15168,7 @@ var BookkeepingOverview = ({
15150
15168
  ), /* @__PURE__ */ React173.createElement(
15151
15169
  Container,
15152
15170
  {
15153
- name: classNames59(
15171
+ name: classNames60(
15154
15172
  "bookkeeping-overview-profit-and-loss-chart",
15155
15173
  pnlToggle !== "revenue" && "bookkeeping-overview-profit-and-loss-chart--hidden"
15156
15174
  )
@@ -15166,7 +15184,7 @@ var BookkeepingOverview = ({
15166
15184
  ), /* @__PURE__ */ React173.createElement(
15167
15185
  Container,
15168
15186
  {
15169
- name: classNames59(
15187
+ name: classNames60(
15170
15188
  "bookkeeping-overview-profit-and-loss-chart",
15171
15189
  pnlToggle !== "expenses" && "bookkeeping-overview-profit-and-loss-chart--hidden"
15172
15190
  )
@@ -15184,10 +15202,10 @@ var BookkeepingOverview = ({
15184
15202
  };
15185
15203
 
15186
15204
  // src/views/AccountingOverview/AccountingOverview.tsx
15187
- import React177, { useState as useState54 } from "react";
15205
+ import React177, { useState as useState53 } from "react";
15188
15206
 
15189
15207
  // src/components/TransactionToReviewCard/TransactionToReviewCard.tsx
15190
- import React176, { useContext as useContext37, useEffect as useEffect43, useState as useState53 } from "react";
15208
+ import React176, { useContext as useContext37, useEffect as useEffect44, useState as useState52 } from "react";
15191
15209
 
15192
15210
  // src/components/BadgeLoader/BadgeLoader.tsx
15193
15211
  import React174 from "react";
@@ -15197,13 +15215,13 @@ var BadgeLoader = ({ children }) => {
15197
15215
 
15198
15216
  // src/components/NotificationCard/NotificationCard.tsx
15199
15217
  import React175 from "react";
15200
- import classNames60 from "classnames";
15218
+ import classNames61 from "classnames";
15201
15219
  var NotificationCard = ({
15202
15220
  onClick,
15203
15221
  children,
15204
15222
  className
15205
15223
  }) => {
15206
- return /* @__PURE__ */ React175.createElement("div", { className: classNames60("Layer__notification-card", className) }, /* @__PURE__ */ React175.createElement("div", { className: "Layer__notification-card__main" }, children), /* @__PURE__ */ React175.createElement(
15224
+ return /* @__PURE__ */ React175.createElement("div", { className: classNames61("Layer__notification-card", className) }, /* @__PURE__ */ React175.createElement("div", { className: "Layer__notification-card__main" }, children), /* @__PURE__ */ React175.createElement(
15207
15225
  IconButton,
15208
15226
  {
15209
15227
  icon: /* @__PURE__ */ React175.createElement(ChevronRight_default, null),
@@ -15221,14 +15239,14 @@ var TransactionToReviewCard = ({
15221
15239
  }) => {
15222
15240
  const { dateRange: contextDateRange } = useContext37(ProfitAndLoss.Context);
15223
15241
  const dateRange = usePnlDateRange ? contextDateRange : void 0;
15224
- const [toReview, setToReview] = useState53(0);
15242
+ const [toReview, setToReview] = useState52(0);
15225
15243
  const { data, loaded, error, refetch } = useProfitAndLossLTM({
15226
15244
  currentDate: dateRange ? dateRange.startDate : startOfMonth14(/* @__PURE__ */ new Date())
15227
15245
  });
15228
- useEffect43(() => {
15246
+ useEffect44(() => {
15229
15247
  checkTransactionsToReview();
15230
15248
  }, []);
15231
- useEffect43(() => {
15249
+ useEffect44(() => {
15232
15250
  checkTransactionsToReview();
15233
15251
  }, [dateRange, loaded]);
15234
15252
  const checkTransactionsToReview = () => {
@@ -15282,7 +15300,7 @@ var TransactionToReviewCard = ({
15282
15300
  };
15283
15301
 
15284
15302
  // src/views/AccountingOverview/AccountingOverview.tsx
15285
- import classNames61 from "classnames";
15303
+ import classNames62 from "classnames";
15286
15304
  var AccountingOverview = ({
15287
15305
  title = "Accounting overview",
15288
15306
  enableOnboarding = false,
@@ -15291,7 +15309,7 @@ var AccountingOverview = ({
15291
15309
  chartColorsList,
15292
15310
  stringOverrides
15293
15311
  }) => {
15294
- const [pnlToggle, setPnlToggle] = useState54("expenses");
15312
+ const [pnlToggle, setPnlToggle] = useState53("expenses");
15295
15313
  return /* @__PURE__ */ React177.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React177.createElement(View, { title, headerControls: /* @__PURE__ */ React177.createElement(ProfitAndLoss.DatePicker, null) }, enableOnboarding && /* @__PURE__ */ React177.createElement(
15296
15314
  Onboarding,
15297
15315
  {
@@ -15337,7 +15355,7 @@ var AccountingOverview = ({
15337
15355
  ), /* @__PURE__ */ React177.createElement(
15338
15356
  Container,
15339
15357
  {
15340
- name: classNames61(
15358
+ name: classNames62(
15341
15359
  "accounting-overview-profit-and-loss-chart",
15342
15360
  pnlToggle !== "revenue" && "accounting-overview-profit-and-loss-chart--hidden"
15343
15361
  )
@@ -15354,7 +15372,7 @@ var AccountingOverview = ({
15354
15372
  ), /* @__PURE__ */ React177.createElement(
15355
15373
  Container,
15356
15374
  {
15357
- name: classNames61(
15375
+ name: classNames62(
15358
15376
  "accounting-overview-profit-and-loss-chart",
15359
15377
  pnlToggle !== "expenses" && "accounting-overview-profit-and-loss-chart--hidden"
15360
15378
  )
@@ -15409,13 +15427,13 @@ var BankTransactionsWithLinkedAccounts = ({
15409
15427
  };
15410
15428
 
15411
15429
  // src/views/GeneralLedger/GeneralLedger.tsx
15412
- import React179, { useState as useState55 } from "react";
15430
+ import React179, { useState as useState54 } from "react";
15413
15431
  var GeneralLedgerView = ({
15414
15432
  title,
15415
15433
  // deprecated
15416
15434
  stringOverrides
15417
15435
  }) => {
15418
- const [activeTab, setActiveTab] = useState55("chartOfAccounts");
15436
+ const [activeTab, setActiveTab] = useState54("chartOfAccounts");
15419
15437
  return /* @__PURE__ */ React179.createElement(ProfitAndLoss, { asContainer: false }, /* @__PURE__ */ React179.createElement(View, { title: stringOverrides?.title || title || "General Ledger" }, /* @__PURE__ */ React179.createElement(
15420
15438
  Toggle,
15421
15439
  {
@@ -15444,13 +15462,13 @@ var GeneralLedgerView = ({
15444
15462
  };
15445
15463
 
15446
15464
  // src/views/Reports/Reports.tsx
15447
- import React180, { useContext as useContext38, useRef as useRef16, useState as useState56 } from "react";
15465
+ import React180, { useContext as useContext38, useRef as useRef16, useState as useState55 } from "react";
15448
15466
  var DownloadButton2 = ({
15449
15467
  stringOverrides
15450
15468
  }) => {
15451
15469
  const { dateRange } = useContext38(ProfitAndLoss.Context);
15452
15470
  const { auth, businessId, apiUrl } = useLayerContext();
15453
- const [requestFailed, setRequestFailed] = useState56(false);
15471
+ const [requestFailed, setRequestFailed] = useState55(false);
15454
15472
  const handleClick = async () => {
15455
15473
  const month = (dateRange.startDate.getMonth() + 1).toString();
15456
15474
  const year = dateRange.startDate.getFullYear().toString();
@@ -15517,7 +15535,7 @@ var Reports = ({
15517
15535
  enabledReports = ["profitAndLoss", "balanceSheet", "statementOfCashFlow"]
15518
15536
  }) => {
15519
15537
  const containerRef = useRef16(null);
15520
- const [activeTab, setActiveTab] = useState56(enabledReports[0]);
15538
+ const [activeTab, setActiveTab] = useState55(enabledReports[0]);
15521
15539
  const options = getOptions(enabledReports);
15522
15540
  const defaultTitle = enabledReports.length > 1 ? "Reports" : options.find((option) => option.value = enabledReports[0])?.label;
15523
15541
  return /* @__PURE__ */ React180.createElement(View, { title: stringOverrides?.title || title || defaultTitle }, enabledReports.length > 1 && /* @__PURE__ */ React180.createElement("div", { className: "Layer__component Layer__header__actions" }, /* @__PURE__ */ React180.createElement(