Skip to content

Commit 32b3d01

Browse files
noahlitvin0xusecannonnicosampler
authored
fix(website): toasts
Co-authored-by: 0xusecannon <noreply@usecannon.com> Co-authored-by: nicosampler <nf.dominguez.87@gmail.com>
1 parent 9757bc3 commit 32b3d01

File tree

18 files changed

+72
-439
lines changed

18 files changed

+72
-439
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client';
2+
3+
import { Toaster } from '@/components/ui/sonner';
4+
5+
export function ToasterProvider() {
6+
return <Toaster />;
7+
}

packages/website/src/components/ui/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const alertVariants = cva(
1111
default: 'bg-background text-foreground border-border',
1212
info: 'bg-teal-100/10 text-teal-100 border-border border-teal-100/20',
1313
destructive:
14-
'border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive',
14+
'bg-destructive text-destructive-foreground border-destructive/70 [&>svg]:text-destructive-foreground',
1515
warning:
1616
'bg-yellow-100/10 text-yellow-100 border-border border-yellow-100/20',
1717
},

packages/website/src/components/ui/sonner.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import React from 'react';
12
import { useTheme } from 'next-themes';
23
import { Toaster as Sonner } from 'sonner';
3-
import React from 'react';
44

55
type ToasterProps = React.ComponentProps<typeof Sonner>;
66

@@ -22,6 +22,8 @@ const Toaster = ({ ...props }: ToasterProps) => {
2222
'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
2323
},
2424
}}
25+
position="bottom-right"
26+
richColors
2527
{...props}
2628
/>
2729
);

packages/website/src/components/ui/toast.tsx

Lines changed: 0 additions & 127 deletions
This file was deleted.

packages/website/src/components/ui/toaster.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/website/src/features/Deploy/PackageErrors.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
22

33
export function PackageErrors({ error }: { error?: string }) {
44
return error == null ? null : (
5-
<Alert className="mt-4" variant="destructive">
5+
<Alert className="mb-4" variant="destructive">
66
<AlertDescription>{error}</AlertDescription>
77
</Alert>
88
);

packages/website/src/features/Deploy/PrepareNetwork.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
CardHeader,
88
CardTitle,
99
} from '@/components/ui/card';
10-
import { useToast } from '@/hooks/use-toast';
10+
import { toast } from 'sonner';
1111
import {
1212
useGasPrice,
1313
usePrepareTransactionRequest,
@@ -43,7 +43,6 @@ export default function PrepareNetwork({
4343
const currentSafe = useStore((s) => s.currentSafe);
4444
// Uncomment the following line to use test with local network
4545
// const currentSafe = { chainId: 31337 };
46-
const { toast } = useToast();
4746

4847
useEffect(() => {
4948
if (!isConnected && openConnectModal) {
@@ -76,10 +75,8 @@ export default function PrepareNetwork({
7675

7776
await deterministicDeployerBytecode.refetch();
7877

79-
toast({
80-
title: 'Deterministic Deployer Deployed',
78+
toast('Deterministic Deployer Deployed', {
8179
description: 'The deterministic deployer has been deployed.',
82-
variant: 'default',
8380
});
8481
},
8582
},
@@ -117,10 +114,8 @@ export default function PrepareNetwork({
117114
onSuccess: async () => {
118115
await onchainStoreBytecode.refetch();
119116

120-
toast({
121-
title: 'Onchain Store Deployed',
117+
toast('Onchain Store Deployed', {
122118
description: 'The onchain store has been deployed.',
123-
variant: 'default',
124119
});
125120
},
126121
},
@@ -149,10 +144,8 @@ export default function PrepareNetwork({
149144
onSuccess: async () => {
150145
await multicallForwarderBytecode.refetch();
151146

152-
toast({
153-
title: 'Multicall Forwarder Deployed',
147+
toast('Multicall Forwarder Deployed', {
154148
description: 'The multicall forwarder has been deployed.',
155-
variant: 'default',
156149
});
157150
},
158151
},

packages/website/src/features/Deploy/PublishUtility.tsx

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
2424
import { Button } from '@/components/ui/button';
2525
import Image from 'next/image';
2626
import Link from 'next/link';
27-
import { useToast } from '@/hooks/use-toast';
27+
import { toast } from 'sonner';
2828
import {
2929
Tooltip,
3030
TooltipContent,
@@ -41,7 +41,6 @@ export default function PublishUtility(props: {
4141

4242
const wc = useWalletClient();
4343
const { switchChainAsync } = useSwitchChain();
44-
const { toast } = useToast();
4544

4645
// get the package referenced by this ipfs package
4746
const {
@@ -151,15 +150,9 @@ export default function PublishUtility(props: {
151150
// eslint-disable-next-line no-console
152151
console.error(err);
153152
if (err.message.includes('exceeds the balance of the account')) {
154-
toast({
155-
title: 'Error Publishing Package: Insufficient Funds',
156-
variant: 'destructive',
157-
});
153+
toast.error('Error Publishing Package: Insufficient Funds');
158154
} else {
159-
toast({
160-
title: 'Error Publishing Package',
161-
variant: 'destructive',
162-
});
155+
toast.error('Error Publishing Package');
163156
}
164157
},
165158
});
@@ -176,15 +169,9 @@ export default function PublishUtility(props: {
176169
console.error(err);
177170

178171
if (err.message.includes('exceeds the balance of the account')) {
179-
toast({
180-
title: 'Error Publishing Package: Insufficient Funds',
181-
variant: 'destructive',
182-
});
172+
toast.error('Error Publishing Package: Insufficient Funds');
183173
} else {
184-
toast({
185-
title: 'Error Publishing Package',
186-
variant: 'destructive',
187-
});
174+
toast.error('Error Publishing Package');
188175
}
189176
},
190177
});

packages/website/src/features/Deploy/QueueDrawer.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
SheetHeader,
3838
SheetTitle,
3939
} from '@/components/ui/sheet';
40-
import { useToast } from '@/hooks/use-toast';
40+
import { toast } from 'sonner';
4141

4242
// Because of a weird type cohercion, after using viem.isAddress during website build,
4343
// the string type of the given value gets invalid to "never", and breaks the build.
@@ -103,8 +103,6 @@ export const QueuedTxns = ({
103103

104104
const txnInfo = useSimulatedTxns(currentSafe as any, queuedTxns);
105105

106-
const { toast } = useToast();
107-
108106
const stager = useTxnStager(
109107
targetTxn
110108
? {
@@ -129,10 +127,7 @@ export const QueuedTxns = ({
129127
async onSignComplete() {
130128
if (onDrawerClose) onDrawerClose();
131129
await router.push(links.DEPLOY);
132-
toast({
133-
title: 'You successfully signed the transaction.',
134-
variant: 'default',
135-
});
130+
toast.success('You successfully signed the transaction.');
136131

137132
setQueuedIdentifiableTxns({
138133
queuedIdentifiableTxns: [],
@@ -542,11 +537,9 @@ export const QueuedTxns = ({
542537
onSuccess: async () => {
543538
await router.push(links.DEPLOY);
544539

545-
toast({
546-
title:
547-
'You successfully executed the transaction.',
548-
variant: 'default',
549-
});
540+
toast.success(
541+
'You successfully executed the transaction.'
542+
);
550543
},
551544
});
552545
}}

0 commit comments

Comments
 (0)