MCPcopy Create free account
hub / github.com/code100x/cms / PaymentMethodsDropdown

Function PaymentMethodsDropdown

src/components/PaymentDropdown.tsx:17–174  ·  view source on GitHub ↗
({
  upiAddresses,
  solanaAddresses,
  fetchPayoutMethods,
}: PaymentMethodsDropdownProps)

Source from the content-addressed store, hash-verified

15}
16
17export default function PaymentMethodsDropdown({
18 upiAddresses,
19 solanaAddresses,
20 fetchPayoutMethods,
21}: PaymentMethodsDropdownProps) {
22 const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
23 const [isPayoutDialogOpen, setIsPayoutDialogOpen] = useState<boolean>(false);
24 const [btnClicked, setBtnClicked] = useState<string>('');
25
26 const { execute: executeDeleteUPI } = useAction(deleteUpiId, {
27 onSuccess: () => {
28 toast.success('UPI Address deleted successfully');
29 fetchPayoutMethods();
30 },
31 onError: () => {
32 toast.error('Failed to delete UPI address');
33 },
34 });
35
36 const { execute: executeDeleteSolana } = useAction(deleteSolanaAddress, {
37 onSuccess: () => {
38 toast.success('Solana Address deleted successfully');
39 fetchPayoutMethods();
40 },
41 onError: () => {
42 toast.error('Failed to delete Solana address');
43 },
44 });
45
46 const handleUpiDelete = (id: number) => {
47 executeDeleteUPI({ id });
48 };
49
50 const handleSolanaDelete = (id: number) => {
51 executeDeleteSolana({ id });
52 };
53
54 useEffect(() => {
55 fetchPayoutMethods();
56 }, [isPayoutDialogOpen]);
57
58 return (
59 <>
60 <Button
61 onClick={() => setIsDropdownOpen(!isDropdownOpen)}
62 className="mt-5 flex w-full items-center justify-between py-2 text-white transition-colors duration-500 hover:bg-gray-900 dark:text-black dark:hover:bg-gray-700"
63 >
64 {isDropdownOpen ? (
65 <>
66 <span>Hide Your Details</span>
67 <ChevronUp className="ml-2" />
68 </>
69 ) : (
70 <>
71 <span>Edit Your Payment Details</span>
72 <ChevronDown className="ml-2" />
73 </>
74 )}

Callers

nothing calls this directly

Calls 4

useActionFunction · 0.90
handleUpiDeleteFunction · 0.85
handleSolanaDeleteFunction · 0.85
fetchPayoutMethodsFunction · 0.50

Tested by

no test coverage detected