Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: transfer modal from profile and change "transfer" with "send" #507

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/activate-subscription-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ export const ActivateSubscriptionProfileModal = ({
<Button variant="text" onClick={onClose}>
Cancel
</Button>
<RainbowEffect borderRadius={'10px'} animationSpeed={'3s'} padding={'0'} width={'auto'}>
<RainbowEffect
{...(loading && {
borderRadius: '10px',
animationSpeed: '3s',
padding: '0',
width: 'auto',
})}
>
<LoadingButton
variant="contained"
sx={{ backgroundColor: '#fff' }}
Expand Down
2 changes: 1 addition & 1 deletion src/components/follow-unfollow-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const FollowUnfollowButton = ({
title={isFollowed ? 'Unfollow' : 'Follow'}
variant={isFollowed ? 'outlined' : 'contained'}
sx={{
minWidth: followButtonMinWidth,
minWidth: { xs: 90, md: followButtonMinWidth },
backgroundColor: isFollowed ? '#24262A' : '#fff',
}}
onClick={(event) => {
Expand Down
10 changes: 6 additions & 4 deletions src/components/subscribe-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,12 @@ export const SubscribeProfileModal = ({
</Button>

<RainbowEffect
borderRadius={'10px'}
animationSpeed={'3s'}
padding={'0'}
width={'auto'}
{...(loading && {
borderRadius: '10px',
animationSpeed: '3s',
padding: '0',
width: 'auto',
})}
>
<LoadingButton
variant="contained"
Expand Down
44 changes: 32 additions & 12 deletions src/sections/finance/components/finance-quick-transfer-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useState} from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';

// MUI components
Expand All @@ -21,17 +21,18 @@ import LoadingButton from '@mui/lab/LoadingButton';
import { supabase } from '@src/utils/supabase';
import { useNotificationPayload } from '@src/hooks/use-notification-payload.ts';
import { useNotifications } from '@src/hooks/use-notifications.ts';
import {InputAmount, InputAmountProps} from '@src/components/input-amount.tsx';
import { InputAmount, InputAmountProps } from '@src/components/input-amount.tsx';
import { useTransfer } from '@src/hooks/use-transfer.ts';

// Notifications
import { notifyError, notifySuccess } from '@notifications/internal-notifications.ts';
import { SUCCESS } from '@notifications/success.ts';
import { ERRORS } from '@notifications/errors.ts';
import {dicebear} from "@src/utils/dicebear.ts";
import AvatarProfile from "@src/components/avatar/avatar.tsx";
import {MAX_POOL} from "@src/sections/finance/components/finance-quick-transfer.tsx";
import {handleAmountConstraints} from "@src/utils/format-number.ts";
import { dicebear } from '@src/utils/dicebear.ts';
import AvatarProfile from '@src/components/avatar/avatar.tsx';
import { MAX_POOL } from '@src/sections/finance/components/finance-quick-transfer.tsx';
import { handleAmountConstraints } from '@src/utils/format-number.ts';
import { useTheme } from '@mui/material/styles';

type TConfirmTransferDialogProps = InputAmountProps & DialogProps;

Expand All @@ -51,15 +52,15 @@ function FinanceQuickTransferModal({
onFinish,
address,
}: ConfirmTransferDialogProps) {
const theme = useTheme();
const sessionData = useSelector((state: any) => state.auth.session);
const { generatePayload } = useNotificationPayload(sessionData);
const { transfer, loading: transferLoading, error } = useTransfer();
const { sendNotification } = useNotifications();
const [message, setMessage] = useState('');

// For transfer button is clicked in some profile
const balance = useSelector((state: any) => state.auth.balance);
const MAX_AMOUNT = balance;
const MAX_AMOUNT = useSelector((state: any) => state.auth.balance);
const [value, setValue] = useState(0);
const [canContinue, setCanContinue] = useState(true);

Expand Down Expand Up @@ -165,7 +166,13 @@ function FinanceQuickTransferModal({

return (
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose}>
<DialogTitle>Transfer to</DialogTitle>
<DialogTitle sx={{
borderBottom: `dashed 1px ${theme.palette.divider}`,
padding: '16px 24px',
marginBottom: '8px'
}}>
Send to
</DialogTitle>
<Stack direction="column" spacing={3} sx={{ px: 3 }}>
<Stack
direction="row"
Expand Down Expand Up @@ -208,15 +215,28 @@ function FinanceQuickTransferModal({
/>
</Stack>

<DialogActions>
<DialogActions
sx={{
borderTop: `dashed 1px ${theme.palette.divider}`,
padding: '16px 24px',
marginTop: '24px'
}}
>
<Button onClick={onClose}>Cancel</Button>

<RainbowEffect borderRadius="10px" animationSpeed="3s" padding="0" width="auto">
<RainbowEffect
{...(transferLoading && {
borderRadius: '10px',
animationSpeed: '3s',
padding: '0',
width: 'auto',
})}
>
<LoadingButton
variant="contained"
sx={{ backgroundColor: '#fff' }}
onClick={handleConfirmTransfer}
disabled={transferLoading || !canContinue}
disabled={transferLoading || !canContinue || value <= 0}
loading={transferLoading}
>
Confirm
Expand Down
2 changes: 1 addition & 1 deletion src/sections/finance/components/finance-quick-transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export default function FinanceQuickTransfer({
disabled={amount === 0 || !isValidAddress(walletAddress) || !canContinue}
onClick={confirm.onTrue}
>
Quick transfer
Send
</Button>
</Stack>
);
Expand Down
2 changes: 1 addition & 1 deletion src/sections/user/profile-join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ProfileJoin: FC<ProfileJoinProps> = ({profile, profileJoinProps}) => {
title={hasAccess ? 'Joined' : 'Join'}
variant={hasAccess ? 'outlined' : 'contained'}
sx={{
minWidth: 120,
minWidth: { xs: 90, md: 120 },
backgroundColor: hasAccess ? '#24262A' : '#fff',
}}
onClick={handleSubscription}
Expand Down
4 changes: 2 additions & 2 deletions src/sections/user/profile-transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const ProfileTransfer: FC<ProfileTransferProps> = ({profile}) => {
return (
<>
<LoadingButton sx={{
minWidth: 120,
minWidth: { xs: 90, md: 120 },
backgroundColor: '#24262A',
}} variant={'outlined'} onClick={handleOpen}>
Transfer
Send
</LoadingButton>

<FinanceQuickTransferModal
Expand Down
Loading