Skip to content

Commit

Permalink
feat: Add TODOs for allowing tx on tx creation
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha committed Jan 21, 2024
1 parent bf62ae4 commit 9649506
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/components/modals/modify-record/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,22 @@ const form = ref<UI_FORM_STRUCT>({
const linkedTransaction = ref<TransactionModel | null>(null);
const openTransactionModalList = async () => {
const type =
props.transaction?.transactionType === TRANSACTION_TYPES.expense
? TRANSACTION_TYPES.income
: TRANSACTION_TYPES.expense;
// if (isFormCreation.value) {
// type =
// form.value.type === FORM_TYPES.expense
// ? TRANSACTION_TYPES.expense
// : TRANSACTION_TYPES.income;
// }
addModal({
type: MODAL_TYPES.recordList,
data: {
transactionType:
props.transaction.transactionType === TRANSACTION_TYPES.expense
? TRANSACTION_TYPES.income
: TRANSACTION_TYPES.expense,
transactionType: type,
onSelect(transaction) {
linkedTransaction.value = transaction;
},
Expand Down Expand Up @@ -286,10 +295,12 @@ const submit = async () => {
try {
if (isFormCreation.value) {
await createTransaction(
// TODO: unit tests for "prepareTxCreationParams" and "prepareTxUpdationParams"
prepareTxCreationParams({
form: form.value,
isTransferTx: isTransferTx.value,
isCurrenciesDifferent: isCurrenciesDifferent.value,
// linkedTransaction: linkedTransaction.value,
}),
);
} else if (linkedTransaction.value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { TRANSACTION_TRANSFER_NATURE, TRANSACTION_TYPES } from "shared-types";
import {
TRANSACTION_TRANSFER_NATURE,
TRANSACTION_TYPES,
// TransactionModel,
} from "shared-types";
import { createTransaction } from "@/api";
import { OUT_OF_WALLET_ACCOUNT_MOCK } from "@/common/const";
import { UI_FORM_STRUCT } from "../types";
Expand All @@ -8,8 +12,10 @@ export const prepareTxCreationParams = ({
form,
isTransferTx,
isCurrenciesDifferent,
// linkedTransaction,
}: {
form: UI_FORM_STRUCT;
// linkedTransaction: TransactionModel;
isTransferTx: boolean;
isCurrenciesDifferent: boolean;
}) => {
Expand All @@ -33,6 +39,13 @@ export const prepareTxCreationParams = ({
accountId,
};

// if (linkedTransaction) {
// creationParams.destinationTransactionId = linkedTransaction.id;
// creationParams.transferNature = TRANSACTION_TRANSFER_NATURE.common_transfer;
// // TODO: also take care about the case when user is filling a form for
// // "target amount" and "target account" and linking exactly to them
// } else {
// // everything that is below...
if (isTransferTx) {
creationParams.destinationAccountId = toAccount.id;
creationParams.destinationAmount = isCurrenciesDifferent
Expand Down

0 comments on commit 9649506

Please sign in to comment.