mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-06 12:36:11 +01:00
Remove unneeded as unknown ases
This commit is contained in:
@@ -78,7 +78,7 @@ const getDefaultSplittingOptions = (
|
|||||||
splitMode: 'EVENLY' as const,
|
splitMode: 'EVENLY' as const,
|
||||||
paidFor: group.participants.map(({ id }) => ({
|
paidFor: group.participants.map(({ id }) => ({
|
||||||
participant: id,
|
participant: id,
|
||||||
shares: '1' as unknown as number,
|
shares: 1,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ const getDefaultSplittingOptions = (
|
|||||||
splitMode: parsedDefaultSplitMode.splitMode,
|
splitMode: parsedDefaultSplitMode.splitMode,
|
||||||
paidFor: parsedDefaultSplitMode.paidFor.map((paidFor) => ({
|
paidFor: parsedDefaultSplitMode.paidFor.map((paidFor) => ({
|
||||||
participant: paidFor.participant,
|
participant: paidFor.participant,
|
||||||
shares: String(paidFor.shares / 100) as unknown as number,
|
shares: paidFor.shares / 100,
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ async function persistDefaultSplittingOptions(
|
|||||||
if (expenseFormValues.splitMode === 'EVENLY') {
|
if (expenseFormValues.splitMode === 'EVENLY') {
|
||||||
return expenseFormValues.paidFor.map(({ participant }) => ({
|
return expenseFormValues.paidFor.map(({ participant }) => ({
|
||||||
participant,
|
participant,
|
||||||
shares: '100' as unknown as number,
|
shares: 100,
|
||||||
}))
|
}))
|
||||||
} else if (expenseFormValues.splitMode === 'BY_AMOUNT') {
|
} else if (expenseFormValues.splitMode === 'BY_AMOUNT') {
|
||||||
return null
|
return null
|
||||||
@@ -186,18 +186,15 @@ export function ExpenseForm({
|
|||||||
? {
|
? {
|
||||||
title: expense.title,
|
title: expense.title,
|
||||||
expenseDate: expense.expenseDate ?? new Date(),
|
expenseDate: expense.expenseDate ?? new Date(),
|
||||||
amount: String(
|
amount: amountAsDecimal(expense.amount, groupCurrency),
|
||||||
amountAsDecimal(expense.amount, groupCurrency),
|
|
||||||
) as unknown as number, // hack
|
|
||||||
category: expense.categoryId,
|
category: expense.categoryId,
|
||||||
paidBy: expense.paidById,
|
paidBy: expense.paidById,
|
||||||
paidFor: expense.paidFor.map(({ participantId, shares }) => ({
|
paidFor: expense.paidFor.map(({ participantId, shares }) => ({
|
||||||
participant: participantId,
|
participant: participantId,
|
||||||
shares: String(
|
shares:
|
||||||
expense.splitMode === 'BY_AMOUNT'
|
expense.splitMode === 'BY_AMOUNT'
|
||||||
? amountAsDecimal(shares, groupCurrency)
|
? amountAsDecimal(shares, groupCurrency)
|
||||||
: shares / 100,
|
: shares / 100,
|
||||||
) as unknown as number,
|
|
||||||
})),
|
})),
|
||||||
splitMode: expense.splitMode,
|
splitMode: expense.splitMode,
|
||||||
saveDefaultSplittingOptions: false,
|
saveDefaultSplittingOptions: false,
|
||||||
@@ -210,19 +207,17 @@ export function ExpenseForm({
|
|||||||
? {
|
? {
|
||||||
title: t('reimbursement'),
|
title: t('reimbursement'),
|
||||||
expenseDate: new Date(),
|
expenseDate: new Date(),
|
||||||
amount: String(
|
amount: amountAsDecimal(
|
||||||
amountAsDecimal(
|
Number(searchParams.get('amount')) || 0,
|
||||||
Number(searchParams.get('amount')) || 0,
|
groupCurrency,
|
||||||
groupCurrency,
|
),
|
||||||
),
|
|
||||||
) as unknown as number, // hack
|
|
||||||
category: 1, // category with Id 1 is Payment
|
category: 1, // category with Id 1 is Payment
|
||||||
paidBy: searchParams.get('from') ?? undefined,
|
paidBy: searchParams.get('from') ?? undefined,
|
||||||
paidFor: [
|
paidFor: [
|
||||||
searchParams.get('to')
|
searchParams.get('to')
|
||||||
? {
|
? {
|
||||||
participant: searchParams.get('to')!,
|
participant: searchParams.get('to')!,
|
||||||
shares: '1' as unknown as number,
|
shares: 1,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
],
|
],
|
||||||
@@ -238,7 +233,7 @@ export function ExpenseForm({
|
|||||||
expenseDate: searchParams.get('date')
|
expenseDate: searchParams.get('date')
|
||||||
? new Date(searchParams.get('date') as string)
|
? new Date(searchParams.get('date') as string)
|
||||||
: new Date(),
|
: new Date(),
|
||||||
amount: (searchParams.get('amount') || 0) as unknown as number, // hack,
|
amount: Number(searchParams.get('amount')) || 0,
|
||||||
category: searchParams.get('categoryId')
|
category: searchParams.get('categoryId')
|
||||||
? Number(searchParams.get('categoryId'))
|
? Number(searchParams.get('categoryId'))
|
||||||
: 0, // category with Id 0 is General
|
: 0, // category with Id 0 is General
|
||||||
@@ -329,11 +324,7 @@ export function ExpenseForm({
|
|||||||
if (!editedParticipants.includes(participant.participant)) {
|
if (!editedParticipants.includes(participant.participant)) {
|
||||||
return {
|
return {
|
||||||
...participant,
|
...participant,
|
||||||
shares: String(
|
shares: Number(amountPerRemaining.toFixed(groupCurrency.decimal_digits)),
|
||||||
Number(
|
|
||||||
amountPerRemaining.toFixed(groupCurrency.decimal_digits),
|
|
||||||
),
|
|
||||||
) as unknown as number,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return participant
|
return participant
|
||||||
@@ -592,7 +583,7 @@ export function ExpenseForm({
|
|||||||
participant: p.id,
|
participant: p.id,
|
||||||
shares:
|
shares:
|
||||||
paidFor.find((pfor) => pfor.participant === p.id)
|
paidFor.find((pfor) => pfor.participant === p.id)
|
||||||
?.shares ?? ('1' as unknown as number),
|
?.shares ?? 1,
|
||||||
}))
|
}))
|
||||||
form.setValue('paidFor', newPaidFor, {
|
form.setValue('paidFor', newPaidFor, {
|
||||||
shouldDirty: true,
|
shouldDirty: true,
|
||||||
@@ -651,7 +642,7 @@ export function ExpenseForm({
|
|||||||
...field.value,
|
...field.value,
|
||||||
{
|
{
|
||||||
participant: id,
|
participant: id,
|
||||||
shares: '1' as unknown as number,
|
shares: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
options,
|
options,
|
||||||
|
|||||||
Reference in New Issue
Block a user