Skip to content

Commit 7b0ece9

Browse files
authored
Merge pull request accesslayerorg#20 from joelpeace48-cell/feat/issues-13-16
feat(ui): add social handle row (accesslayerorg#13) & reusable transaction success toast
2 parents f70bd7f + 884da30 commit 7b0ece9

4 files changed

Lines changed: 68 additions & 26 deletions

File tree

src/components/common/CreatorCard.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { useAccount } from 'wagmi';
22
import { Button } from '@/components/ui/button';
33
import type { Course } from '@/services/course.service';
44
import { cn } from '@/lib/utils';
5-
import { ShoppingCart, Wallet } from 'lucide-react';
5+
import { ShoppingCart, Wallet, Link as LinkIcon } from 'lucide-react';
66
import toast from 'react-hot-toast';
7+
import showToast from '@/utils/toast.util';
78

89
interface CreatorCardProps {
910
creator: Course;
@@ -22,10 +23,14 @@ const CreatorCard: React.FC<CreatorCardProps> = ({ creator, className }) => {
2223
return;
2324
}
2425

25-
toast.success(`Purchasing keys for ${creator.title}...`, {
26-
duration: 3000,
27-
});
26+
showToast.loading(`Purchasing keys for ${creator.title}...`);
2827
// Implementation for contract interaction would go here
28+
setTimeout(() => {
29+
showToast.transactionSuccess(
30+
'Purchase Successful!',
31+
`You successfully bought a key for ${creator.title}`
32+
);
33+
}, 1500);
2934
};
3035

3136
return (
@@ -51,6 +56,17 @@ const CreatorCard: React.FC<CreatorCardProps> = ({ creator, className }) => {
5156
<p className="font-jakarta text-sm text-white/50">
5257
@{creator.instructorId || 'creator'}
5358
</p>
59+
{creator.socialHandle ? (
60+
<div className="mt-2 flex items-center gap-1.5 text-xs text-white/60">
61+
<LinkIcon className="size-3 text-amber-500/70" />
62+
<span className="truncate">@{creator.socialHandle}</span>
63+
</div>
64+
) : (
65+
<div className="mt-2 flex items-center gap-1.5 text-xs text-white/30 italic">
66+
<LinkIcon className="size-3 opacity-50" />
67+
<span>No public handle</span>
68+
</div>
69+
)}
5470
</div>
5571

5672
<div className="flex items-center justify-between gap-4">

src/services/course.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface Course {
1010
thumbnail?: string;
1111
category: string;
1212
level: 'BEGINNER' | 'INTERMEDIATE' | 'ADVANCED';
13+
socialHandle?: string;
1314
}
1415

1516
export interface GetCoursesParams {

src/utils/toast.util.ts

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

src/utils/toast.util.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import toast from "react-hot-toast";
2+
3+
const showToast = {
4+
message: (message: string) => {
5+
toast.remove();
6+
toast(message);
7+
},
8+
success: (message: string) => {
9+
toast.remove();
10+
toast.success(message);
11+
},
12+
error: (message: string) => {
13+
toast.remove();
14+
toast.error(message);
15+
},
16+
loading: (message: string) => {
17+
toast.remove();
18+
toast.loading(message);
19+
},
20+
transactionSuccess: (title: string, message?: string) => {
21+
toast.remove();
22+
toast.custom((t) => (
23+
<div
24+
className={`${
25+
t.visible ? 'animate-enter' : 'animate-leave'
26+
} pointer-events-auto flex w-full max-w-sm rounded-xl border border-amber-500/20 bg-slate-900 shadow-xl shadow-amber-500/10`}
27+
>
28+
<div className="flex w-full p-4">
29+
<div className="flex items-start">
30+
<div className="ml-3 flex-1">
31+
<p className="font-jakarta text-sm font-bold text-white">
32+
{title}
33+
</p>
34+
{message && (
35+
<p className="mt-1 font-jakarta text-sm text-white/60">
36+
{message}
37+
</p>
38+
)}
39+
</div>
40+
</div>
41+
</div>
42+
</div>
43+
), { duration: 4000 });
44+
},
45+
};
46+
47+
export default showToast;

0 commit comments

Comments
 (0)