Skip to content

Commit

Permalink
added toast notfication
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritam12F committed Aug 11, 2024
1 parent 78d8566 commit daf9531
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/components/AddNewPayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { Label } from '@/components/ui/label';
import { Button } from './ui/button';
import axios from 'axios';
import { toast } from 'sonner';

export const AddPayout = () => {
type payoutType = 'upi' | 'solana';
Expand All @@ -23,7 +24,7 @@ export const AddPayout = () => {
};

return (
<diV className="mx-auto max-w-[500px] space-y-5">
<diV className="mx-auto my-10 max-w-[450px] space-y-5 rounded-md border-2 p-10">
<Label htmlFor="address" className="text-xl">
Enter details
</Label>
Expand All @@ -49,10 +50,17 @@ export const AddPayout = () => {
</div>
<Button
onClick={async () => {
await axios.post('/api/addpayout', {
payoutType,
address,
});
try {
await axios.post('/api/addpayout', {
payoutType,
address,
});
toast.success(
`Added ${payoutType === 'upi' ? payoutType.toUpperCase() : payoutType} successfully!`,
);
} catch {
toast.error('Error adding address!');
}
}}
>
Add {payoutType === 'upi' ? 'UPI' : 'Solana'}
Expand Down

0 comments on commit daf9531

Please sign in to comment.