Skip to content

Commit 302834c

Browse files
committed
fix: warning
1 parent e9023f7 commit 302834c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

client/src/components/email/utils.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,30 @@ export const sendEmail = async (
6868
if (blob) {
6969
const formData = new FormData();
7070
formData.append("pdfFile", blob, `${pdf_title}.pdf`);
71-
formData.append("to", emails);
71+
const toString = Array.isArray(emails)
72+
? emails.filter(Boolean).join(",")
73+
: (emails || "");
74+
const ccString = Array.isArray(ccEmails)
75+
? ccEmails.filter(Boolean).join(",")
76+
: (ccEmails || "");
77+
const bccString = Array.isArray(bccEmails)
78+
? bccEmails.filter(Boolean).join(",")
79+
: (bccEmails || "");
80+
81+
formData.append("to", toString);
7282
formData.append("subject", title);
7383
formData.append("text", message);
7484
formData.append("html", `<p>${message.replace(/\n/g, "<br />")}</p>`);
75-
formData.append("cc", ccEmails);
76-
formData.append("bcc", bccEmails);
85+
formData.append("cc", ccString);
86+
formData.append("bcc", bccString);
7787

7888
const response = await backend.post("/email/send", formData);
7989

8090
}
8191
} catch (error) {
8292
console.error("Error sending email:", error);
8393
} finally {
84-
setLoading(false);
94+
if (typeof setLoading === "function") setLoading(false);
8595
}
8696
};
8797

client/src/components/invoices/InvoicePDFDocument.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const EditInvoiceDetailsPDF = ({
219219
{payees && payees.length > 0 ? (
220220
payees.map((payee, index) => (
221221
<Text
222-
key={index}
222+
key={`payee-${payee?.id || payee?.email || index}`}
223223
style={{ fontSize: 8, marginBottom: 2 }}
224224
>
225225
{payee.name} - {payee.email}
@@ -245,7 +245,7 @@ const EditInvoiceDetailsPDF = ({
245245
{instructors && instructors.length > 0 ? (
246246
instructors.map((instructor, index) => (
247247
<Text
248-
key={index}
248+
key={`instr-${instructor?.id || instructor?.email || index}`}
249249
style={{ fontSize: 8, marginBottom: 2 }}
250250
>
251251
{instructor.name} - {instructor.email}
@@ -781,7 +781,7 @@ const InvoiceTable = ({ sessions, summary }) => {
781781
session.comments?.map((line, textIndex) => {
782782
return (
783783
<View
784-
key={`comment-${textIndex}`}
784+
key={`comment-${session.id || index}-${textIndex}`}
785785
style={tableStyles.tableRow}
786786
>
787787
<View
@@ -805,7 +805,7 @@ const InvoiceTable = ({ sessions, summary }) => {
805805
const totalRow =
806806
session?.total?.map((total, totalIndex) => {
807807
return (
808-
<View style={tableStyles.tableRow}>
808+
<View style={tableStyles.tableRow} key={`total-${session.id || index}-${totalIndex}`}>
809809
<View style={tableStyles.tableCol}>
810810
<Text style={{ fontSize: 7 }}>
811811
{format(new Date(new Date(total.date).getTime() + new Date(total.date).getTimezoneOffset() * 60000), "EEE. M/d/yy")}
@@ -1034,6 +1034,7 @@ const SummaryTable = ({
10341034
: summaryTableStyles.roomFeeRow;
10351035
return (
10361036
<View
1037+
key={`roomfee-${session?.id || session?.name || index}`}
10371038
style={{
10381039
...rowStyle,
10391040
width: "100%",

client/src/components/invoices/SavedEditInvoiceComponent.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ const SavedStatementComments = ({
220220
const finalTotal = adjSum + totalSum;
221221

222222
const total = finalTotal.toFixed(2);
223-
setSubtotal(Number(total));
224223
return total;
225224
};
226225

@@ -392,6 +391,7 @@ const SavedStatementComments = ({
392391
session.total?.map((total, totalIndex) => {
393392
return (
394393
<Tr
394+
key={`custom-${session.id || index}-${totalIndex}`}
395395
position="relative"
396396
cursor="pointer"
397397
_hover={{ bg: "gray.50" }}
@@ -642,6 +642,7 @@ const SavedStatementComments = ({
642642
session?.total?.map((total, totalIndex) => {
643643
return (
644644
<Tr
645+
key={`total-${session.id || index}-${totalIndex}`}
645646
position="relative"
646647
cursor="pointer"
647648
_hover={{ bg: "gray.50" }}

0 commit comments

Comments
 (0)