Skip to content

Commit

Permalink
refactor: added extra comments a some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geolffreym committed Jan 1, 2025
1 parent 5598d8e commit d0fec55
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/hooks/use-deposit-metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ import { GLOBAL_CONSTANTS } from '@src/config-global';
import { publicClient } from '@src/clients/viem/publicClient';
import { useSnackbar } from 'notistack';

// AND HERE
interface VaultError {
message: string;
code?: number;
[key: string]: any;
}

// SAME HERE
interface DepositParams {
recipient: string; // The address receiving the deposit
amount: number; // Amount in "human" format (not in Wei)
}

// TODO this could be handled in one interface in a type.tsx file
// is duplicated in use-deposit, this MUST be reusable
interface UseDepositHook {
data?: any;
deposit: (params: DepositParams) => Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface DepositParams {
amount: number; // plain number
}

interface UseDepositHook {
export interface UseDepositHook {
data?: any;
deposit: (params: DepositParams) => Promise<void>;
loading: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface FinanceDepositFromMetamaskProps {
onClose: () => void;
}

// TODO please finance-deposit.tsx
const FinanceDepositFromMetamask: FC<FinanceDepositFromMetamaskProps> = ({ onClose }) => {
const [address, setAddress] = useState<Address | undefined>();
const { balance } = useGetMmcContractBalance(address);
Expand Down Expand Up @@ -72,7 +73,7 @@ const FinanceDepositFromMetamask: FC<FinanceDepositFromMetamaskProps> = ({ onClo
} else {
enqueueSnackbar("Invalid deposit amount", { variant: "warning" });
}
}, [sessionData?.address]);
}, [sessionData?.address, amount, balance]);

const RainbowEffect = loading || depositLoading ? NeonPaper : Box;
const mdUp = useResponsive('up', 'md');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ interface FinanceDepositFromSmartAccountProps {
onClose: () => void;
}

// TODO please finance-deposit.tsx
const FinanceDepositFromSmartAccount: FC<FinanceDepositFromSmartAccountProps> = ({ onClose }) => {
// TODO Use this component as generic finance deposit and create new sub components for metamask & smart account
// TODO Please keep declaration on top
const [amount, setAmount] = useState<number>(0);
const [loading, setLoading] = useState(false);
Expand All @@ -42,7 +44,7 @@ const FinanceDepositFromSmartAccount: FC<FinanceDepositFromSmartAccountProps> =
useEffect(() => {
if (error) errorDuringDeposit()
}, [error]);

const handleConfirmDeposit = useCallback(async () => {
// fail fast
// TODO validation formatUint(amount) > balance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ type TransactionsProcessedData = {
}

export default function FinanceTransactionsHistory({ transactionData }: TransactionsProcessedData) {
console.log('processedTransactions passed:', transactionData);
const table = useTable({ defaultOrderBy: 'name' });

const [tableData, _setTableData] = useState(transactionData);

const [filters, setFilters] = useState(defaultFilters);

const dataFiltered = applyFilter({
Expand All @@ -62,14 +59,9 @@ export default function FinanceTransactionsHistory({ transactionData }: Transact
});

const denseHeight = table.dense ? 52 : 72;

const canReset = filters.status !== 'all';

const notFound = (!dataFiltered.length && canReset) || !dataFiltered.length;

console.log('Data:', tableData);
console.log('Date Filtered:', dataFiltered);

const handleFilters = useCallback(
(name: string, value: IOrderTableFilterValue) => {
table.onResetPage();
Expand Down

0 comments on commit d0fec55

Please sign in to comment.