Skip to content

Commit

Permalink
Merge pull request #147 from LerianStudio/fix/transaction-error-handling
Browse files Browse the repository at this point in the history
Fix/transaction error handling
  • Loading branch information
augusto-draxx authored Feb 12, 2025
2 parents d1df675 + bea3e00 commit bdcebec
Show file tree
Hide file tree
Showing 35 changed files with 812 additions and 318 deletions.
42 changes: 21 additions & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.formatOnSave": true
},
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"editor.tabSize": 2
}
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.formatOnSave": true
},
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"editor.tabSize": 2
}
7 changes: 7 additions & 0 deletions locales/compiled/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@
"error.midaz.ledgerNameConflict": "Error Midaz name conflict",
"error.midaz.missingFields": "Error Midaz missing fields",
"error.midaz.unauthorized": "Error Midaz unauthorized",
"error.midaz.accountIneligibilityError": "One or more accounts listed in the transaction are not eligible to participate. Please review the account statuses and try again.",
"error.midaz.insufficientFundsError": "The transaction could not be completed due to insufficient funds in the account. Please add sufficient funds to your account and try again.",
"error.midaz.invalidPathParameter": "The provided path parameter is not in the expected format. Please ensure the parameter adheres to the required format and try again.",
"error.midaz.duplicateIdempotencyKey": "The idempotency key is already in use. Please provide a unique key and try again.",
"error.midaz.badRequest": "The server could not understand the request due to malformed syntax. Please check the listed fields and try again.",
"error.midaz.externalAccountModificationProhibitedError": "Accounts of type 'external' cannot be deleted or modified as they are used for traceability with external systems. Please review your request and ensure operations are only performed on internal accounts.",
"error.midaz.unexpectedFieldsInTheRequest": "The request body contains more fields than expected. Please send only the allowed fields as per the documentation.",
"error.midaz.unknowError": "Error on Midaz.",
"errors.custom.date.invalid": "Invalid date",
"errors.custom.one_lowercase_letter": "Field must contain at least 1 lowercase letter",
Expand Down
7 changes: 7 additions & 0 deletions locales/compiled/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@
"error.midaz.ledgerNameConflict": "Já existe um ledger com este nome na sua organização. Renomeie o ledger ou, se quiser usar o mesmo nome, considere criar um novo ledger para uma divisão diferente.",
"error.midaz.missingFields": "Sua solicitação está faltando um ou mais campos obrigatórios. Consulte a documentação para verificar os campos necessários para sua solicitação.",
"error.midaz.unauthorized": "O token fornecido está expirado, inválido ou malformado. Forneça um token válido e tente novamente.",
"error.midaz.accountIneligibilityError": "Uma ou mais contas listadas na transação não são elegíveis para participar. Revise o status da conta e tente novamente.",
"error.midaz.insufficientFundsError": "A transação não pôde ser concluída devido a fundos insuficientes na conta. Adicione fundos suficientes à sua conta e tente novamente.",
"error.midaz.invalidPathParameter": "O parâmetro de caminho fornecido não está no formato esperado. Certifique-se de que o parâmetro esteja de acordo com o formato exigido e tente novamente.",
"error.midaz.duplicateIdempotencyKey": "A chave de idempotência já está em uso. Forneça uma chave exclusiva e tente novamente.",
"error.midaz.badRequest": "O servidor não conseguiu entender a solicitação devido à sintaxe malformada. Verifique os campos listados e tente novamente.",
"error.midaz.externalAccountModificationProhibitedError": "As contas do tipo 'externas' não podem ser excluídas ou modificadas, pois são utilizadas para rastreabilidade com sistemas externos. Revise sua solicitação e certifique-se de que as operações sejam realizadas apenas em contas internas.",
"error.midaz.unexpectedFieldsInTheRequest": "O corpo da solicitação contém mais campos do que o esperado. Por favor envie apenas os campos permitidos conforme a documentação.",
"error.midaz.unknowError": "Erro no Midaz, por favor, entre em contato com o suporte.",
"errors.custom.date.invalid": "Data inválida",
"errors.custom.one_lowercase_letter": "Campo deve conter pelo menos 1 letra minúscula",
Expand Down
10 changes: 9 additions & 1 deletion locales/extracted/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
"error.midaz.ledgerNameConflict": "Error Midaz name conflict",
"error.midaz.missingFields": "Error Midaz missing fields",
"error.midaz.unauthorized": "Error Midaz unauthorized",
"error.midaz.accountIneligibilityError": "One or more accounts listed in the transaction are not eligible to participate. Please review the account statuses and try again.",
"error.midaz.insufficientFundsError": "The transaction could not be completed due to insufficient funds in the account. Please add sufficient funds to your account and try again.",
"error.midaz.invalidPathParameter": "The provided path parameter is not in the expected format. Please ensure the parameter adheres to the required format and try again.",
"error.midaz.duplicateIdempotencyKey": "The idempotency key is already in use. Please provide a unique key and try again.",
"error.midaz.badRequest": "The server could not understand the request due to malformed syntax. Please check the listed fields and try again.",
"error.midaz.externalAccountModificationProhibitedError": "Accounts of type 'external' cannot be deleted or modified as they are used for traceability with external systems. Please review your request and ensure operations are only performed on internal accounts.",
"error.midaz.unexpectedFieldsInTheRequest": "The request body contains more fields than expected. Please send only the allowed fields as per the documentation.",
"error.midaz.unknowError": "Error on Midaz.",
"errors.custom.date.invalid": "Invalid date",
"errors.custom.one_lowercase_letter": "Field must contain at least 1 lowercase letter",
Expand Down Expand Up @@ -379,5 +386,6 @@
"transactions.tab.operations": "Operations & Metadata",
"transactions.tab.summary": "Summary",
"transactions.title": "Transactions",
"transactions.toast.update.success": "Transaction updated successfully"
"transactions.toast.update.success": "Transaction updated successfully",
"transactions.toast.update.error": "Transaction updated Failed"
}
7 changes: 7 additions & 0 deletions locales/extracted/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@
"error.midaz.invalidScriptError": "O script fornecido na sua solicitação é inválido ou está em um formato incompatível. Verifique o formato do script e tente novamente.",
"error.midaz.duplicateProductNameError": "Já existe um produto com o nome para este ID contábil. Tente novamente com um razão ou nome diferente.",
"error.midaz.unauthorized": "O token fornecido está expirado, inválido ou malformado. Forneça um token válido e tente novamente.",
"error.midaz.accountIneligibilityError": "Uma ou mais contas listadas na transação não são elegíveis para participar. Revise o status da conta e tente novamente.",
"error.midaz.insufficientFundsError": "A transação não pôde ser concluída devido a fundos insuficientes na conta. Adicione fundos suficientes à sua conta e tente novamente.",
"error.midaz.invalidPathParameter": "O parâmetro de caminho fornecido não está no formato esperado. Certifique-se de que o parâmetro esteja de acordo com o formato exigido e tente novamente.",
"error.midaz.duplicateIdempotencyKey": "A chave de idempotência já está em uso. Forneça uma chave exclusiva e tente novamente.",
"error.midaz.badRequest": "O servidor não conseguiu entender a solicitação devido à sintaxe malformada. Verifique os campos listados e tente novamente.",
"error.midaz.externalAccountModificationProhibitedError": "As contas do tipo 'externas' não podem ser excluídas ou modificadas, pois são utilizadas para rastreabilidade com sistemas externos. Revise sua solicitação e certifique-se de que as operações sejam realizadas apenas em contas internas.",
"error.midaz.unexpectedFieldsInTheRequest": "O corpo da solicitação contém mais campos do que o esperado. Por favor envie apenas os campos permitidos conforme a documentação.",
"common.status": "Status",
"common.cancel": "Cancelar",
"common.confirm": "Confirmar",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const TRANSACTION_DETAILS_TAB_VALUES = {
SUMMARY: 'summary',
TRANSACTION_DATA: 'transaction-data',
OPERATIONS: 'operations'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import ConfirmationDialog from '@/components/confirmation-dialog'
import { useConfirmDialog } from '@/components/confirmation-dialog/use-confirm-dialog'
import { z } from 'zod'
import { zodResolver } from '@hookform/resolvers/zod'
import { TRANSACTION_DETAILS_TAB_VALUES } from './Transaction-details-tab-values'

interface TransactionValues {
chartOfAccountsGroupName?: string
Expand Down Expand Up @@ -50,7 +51,7 @@ const useTransactionForm = (
id: string
transactionId: string
}>()
const { showSuccess } = useCustomToast()
const { showSuccess, showError } = useCustomToast()
const { currentOrganization } = useOrganization()

const form = useForm<FormSchema>({
Expand All @@ -72,7 +73,16 @@ const useTransactionForm = (
})
)
onSave?.(form.getValues().description)
handleTabChange?.('summary')
handleTabChange?.(TRANSACTION_DETAILS_TAB_VALUES.SUMMARY)
},
onError: (error) => {
showError(
intl.formatMessage({
id: 'transactions.toast.update.error',
defaultMessage: 'An error occurred while updating the transaction'
})
),
handleTabChange?.(TRANSACTION_DETAILS_TAB_VALUES.SUMMARY)
}
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import { Separator } from '@/components/ui/separator'
import { useUpdateTransaction } from '@/client/transactions'
import { MetadataField } from '@/components/form'
import { PageFooter, PageFooterSection } from '@/components/page-footer'
import {
PaperCollapsible,
PaperCollapsibleBanner,
PaperCollapsibleContent
} from '@/components/transactions/primitives/paper-collapsible'
import { MetadataField } from '@/components/form'
import { Control, Form, useForm, useWatch } from 'react-hook-form'
import { useIntl } from 'react-intl'
import { Metadata } from '@/types/metadata-type'
import { useEffect, useState } from 'react'
import { useUpdateTransaction } from '@/client/transactions'
import { useParams } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { LoadingButton } from '@/components/ui/loading-button'
import { Separator } from '@/components/ui/separator'
import { useOrganization } from '@/context/organization-provider/organization-provider-client'
import useCustomToast from '@/hooks/use-custom-toast'
import { SaveSheet } from '../../overview/save-sheet'
import { PageFooter } from '@/components/page-footer'
import { ArrowRight } from 'lucide-react'
import { PageFooterSection } from '@/components/page-footer'
import { metadata } from '@/schema/metadata'
import { Metadata } from '@/types/metadata-type'
import { zodResolver } from '@hookform/resolvers/zod'
import { ArrowRight } from 'lucide-react'
import { useParams } from 'next/navigation'
import { z } from 'node_modules/zod/lib'
import { metadata } from '@/schema/metadata'
import { Button } from '@/components/ui/button'
import { LoadingButton } from '@/components/ui/loading-button'
import { useEffect, useState } from 'react'
import { Control, Form, useForm } from 'react-hook-form'
import { useIntl } from 'react-intl'

export type MetadataAccordionProps = {
name: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import { ArrowLeft, ArrowRight, MinusCircle, PlusCircle } from 'lucide-react'
import {
PaperCollapsible,
PaperCollapsibleBanner,
PaperCollapsibleContent
} from '@/components/transactions/primitives/paper-collapsible'
import { Separator } from '@/components/ui/separator'
import { MetadataField } from '@/components/form'
import { useIntl } from 'react-intl'
import { Control } from 'react-hook-form'
import { Input } from '@/components/ui/input'
import {
FormControl,
FormField,
FormItem,
FormMessage
} from '@/components/ui/form'
import { cn } from '@/lib/utils'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Separator } from '@/components/ui/separator'
import {
Tooltip,
TooltipTrigger,
TooltipContent,
TooltipProvider
TooltipProvider,
TooltipTrigger
} from '@/components/ui/tooltip'
import { useState, useEffect } from 'react'
import { cn } from '@/lib/utils'
import { ArrowLeft, ArrowRight, MinusCircle, PlusCircle } from 'lucide-react'
import { useEffect, useState } from 'react'
import { Control } from 'react-hook-form'
import { useIntl } from 'react-intl'
import { TransactionSourceFormSchema } from '../create/schemas'
import { useTransactionForm } from '../create/transaction-form-provider'
import { Label } from '@/components/ui/label'

type ValueFieldProps = {
name: string
Expand Down
Loading

0 comments on commit bdcebec

Please sign in to comment.