@musetax/compass-widget 0.1.218
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/README.md +1 -0
- package/dist/AddTransactionForm.d.ts +9 -0
- package/dist/AddTransactionForm.js +317 -0
- package/dist/App.d.ts +2 -0
- package/dist/App.js +5 -0
- package/dist/App.test.d.ts +1 -0
- package/dist/App.test.js +8 -0
- package/dist/ClientAuthForm.d.ts +8 -0
- package/dist/ClientAuthForm.js +504 -0
- package/dist/PotentialDeductions.d.ts +3 -0
- package/dist/PotentialDeductions.js +187 -0
- package/dist/ShowToast.d.ts +3 -0
- package/dist/ShowToast.js +42 -0
- package/dist/api.d.ts +2 -0
- package/dist/api.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/reportWebVitals.d.ts +3 -0
- package/dist/reportWebVitals.js +12 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +5 -0
- package/dist/taxInsightDashboard.d.ts +2 -0
- package/dist/taxInsightDashboard.js +261 -0
- package/package.json +57 -0
@@ -0,0 +1,504 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
11
|
+
import React, { useEffect, useMemo, useState } from "react";
|
12
|
+
import AddTransactionForm from "./AddTransactionForm";
|
13
|
+
import showToast from "./ShowToast";
|
14
|
+
import api from "./api";
|
15
|
+
const { CiSearch } = require("react-icons/ci");
|
16
|
+
const { FaPlus, FaCaretDown } = require("react-icons/fa6");
|
17
|
+
const { HiOutlineArrowSmLeft } = require("react-icons/hi");
|
18
|
+
const ClientAuthForm = ({ userId, access_token, onError }) => {
|
19
|
+
var _a, _b;
|
20
|
+
const [isOpen, setIsOpen] = useState(false);
|
21
|
+
const [selected, setSelected] = useState(null);
|
22
|
+
const [search, setSearch] = useState("");
|
23
|
+
const [loading, setLoading] = useState(false);
|
24
|
+
const [error, setError] = useState("");
|
25
|
+
const [transactions, setTransactions] = useState([]);
|
26
|
+
const [showAddForm, setShowAddForm] = useState(false);
|
27
|
+
const [categoryNames, setCategoryNames] = useState([]);
|
28
|
+
//done
|
29
|
+
const makeSessionToken = () => __awaiter(void 0, void 0, void 0, function* () {
|
30
|
+
var _c, _d;
|
31
|
+
setLoading(true);
|
32
|
+
setError("");
|
33
|
+
try {
|
34
|
+
const response = yield api.post("/widgets/session", {
|
35
|
+
user_id: userId,
|
36
|
+
domain_urls: [`${window.location.origin}/`],
|
37
|
+
}, {
|
38
|
+
headers: {
|
39
|
+
Accept: "application/json",
|
40
|
+
"Content-Type": "application/json",
|
41
|
+
Authorization: `Bearer ${access_token}`,
|
42
|
+
},
|
43
|
+
});
|
44
|
+
console.log(response, "responseresponseresponse");
|
45
|
+
const data = response.data;
|
46
|
+
console.log(data, "datadatadatadatadata");
|
47
|
+
if (data.widget_session_token) {
|
48
|
+
getAuthSessionToken(data.widget_session_token);
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
setError(data === null || data === void 0 ? void 0 : data.detail);
|
52
|
+
onError === null || onError === void 0 ? void 0 : onError(data === null || data === void 0 ? void 0 : data.detail);
|
53
|
+
showToast("error", data === null || data === void 0 ? void 0 : data.detail);
|
54
|
+
setLoading(false);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
catch (err) {
|
58
|
+
const msg = ((_d = (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.detail) ||
|
59
|
+
"Error while fetching auth session token";
|
60
|
+
setError(msg);
|
61
|
+
onError === null || onError === void 0 ? void 0 : onError(msg);
|
62
|
+
showToast("error", msg);
|
63
|
+
setLoading(false);
|
64
|
+
}
|
65
|
+
});
|
66
|
+
//done
|
67
|
+
const getAuthSessionToken = (session_token) => __awaiter(void 0, void 0, void 0, function* () {
|
68
|
+
var _e, _f;
|
69
|
+
setError("");
|
70
|
+
try {
|
71
|
+
const response = yield api.get("/widgets/auth/token", {
|
72
|
+
headers: {
|
73
|
+
Accept: "application/json",
|
74
|
+
Authorization: `Bearer ${session_token}`,
|
75
|
+
},
|
76
|
+
});
|
77
|
+
const data = response.data;
|
78
|
+
if (data.domain_urls) {
|
79
|
+
yield fetchTransactions(userId);
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
setError(data === null || data === void 0 ? void 0 : data.detail);
|
83
|
+
onError === null || onError === void 0 ? void 0 : onError(data === null || data === void 0 ? void 0 : data.detail);
|
84
|
+
showToast("error", data === null || data === void 0 ? void 0 : data.detail);
|
85
|
+
setLoading(false);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
catch (err) {
|
89
|
+
const msg = ((_f = (_e = err === null || err === void 0 ? void 0 : err.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.detail) ||
|
90
|
+
"Error while fetching auth session token";
|
91
|
+
setError(msg);
|
92
|
+
onError === null || onError === void 0 ? void 0 : onError(msg);
|
93
|
+
showToast("error", msg);
|
94
|
+
setLoading(false);
|
95
|
+
}
|
96
|
+
});
|
97
|
+
// done
|
98
|
+
const fetchTransactions = (userId) => __awaiter(void 0, void 0, void 0, function* () {
|
99
|
+
setLoading(true);
|
100
|
+
try {
|
101
|
+
const { data } = yield api.get(`/transaction/categorize/${userId}`);
|
102
|
+
console.log(data, "transactions");
|
103
|
+
if (data === null || data === void 0 ? void 0 : data.detail) {
|
104
|
+
setError(data === null || data === void 0 ? void 0 : data.detail);
|
105
|
+
onError === null || onError === void 0 ? void 0 : onError(data.detail);
|
106
|
+
showToast("error", data.detail);
|
107
|
+
setLoading(false);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
setTransactions(data || []);
|
111
|
+
setLoading(false);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
catch (error) {
|
115
|
+
const msg = "Failed to fetch transactions.";
|
116
|
+
setError(msg);
|
117
|
+
onError === null || onError === void 0 ? void 0 : onError(msg);
|
118
|
+
showToast("error", msg);
|
119
|
+
setLoading(false);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
//done
|
123
|
+
const getAllUserCategory = () => __awaiter(void 0, void 0, void 0, function* () {
|
124
|
+
var _g, _h;
|
125
|
+
try {
|
126
|
+
const response = yield api.get(`/categorized/data/${userId}`);
|
127
|
+
const data = response.data;
|
128
|
+
setCategoryNames(data); // 🔥 Save to state
|
129
|
+
}
|
130
|
+
catch (err) {
|
131
|
+
console.error("Error fetching categories:", err);
|
132
|
+
const msg = ((_h = (_g = err === null || err === void 0 ? void 0 : err.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.detail) || "Error fetching categories";
|
133
|
+
showToast("error", msg);
|
134
|
+
}
|
135
|
+
});
|
136
|
+
// done
|
137
|
+
const updateTransactionCategory = (payload) => __awaiter(void 0, void 0, void 0, function* () {
|
138
|
+
try {
|
139
|
+
console.log(payload, "payloadpayloadpayloadpayload");
|
140
|
+
const response = yield api.put("/transaction/update/category", payload);
|
141
|
+
console.log(response, "responseresponseresponse");
|
142
|
+
if ((response === null || response === void 0 ? void 0 : response.status) == 200) {
|
143
|
+
setSelected(null);
|
144
|
+
showToast("success", "Category updated successfully");
|
145
|
+
yield fetchTransactions(userId);
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
showToast("error", "Something went wrong");
|
149
|
+
}
|
150
|
+
}
|
151
|
+
catch (err) {
|
152
|
+
showToast("error", "Failed to update category");
|
153
|
+
}
|
154
|
+
});
|
155
|
+
const filtered = useMemo(() => {
|
156
|
+
if (!search.trim())
|
157
|
+
return transactions;
|
158
|
+
const s = search.toLowerCase();
|
159
|
+
return transactions.filter((g) => { var _a; return (_a = g.category) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(s); });
|
160
|
+
}, [transactions, search]);
|
161
|
+
const taxSavings = filtered.reduce((sum, g) => {
|
162
|
+
var _a, _b;
|
163
|
+
const deductible = ((g === null || g === void 0 ? void 0 : g.category) && ((_a = g === null || g === void 0 ? void 0 : g.category) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === "LOAN_PAYMENTS") ||
|
164
|
+
((g === null || g === void 0 ? void 0 : g.category) && ((_b = g === null || g === void 0 ? void 0 : g.category) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === "TRAVEL");
|
165
|
+
return deductible ? sum + g.total_amount * 0.1 : sum;
|
166
|
+
}, 0);
|
167
|
+
useEffect(() => {
|
168
|
+
if (access_token) {
|
169
|
+
getAllUserCategory();
|
170
|
+
makeSessionToken();
|
171
|
+
}
|
172
|
+
}, [access_token]);
|
173
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ style: {
|
174
|
+
position: "fixed",
|
175
|
+
bottom: "20px",
|
176
|
+
right: "20px",
|
177
|
+
width: "60px",
|
178
|
+
height: "60px",
|
179
|
+
backgroundColor: "#007bff",
|
180
|
+
borderRadius: "50%",
|
181
|
+
display: "flex",
|
182
|
+
justifyContent: "center",
|
183
|
+
alignItems: "center",
|
184
|
+
cursor: "pointer",
|
185
|
+
zIndex: 9999,
|
186
|
+
color: "#fff",
|
187
|
+
fontSize: "28px",
|
188
|
+
boxShadow: "0 4px 5px rgba(0, 0, 0, 0.3)",
|
189
|
+
}, onClick: () => setIsOpen(!isOpen), title: "Open Auth Widget" }, { children: "\uD83D\uDCAC" })), isOpen && (_jsx("div", Object.assign({ style: {
|
190
|
+
position: "fixed",
|
191
|
+
bottom: "90px",
|
192
|
+
right: "20px",
|
193
|
+
width: "50rem",
|
194
|
+
maxHeight: "70vh",
|
195
|
+
backgroundColor: "#fff",
|
196
|
+
borderRadius: "12px",
|
197
|
+
boxShadow: "0 0 5px rgba(0,0,0,0.2)",
|
198
|
+
zIndex: 9998,
|
199
|
+
padding: "0",
|
200
|
+
overflowY: "auto",
|
201
|
+
} }, { children: _jsxs("div", Object.assign({ style: {
|
202
|
+
padding: "0",
|
203
|
+
minHeight: "500px",
|
204
|
+
} }, { children: [_jsx("h2", Object.assign({ style: {
|
205
|
+
fontSize: "1.125rem",
|
206
|
+
fontWeight: "500",
|
207
|
+
color: "#042567",
|
208
|
+
margin: "0px",
|
209
|
+
backgroundColor: "#F1F7FB",
|
210
|
+
padding: "16px 24px",
|
211
|
+
display: "flex",
|
212
|
+
justifyContent: "space-between",
|
213
|
+
alignItems: "center",
|
214
|
+
borderBottom: "1px solid #BFDBFE",
|
215
|
+
marginBottom: "18px",
|
216
|
+
} }, { children: "Review & Categorize" })), !selected && (_jsxs("div", Object.assign({ style: { padding: "0px 24px 16px", position: "relative" } }, { children: [_jsx("span", Object.assign({ style: { position: "absolute", top: "9px", left: "40px" } }, { children: _jsx(CiSearch, { style: { color: "#526282", fontSize: "20px" } }) })), _jsx("input", { type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Search\u2026", style: {
|
217
|
+
width: "calc(100% - 70px)",
|
218
|
+
padding: "10px 16px 10px 44px",
|
219
|
+
border: "1px solid #E6E7EA",
|
220
|
+
borderRadius: "9999px",
|
221
|
+
fontSize: "0.875rem",
|
222
|
+
color: "#042567",
|
223
|
+
outline: "none",
|
224
|
+
} })] }))), _jsxs("div", Object.assign({ style: { padding: "0 24px 10px" } }, { children: [_jsx("div", Object.assign({ style: {
|
225
|
+
display: "flex",
|
226
|
+
justifyContent: "end",
|
227
|
+
width: "100%",
|
228
|
+
marginBottom: "16px",
|
229
|
+
} }, { children: _jsxs("button", Object.assign({ style: {
|
230
|
+
backgroundColor: "#5387F1",
|
231
|
+
border: "1px solid #5387F1",
|
232
|
+
color: "white",
|
233
|
+
fontSize: "0.875rem",
|
234
|
+
fontWeight: 500,
|
235
|
+
padding: "8px 16px",
|
236
|
+
borderRadius: 8,
|
237
|
+
marginRight: 8,
|
238
|
+
cursor: "pointer",
|
239
|
+
display: "flex",
|
240
|
+
alignItems: "center",
|
241
|
+
justifyContent: "center",
|
242
|
+
gap: "5px",
|
243
|
+
}, onClick: () => setShowAddForm(true) }, { children: [_jsx(FaPlus, { style: { fontSize: "18px" } }), " Add Transaction"] })) })), !loading && (_jsxs("div", Object.assign({ style: {
|
244
|
+
display: "flex",
|
245
|
+
alignItems: "center",
|
246
|
+
gap: "10px",
|
247
|
+
marginBottom: "10px",
|
248
|
+
} }, { children: [_jsxs("span", Object.assign({ style: {
|
249
|
+
fontSize: "14px",
|
250
|
+
color: "rgb(82, 98, 130)",
|
251
|
+
margin: "0px",
|
252
|
+
display: "flex",
|
253
|
+
alignItems: "center",
|
254
|
+
gap: 6,
|
255
|
+
} }, { children: ["Number of Review & Categorize :", " ", _jsx("span", Object.assign({ style: {
|
256
|
+
color: "#042567",
|
257
|
+
fontSize: "16px",
|
258
|
+
fontWeight: 500,
|
259
|
+
} }, { children: filtered ? filtered === null || filtered === void 0 ? void 0 : filtered.length : "0" }))] })), _jsxs("span", Object.assign({ style: {
|
260
|
+
fontSize: "14px",
|
261
|
+
color: "rgb(82, 98, 130)",
|
262
|
+
margin: "0px",
|
263
|
+
display: "flex",
|
264
|
+
alignItems: "center",
|
265
|
+
gap: 6,
|
266
|
+
} }, { children: ["Number of transaction", " ", _jsx("span", Object.assign({ style: {
|
267
|
+
color: "#042567",
|
268
|
+
fontSize: "16px",
|
269
|
+
fontWeight: 500,
|
270
|
+
} }, { children: filtered
|
271
|
+
? filtered === null || filtered === void 0 ? void 0 : filtered.reduce((sum, item) => sum + item.transactions.length, 0)
|
272
|
+
: "0" }))] }))] }))), showAddForm ? (_jsx(AddTransactionForm, { userId: userId, accessToken: access_token, onSuccess: () => __awaiter(void 0, void 0, void 0, function* () {
|
273
|
+
// await handleAddTransaction();
|
274
|
+
setShowAddForm(false);
|
275
|
+
yield fetchTransactions(userId);
|
276
|
+
}), onError: onError })) : loading ? (_jsx("p", Object.assign({ style: {
|
277
|
+
fontSize: "0.875rem",
|
278
|
+
color: "#526282",
|
279
|
+
margin: 0,
|
280
|
+
display: "flex",
|
281
|
+
justifyContent: "center",
|
282
|
+
width: "100%",
|
283
|
+
} }, { children: "Loading\u2026" }))) : error ? (_jsx("p", Object.assign({ style: { color: "red" } }, { children: error }))) : !selected ? (filtered.length === 0 ? (_jsx("p", Object.assign({ style: {
|
284
|
+
fontSize: "0.875rem",
|
285
|
+
color: "#526282",
|
286
|
+
margin: 0,
|
287
|
+
display: "flex",
|
288
|
+
justifyContent: "center",
|
289
|
+
width: "100%",
|
290
|
+
} }, { children: "No transactions match." }))) : (filtered.map((g) => {
|
291
|
+
var _a, _b;
|
292
|
+
return (_jsxs("div", Object.assign({ onClick: () => setSelected(g), style: {
|
293
|
+
cursor: "pointer",
|
294
|
+
display: "flex",
|
295
|
+
justifyContent: "space-between",
|
296
|
+
alignItems: "center",
|
297
|
+
padding: "16px 20px",
|
298
|
+
border: "1px solid #1E40AF1A",
|
299
|
+
borderRadius: 12,
|
300
|
+
marginBottom: "12px",
|
301
|
+
} }, { children: [_jsxs("div", { children: [_jsx("h3", Object.assign({ style: {
|
302
|
+
fontSize: "15px",
|
303
|
+
fontWeight: 500,
|
304
|
+
color: "#042567",
|
305
|
+
margin: "0 0 6px 0",
|
306
|
+
} }, { children: (_a = g === null || g === void 0 ? void 0 : g.category) !== null && _a !== void 0 ? _a : "NA" })), _jsx("span", Object.assign({ style: {
|
307
|
+
fontSize: "0.75rem",
|
308
|
+
backgroundColor: "#4A6CF71F",
|
309
|
+
color: "#4A6CF7",
|
310
|
+
borderRadius: 9999,
|
311
|
+
padding: "4px 16px",
|
312
|
+
display: "inline-block",
|
313
|
+
border: "1px solid #4A6CF71A",
|
314
|
+
} }, { children: ((_b = g === null || g === void 0 ? void 0 : g.schedule) !== null && _b !== void 0 ? _b : "") !== "" ? g.schedule : "N/A" }))] }), _jsxs("div", Object.assign({ style: { textAlign: "right" } }, { children: [_jsxs("p", Object.assign({ style: {
|
315
|
+
color: "#042567",
|
316
|
+
fontSize: "16px",
|
317
|
+
fontWeight: 500,
|
318
|
+
margin: "0 0 4px",
|
319
|
+
display: "flex",
|
320
|
+
alignItems: "center",
|
321
|
+
gap: 6,
|
322
|
+
} }, { children: ["$", g.total_amount.toFixed(2), " ", _jsx(FaCaretDown, {})] })), _jsxs("p", Object.assign({ style: {
|
323
|
+
fontSize: "0.875rem",
|
324
|
+
color: "#526282",
|
325
|
+
margin: 0,
|
326
|
+
} }, { children: [" ", g.transactions.length, " transactions"] }))] }))] }), g.category));
|
327
|
+
}))) : (_jsx(_Fragment, { children: _jsxs("div", Object.assign({ style: {
|
328
|
+
backgroundColor: "#fff",
|
329
|
+
color: "#000",
|
330
|
+
borderRadius: "12px",
|
331
|
+
padding: "1rem 0px",
|
332
|
+
maxWidth: "100%",
|
333
|
+
margin: "1rem auto",
|
334
|
+
fontFamily: "sans-serif",
|
335
|
+
fontSize: "0.9rem",
|
336
|
+
} }, { children: [_jsxs("button", Object.assign({ onClick: () => {
|
337
|
+
setSelected(null);
|
338
|
+
setSearch("");
|
339
|
+
}, style: {
|
340
|
+
background: "transparent",
|
341
|
+
border: "none",
|
342
|
+
color: "#2094EA",
|
343
|
+
marginBottom: "1rem",
|
344
|
+
cursor: "pointer",
|
345
|
+
fontWeight: 500,
|
346
|
+
fontSize: "1rem",
|
347
|
+
display: "flex",
|
348
|
+
alignItems: "center",
|
349
|
+
gap: "5px",
|
350
|
+
} }, { children: [_jsx(HiOutlineArrowSmLeft, { style: { fontSize: "22px" } }), "Back"] })), _jsxs("div", Object.assign({ style: {
|
351
|
+
padding: "0px",
|
352
|
+
} }, { children: [_jsxs("div", Object.assign({ style: {
|
353
|
+
backgroundColor: "#F1F7FB",
|
354
|
+
borderRadius: "8px",
|
355
|
+
padding: "1rem",
|
356
|
+
display: "flex",
|
357
|
+
justifyContent: "space-between",
|
358
|
+
alignItems: "center",
|
359
|
+
marginBottom: "14px",
|
360
|
+
flexWrap: "wrap",
|
361
|
+
} }, { children: [_jsxs("div", Object.assign({ style: { display: "flex", flexDirection: "column" } }, { children: [_jsx("h2", Object.assign({ style: {
|
362
|
+
color: "#042567",
|
363
|
+
fontSize: "16px",
|
364
|
+
fontWeight: "500",
|
365
|
+
margin: 0,
|
366
|
+
textTransform: "capitalize",
|
367
|
+
} }, { children: selected === null || selected === void 0 ? void 0 : selected.category })), _jsx("span", Object.assign({ style: {
|
368
|
+
backgroundColor: "#67DC791F",
|
369
|
+
color: "#15803D",
|
370
|
+
padding: "6px 16px",
|
371
|
+
border: "1px solid #4EC7601A",
|
372
|
+
borderRadius: "50px",
|
373
|
+
fontSize: "0.85rem",
|
374
|
+
marginTop: "6px",
|
375
|
+
textAlign: "center",
|
376
|
+
} }, { children: ((_a = selected === null || selected === void 0 ? void 0 : selected.schedule) !== null && _a !== void 0 ? _a : "") !== ""
|
377
|
+
? selected.schedule
|
378
|
+
: "N/A" }))] })), _jsxs("div", Object.assign({ style: { textAlign: "right" } }, { children: [_jsxs("p", Object.assign({ style: {
|
379
|
+
color: "#042567",
|
380
|
+
fontSize: "17px",
|
381
|
+
fontWeight: "500",
|
382
|
+
margin: 0,
|
383
|
+
} }, { children: ["$", selected.total_amount.toFixed(2)] })), _jsxs("span", Object.assign({ style: { fontSize: "14px", color: "#526282" } }, { children: [selected.transactions.length, " transactions"] }))] }))] })), _jsx("div", Object.assign({ style: {
|
384
|
+
border: "1px solid #E4EEF4",
|
385
|
+
borderRadius: "12px",
|
386
|
+
overflow: "hidden",
|
387
|
+
} }, { children: _jsxs("table", Object.assign({ style: {
|
388
|
+
width: "100%",
|
389
|
+
borderCollapse: "collapse",
|
390
|
+
background: "#fff",
|
391
|
+
borderRadius: "8px",
|
392
|
+
overflow: "hidden",
|
393
|
+
} }, { children: [_jsx("thead", Object.assign({ style: {
|
394
|
+
backgroundColor: "#f1f5f9",
|
395
|
+
textAlign: "left",
|
396
|
+
} }, { children: _jsxs("tr", { children: [_jsx("th", Object.assign({ style: {
|
397
|
+
padding: "12px 16px",
|
398
|
+
color: "#042567",
|
399
|
+
textAlign: "left",
|
400
|
+
fontWeight: "500",
|
401
|
+
} }, { children: "Description" })), _jsx("th", Object.assign({ style: {
|
402
|
+
padding: "12px 16px",
|
403
|
+
color: "#042567",
|
404
|
+
textAlign: "left",
|
405
|
+
fontWeight: "500",
|
406
|
+
} }, { children: "Type" })), _jsx("th", Object.assign({ style: {
|
407
|
+
padding: "12px 16px",
|
408
|
+
color: "#042567",
|
409
|
+
textAlign: "left",
|
410
|
+
fontWeight: "500",
|
411
|
+
} }, { children: "Amount" })), _jsx("th", Object.assign({ style: {
|
412
|
+
padding: "12px 16px",
|
413
|
+
color: "#042567",
|
414
|
+
textAlign: "left",
|
415
|
+
fontWeight: "500",
|
416
|
+
} }, { children: "Category" }))] }) })), _jsx("tbody", { children: (_b = selected === null || selected === void 0 ? void 0 : selected.transactions) === null || _b === void 0 ? void 0 : _b.map((t) => {
|
417
|
+
var _a, _b, _c;
|
418
|
+
const transactionId = (t === null || t === void 0 ? void 0 : t.transaction_id) || (t === null || t === void 0 ? void 0 : t.description);
|
419
|
+
// Deduplicate category names by category_details.name
|
420
|
+
const uniqueCategories = Array.from(new Map(categoryNames.map((item) => [
|
421
|
+
item === null || item === void 0 ? void 0 : item.category,
|
422
|
+
item,
|
423
|
+
])).values());
|
424
|
+
console.log(selected, "selected.categoryselected.categoryselected.category");
|
425
|
+
return (_jsx(React.Fragment, { children: _jsxs("tr", Object.assign({ style: {
|
426
|
+
borderBottom: "1px solid #e0e0e0",
|
427
|
+
} }, { children: [_jsx("td", Object.assign({ style: {
|
428
|
+
padding: "12px",
|
429
|
+
color: "#444",
|
430
|
+
textAlign: "left",
|
431
|
+
} }, { children: (_a = t.description) !== null && _a !== void 0 ? _a : t.merchant_name })), _jsx("td", Object.assign({ style: {
|
432
|
+
padding: "12px",
|
433
|
+
textAlign: "left",
|
434
|
+
} }, { children: ((_b = t.schedule) !== null && _b !== void 0 ? _b : "") !== ""
|
435
|
+
? t.schedule
|
436
|
+
: ((_c = selected === null || selected === void 0 ? void 0 : selected.schedule) !== null && _c !== void 0 ? _c : "") !== ""
|
437
|
+
? selected.schedule
|
438
|
+
: "N/A" })), _jsx("td", Object.assign({ style: {
|
439
|
+
padding: "12px",
|
440
|
+
textAlign: "left",
|
441
|
+
color: t.amount < 0 ? "#d32f2f" : "#2e7d32",
|
442
|
+
} }, { children: t.amount < 0
|
443
|
+
? `-$${Math.abs(t.amount).toFixed(2)}`
|
444
|
+
: `$${t.amount.toFixed(2)}` })), _jsx("td", Object.assign({ style: {
|
445
|
+
padding: "12px",
|
446
|
+
textAlign: "left",
|
447
|
+
} }, { children: _jsxs("select", Object.assign({ value: selected.category || "", onChange: (e) => {
|
448
|
+
var _a, _b, _c, _d;
|
449
|
+
const selectedCategory = uniqueCategories.find((c) => (c === null || c === void 0 ? void 0 : c.category) === e.target.value);
|
450
|
+
if (selectedCategory) {
|
451
|
+
console.log(selectedCategory, "selectedCategoryselectedCategory");
|
452
|
+
const payload = {
|
453
|
+
transaction_id: t === null || t === void 0 ? void 0 : t.transaction_id,
|
454
|
+
category: selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category,
|
455
|
+
category_name: selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category,
|
456
|
+
schedule: (_a = selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category_details) === null || _a === void 0 ? void 0 : _a.schedule,
|
457
|
+
line: (_b = selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category_details) === null || _b === void 0 ? void 0 : _b.line,
|
458
|
+
deductible: (_c = selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category_details) === null || _c === void 0 ? void 0 : _c.deductible,
|
459
|
+
taxable: (_d = selectedCategory === null || selectedCategory === void 0 ? void 0 : selectedCategory.category_details) === null || _d === void 0 ? void 0 : _d.taxable,
|
460
|
+
confidence_score: 1,
|
461
|
+
};
|
462
|
+
updateTransactionCategory(payload);
|
463
|
+
}
|
464
|
+
}, style: {
|
465
|
+
padding: "8px 16px",
|
466
|
+
border: "1px solid #E6E7EA",
|
467
|
+
borderRadius: "9999px",
|
468
|
+
fontSize: "0.875rem",
|
469
|
+
color: "#042567",
|
470
|
+
outline: "none",
|
471
|
+
} }, { children: [_jsx("option", Object.assign({ value: "" }, { children: "Select Category" })), uniqueCategories.map((data, index) => (_jsx("option", Object.assign({ value: data === null || data === void 0 ? void 0 : data.category }, { children: data === null || data === void 0 ? void 0 : data.category }), index)))] })) }))] })) }, transactionId));
|
472
|
+
}) })] })) }))] }))] })) }))] })), !selected && filtered.length > 0 && !showAddForm && (_jsx("div", Object.assign({ style: { padding: "0 24px 24px" } }, { children: _jsxs("div", Object.assign({ style: {
|
473
|
+
backgroundColor: "#F1F7FB",
|
474
|
+
padding: "32px 24px",
|
475
|
+
borderRadius: 16,
|
476
|
+
textAlign: "center",
|
477
|
+
} }, { children: [_jsxs("p", Object.assign({ style: {
|
478
|
+
fontSize: "14px",
|
479
|
+
fontWeight: 500,
|
480
|
+
color: "#042567",
|
481
|
+
marginBottom: 16,
|
482
|
+
marginTop: 0,
|
483
|
+
} }, { children: ["Potential Tax Savings from Reviewed Transactions: \u00A0", _jsxs("span", Object.assign({ style: { color: "#042567", fontWeight: "bold" } }, { children: ["$", taxSavings.toFixed(2)] }))] })), _jsx("button", Object.assign({ style: {
|
484
|
+
backgroundColor: "#5387F1",
|
485
|
+
border: "1px solid #5387F1",
|
486
|
+
color: "white",
|
487
|
+
fontSize: "0.875rem",
|
488
|
+
fontWeight: 500,
|
489
|
+
padding: "8px 16px",
|
490
|
+
borderRadius: 8,
|
491
|
+
marginRight: 8,
|
492
|
+
cursor: "pointer",
|
493
|
+
} }, { children: "Proceed" })), _jsx("button", Object.assign({ style: {
|
494
|
+
border: "1px solid #5387F1",
|
495
|
+
backgroundColor: "white",
|
496
|
+
color: "#5387F1",
|
497
|
+
fontSize: "0.875rem",
|
498
|
+
fontWeight: 500,
|
499
|
+
padding: "8px 16px",
|
500
|
+
borderRadius: 8,
|
501
|
+
cursor: "pointer",
|
502
|
+
} }, { children: "Review More" }))] })) })))] })) })))] }));
|
503
|
+
};
|
504
|
+
export default ClientAuthForm;
|