Skip to content

Commit 4735a4b

Browse files
committed
refactor(login): get "do you know" in server action
1 parent 6a6d268 commit 4735a4b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

app/login/_components/do-you-know/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ import { connection } from "next/server";
55
export default async function DoYouKnow() {
66
await connection();
77

8+
const randomKnow = await getDoYouKnow();
9+
10+
return (
11+
<div className="flex flex-col justify-center gap-2 text-center">
12+
<div className="text-sm text-gray-500">你知道嗎?</div>
13+
<div className="font-normal">{randomKnow}</div>
14+
</div>
15+
);
16+
}
17+
18+
export async function getDoYouKnow() {
819
const knowsList = [
920
<p key="do-you-knows-daily-login">
1021
每天登入可以獲得 20 點點數,<br />連續 7 天登入可以獲得 50 點加成!
@@ -21,10 +32,6 @@ export default async function DoYouKnow() {
2132
];
2233

2334
const randomKnow = knowsList[Math.floor(Math.random() * knowsList.length)];
24-
return (
25-
<div className="flex flex-col justify-center gap-2 text-center">
26-
<div className="text-sm text-gray-500">你知道嗎?</div>
27-
<div className="font-normal">{randomKnow}</div>
28-
</div>
29-
);
35+
36+
return randomKnow;
3037
}

0 commit comments

Comments
 (0)