diff --git a/src/components/Dashboard/TableRows/TableRowMobile/index.tsx b/src/components/Dashboard/TableRows/TableRowMobile/index.tsx
new file mode 100644
index 0000000..f30efb7
--- /dev/null
+++ b/src/components/Dashboard/TableRows/TableRowMobile/index.tsx
@@ -0,0 +1,48 @@
+import { memo } from 'react'
+import { FiTrash } from 'react-icons/fi'
+
+import { TransactionProps } from '..'
+import * as Table from '../../../Table'
+import { Button } from '../../../Button'
+
+type TableRowWebProps = {
+ transaction: TransactionProps
+ handleRemoveTransactionById: (id: string) => void
+}
+
+export function TableRowMobile({
+ transaction,
+ handleRemoveTransactionById,
+}: TableRowWebProps) {
+ return (
+ <>
+
+
{transaction.description}
+
+
+
+
+
+ {transaction.price}
+
+
+
{transaction.category}
+
{transaction.date}
+
+ >
+ )
+}
+
+export const TableRowMobileMemoized = memo(
+ TableRowMobile,
+ (prevProps, nextProps) => {
+ return prevProps.transaction.id === nextProps.transaction.id
+ },
+)
diff --git a/src/components/Dashboard/TableRows/TableRowWeb/index.tsx b/src/components/Dashboard/TableRows/TableRowWeb/index.tsx
new file mode 100644
index 0000000..54ce416
--- /dev/null
+++ b/src/components/Dashboard/TableRows/TableRowWeb/index.tsx
@@ -0,0 +1,39 @@
+import { memo } from 'react'
+import { FiTrash } from 'react-icons/fi'
+
+import { TransactionProps } from '..'
+import * as Table from '../../../Table'
+import { Button } from '../../../Button'
+
+type TableRowWebProps = {
+ transaction: TransactionProps
+ handleRemoveTransactionById: (id: string) => void
+}
+
+export function TableRowWeb({
+ transaction,
+ handleRemoveTransactionById,
+}: TableRowWebProps) {
+ return (
+ <>
+ {transaction.description}
+ {transaction.price}
+ {transaction.category}
+ {transaction.date}
+
+
+
+ >
+ )
+}
+
+export const TableRowWebMemoized = memo(TableRowWeb, (prevProps, nextProps) => {
+ return prevProps.transaction.id === nextProps.transaction.id
+})
diff --git a/src/components/Dashboard/TableRows/index.tsx b/src/components/Dashboard/TableRows/index.tsx
index e54e0ad..960e6ea 100644
--- a/src/components/Dashboard/TableRows/index.tsx
+++ b/src/components/Dashboard/TableRows/index.tsx
@@ -1,20 +1,21 @@
-import { FiTrash } from 'react-icons/fi'
-
import * as Table from '../../Table'
-import { Button } from '../../Button'
-import { Loading } from '../../Loading'
+// import { Loading } from '../../Loading'
+import { TableRowWebMemoized } from './TableRowWeb'
+import { TableRowMobileMemoized } from './TableRowMobile'
+import { ITransactions } from '../../../dto/transactions'
import { useTransactions } from '../../../hook/useTransactions'
import { useResponsiveness } from '../../../hook/useResponsiveness'
import { dateFormatter, priceFormatter } from '../../../utils/formatter'
+export type TransactionProps = Omit & {
+ date: string
+ price: string
+}
+
export function TableRows() {
const { isMobile } = useResponsiveness()
- const {
- transactions,
- handleRemoveTransactionById,
- isDeleteTransactionLoading,
- } = useTransactions()
+ const { transactions, handleRemoveTransactionById } = useTransactions()
return transactions.map((transaction) => {
const dataFormatted = dateFormatter.format(new Date(transaction.date))
@@ -22,69 +23,37 @@ export function TableRows() {
const priceFormattedWithSignalOrNot =
transaction.type === 'outcome' ? `- ${priceFormatted}` : priceFormatted
- const isLoadingIcon =
- isDeleteTransactionLoading.id === transaction.id &&
- isDeleteTransactionLoading.value
-
- const buttonIcon = isLoadingIcon ? (
-
- ) : (
-
- )
+ const transactionData: TransactionProps = {
+ ...transaction,
+ date: dataFormatted,
+ price: priceFormattedWithSignalOrNot,
+ }
+
+ // This branch will not use json-server, but localStorage so don't need this
+ // const isLoadingIcon =
+ // isDeleteTransactionLoading.id === transaction.id &&
+ // isDeleteTransactionLoading.value
+ // const buttonIcon = isLoadingIcon ? (
+ //
+ // ) : (
+ //
+ // )
return (
{isMobile ? (
- <>
-
-
- {transaction.description}
-
-
-
-
-
-
-
- {priceFormattedWithSignalOrNot}
-
-
-
-
{transaction.category}
-
{dataFormatted}
-
- >
+
) : (
- <>
-
- {transaction.description}
-
-
- {priceFormattedWithSignalOrNot}
-
- {transaction.category}
- {dataFormatted}
-
-
-
- >
+
)}
)