-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.text
41 lines (23 loc) · 877 Bytes
/
help.text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
///////Server Side User /////////////////
import { currentUser } from "@/lib/auth";
const user = await currentUser() as User | undefined;
///////Client Side User /////////////////
import { useCurrentUser } from "@/hooks/use-current-user";
const user = useCurrentUser();
-------
import { useSession } from "next-auth/react";
const session = useSession();
session.data?.user.role;
const { data: session } = useSession();
--------
///////// Manage Credits for Usage
import { CreditsProvider, useCredits } from '@/context/CreditsContext';
const { credits, addCredits, spendCredits } = useCredits();
const handleAddCredits = async () => {
await addCredits('user-id', 50); // Replace 'user-id' with actual ID
};
const handleSpendCredits = async () => {
await spendCredits('user-id', 10); // Replace 'user-id' with actual ID
};
///////// Test Card
4242424242424242