diff --git a/client/src/components/modals/EditGroupFeesModal.tsx b/client/src/components/modals/EditGroupFeesModal.tsx index 7bdcf48..3aba36a 100644 --- a/client/src/components/modals/EditGroupFeesModal.tsx +++ b/client/src/components/modals/EditGroupFeesModal.tsx @@ -56,18 +56,16 @@ export default function EditGroupFeesModal({ isOpen, onClose, group, onSaved }: setError(null); setLoading(true); try { - const body: Record = { id: group.id }; - body.fees = feesNum; - body.shipping = shippingNum; - body.tip = tipNum; - if (discountNum > 0) { - body.discountType = discountType; - body.discountValue = discountNum; - } else { - body.discountType = ''; - body.discountValue = 0; - } - const res = await updateGroupFees({ body }); + const res = await updateGroupFees({ + body: { + id: group.id, + fees: feesNum, + shipping: shippingNum, + tip: tipNum, + discountType: discountNum > 0 ? discountType : undefined, + discountValue: discountNum > 0 ? discountNum : undefined, + }, + }); if (res.error) { setError((res.error as any).error || 'Nastala chyba'); } else { diff --git a/server/src/websocket.ts b/server/src/websocket.ts index 2257881..fd2cc05 100644 --- a/server/src/websocket.ts +++ b/server/src/websocket.ts @@ -32,5 +32,6 @@ export const getWebsocket = () => io; /** Pošle event konkrétnímu přihlášenému uživateli (pokud je připojen). */ export const emitToUser = (login: string, event: string, data: unknown) => { + if (!io) return; io.to(`user:${login}`).emit(event, data); } \ No newline at end of file