refactor(api): consume bank operation oneOf contract (WealthLedger/frontend#144) (#152)
This commit was merged in pull request #152.
This commit is contained in:
@@ -120,11 +120,52 @@ const useOperationFormVm = (props: OperationFormProps) => {
|
||||
body: { ...body, version },
|
||||
id: props.operation.id,
|
||||
});
|
||||
else
|
||||
await operationCreation.mutateAsync({
|
||||
else {
|
||||
const base = {
|
||||
amount: body.amount,
|
||||
cardId: values.cardId,
|
||||
date: values.date,
|
||||
description: values.description,
|
||||
id: intent,
|
||||
...body,
|
||||
});
|
||||
};
|
||||
|
||||
switch (values.kind) {
|
||||
case "expense": {
|
||||
await operationCreation.mutateAsync({
|
||||
...base,
|
||||
categoryId: values.categoryId || defaultCategoryId,
|
||||
kind: values.kind,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "refund": {
|
||||
await operationCreation.mutateAsync({
|
||||
...base,
|
||||
kind: values.kind,
|
||||
originalExpenseId: values.originalExpenseId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "topup": {
|
||||
await operationCreation.mutateAsync({
|
||||
...base,
|
||||
kind: values.kind,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "transfer": {
|
||||
await operationCreation.mutateAsync({
|
||||
...base,
|
||||
kind: values.kind,
|
||||
targetCardId: values.targetCardId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifications.show({
|
||||
id: "bank-operation-saved-" + actionId,
|
||||
|
||||
Reference in New Issue
Block a user