Skip to content

Commit

Permalink
📈 installments: track
Browse files Browse the repository at this point in the history
  • Loading branch information
sebipap committed Apr 19, 2024
1 parent fe4bada commit 1582929
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions components/operations/BorrowAtMaturity/Installments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import { Box, Typography } from '@mui/material';
import { MATURITY_DAYS } from 'utils/utils';
import ModalAlert from 'components/common/modal/ModalAlert';
import InstallmentsOptions from './InstallmentsOptions';
import { track } from 'utils/mixpanel';

export default function Installments({ setBreakdownSheetOpen }: { setBreakdownSheetOpen: (open: boolean) => void }) {
const { t } = useTranslation();
const { installments } = useOperationContext();

const viewBreakdown = useCallback(() => {
setBreakdownSheetOpen(true);
track('Button Clicked', {
name: 'Payment Schedule',
location: 'Operations Modal',
});
}, [setBreakdownSheetOpen]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useAccountData from 'hooks/useAccountData';
import { formatUnits } from 'viem';
import { Box, Skeleton, Typography } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { track } from 'utils/mixpanel';

type OptionProps = {
installments: number;
Expand Down Expand Up @@ -45,9 +46,15 @@ export default function InstallmentsOptions() {

const handleChange = useCallback(
(option: { installments: number }) => {
track('Option Selected', {
name: 'Installments',
location: 'Operations Modal',
value: option.installments,
prevValue: installments,
});
onInstallmentsChange(option.installments);
},
[onInstallmentsChange],
[installments, onInstallmentsChange],
);

const option = useMemo(() => {
Expand Down
17 changes: 16 additions & 1 deletion hooks/useBorrowInInstallments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,22 @@ export default function useBorrowInInstallments() {
if (!installmentsBorrow.write) return;
installmentsBorrow.write();
}
}, [installmentsBorrow, installmentsBorrowETH, isBorrowETH]);
track('TX Signed', {
contractName: 'InstallmentsRouter',
method: 'borrow',
symbol,
amount: installmentsDetails?.installmentsPrincipal.map(String).join(','),
hash: installmentsBorrowETH.data?.hash || '0x',
maturity: Number(date),
});
}, [
date,
installmentsBorrow,
installmentsBorrowETH,
installmentsDetails?.installmentsPrincipal,
isBorrowETH,
symbol,
]);

const needsApproval = useMemo(() => {
if (allowance.data === undefined) return true;
Expand Down

0 comments on commit 1582929

Please sign in to comment.