Spaces:
Sleeping
Sleeping
Commit
·
2b235a9
1
Parent(s):
5081fcb
chore: remove unused file
Browse files
app/components/chatbot/chat-bot-card.tsx
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
// Move the existing ChatBotCard component here with no changes needed
|
2 |
-
// This is already well-structured as a reusable component
|
|
|
|
|
|
app/components/chatbot/chat-bot-grid.tsx
DELETED
@@ -1,152 +0,0 @@
|
|
1 |
-
"use client";
|
2 |
-
|
3 |
-
import { useState, useEffect } from "react";
|
4 |
-
import ChatBotCard from "@/app/(audiences)/components/chat-bot-card";
|
5 |
-
import { ChatBot } from "@/types/chatbot";
|
6 |
-
|
7 |
-
interface SectionProps {
|
8 |
-
title: string;
|
9 |
-
subtitle: string;
|
10 |
-
bots: ChatBot[];
|
11 |
-
columns?: number;
|
12 |
-
}
|
13 |
-
|
14 |
-
function Section({ title, subtitle, bots, columns = 4 }: SectionProps) {
|
15 |
-
if (bots.length === 0) return null;
|
16 |
-
|
17 |
-
return (
|
18 |
-
<div className="mb-16">
|
19 |
-
<div className="mb-8">
|
20 |
-
<h2 className="text-2xl font-bold text-text-primary mb-2">{title}</h2>
|
21 |
-
<p className="text-text-secondary">{subtitle}</p>
|
22 |
-
</div>
|
23 |
-
<div className={`grid gap-4 sm:grid-cols-2 lg:grid-cols-${columns}`}>
|
24 |
-
{bots.map((chatbot) => (
|
25 |
-
<ChatBotCard key={chatbot.id} chatbot={chatbot} />
|
26 |
-
))}
|
27 |
-
</div>
|
28 |
-
</div>
|
29 |
-
);
|
30 |
-
}
|
31 |
-
|
32 |
-
interface ChatBotGridProps {
|
33 |
-
selectedCategories: string[];
|
34 |
-
selectedSubjects: string[];
|
35 |
-
searchQuery: string;
|
36 |
-
getPopularBots: () => ChatBot[];
|
37 |
-
getTrendingBots: () => ChatBot[];
|
38 |
-
getAllBots: () => ChatBot[];
|
39 |
-
}
|
40 |
-
|
41 |
-
export default function ChatBotGrid({
|
42 |
-
selectedCategories,
|
43 |
-
selectedSubjects,
|
44 |
-
searchQuery,
|
45 |
-
getPopularBots,
|
46 |
-
getTrendingBots,
|
47 |
-
getAllBots,
|
48 |
-
}: ChatBotGridProps) {
|
49 |
-
const [filteredPopularBots, setFilteredPopularBots] =
|
50 |
-
useState<ChatBot[]>(getPopularBots());
|
51 |
-
const [filteredTrendingBots, setFilteredTrendingBots] =
|
52 |
-
useState<ChatBot[]>(getTrendingBots());
|
53 |
-
const [filteredAllBots, setFilteredAllBots] =
|
54 |
-
useState<ChatBot[]>(getAllBots());
|
55 |
-
|
56 |
-
useEffect(() => {
|
57 |
-
const filterBots = (bots: ChatBot[]) => {
|
58 |
-
let filtered = bots;
|
59 |
-
|
60 |
-
if (searchQuery) {
|
61 |
-
const query = searchQuery.toLowerCase();
|
62 |
-
filtered = filtered.filter(
|
63 |
-
(bot) =>
|
64 |
-
bot.title.toLowerCase().includes(query) ||
|
65 |
-
bot.description.toLowerCase().includes(query) ||
|
66 |
-
bot.subject.toLowerCase().includes(query) ||
|
67 |
-
bot.category.toLowerCase().includes(query),
|
68 |
-
);
|
69 |
-
}
|
70 |
-
|
71 |
-
if (selectedCategories.length > 0) {
|
72 |
-
filtered = filtered.filter(
|
73 |
-
(bot) => bot.category && selectedCategories.includes(bot.category),
|
74 |
-
);
|
75 |
-
}
|
76 |
-
|
77 |
-
if (selectedSubjects.length > 0) {
|
78 |
-
filtered = filtered.filter((bot) =>
|
79 |
-
selectedSubjects.includes(bot.subject),
|
80 |
-
);
|
81 |
-
}
|
82 |
-
|
83 |
-
return filtered;
|
84 |
-
};
|
85 |
-
|
86 |
-
setFilteredPopularBots(filterBots(getPopularBots()));
|
87 |
-
setFilteredTrendingBots(filterBots(getTrendingBots()));
|
88 |
-
setFilteredAllBots(filterBots(getAllBots()));
|
89 |
-
}, [
|
90 |
-
selectedCategories,
|
91 |
-
selectedSubjects,
|
92 |
-
searchQuery,
|
93 |
-
getPopularBots,
|
94 |
-
getTrendingBots,
|
95 |
-
getAllBots,
|
96 |
-
]);
|
97 |
-
|
98 |
-
const hasFiltersOrSearch =
|
99 |
-
selectedCategories.length > 0 || selectedSubjects.length > 0 || searchQuery;
|
100 |
-
|
101 |
-
if (hasFiltersOrSearch) {
|
102 |
-
return (
|
103 |
-
<Section
|
104 |
-
title="搜尋結果"
|
105 |
-
subtitle={`符合 ${searchQuery ? '"' + searchQuery + '" ' : ""}的工具`}
|
106 |
-
bots={filteredAllBots}
|
107 |
-
columns={4}
|
108 |
-
/>
|
109 |
-
);
|
110 |
-
}
|
111 |
-
|
112 |
-
const tutorBots = filteredAllBots.filter((bot) => bot.category === "教育");
|
113 |
-
const teachingBots = filteredAllBots.filter((bot) => bot.subject === "教學");
|
114 |
-
const assessmentBots = filteredAllBots.filter(
|
115 |
-
(bot) => bot.subject === "評量",
|
116 |
-
);
|
117 |
-
|
118 |
-
return (
|
119 |
-
<div className="space-y-8">
|
120 |
-
<Section
|
121 |
-
title="精選"
|
122 |
-
subtitle="歷來最多人使用的工具"
|
123 |
-
bots={filteredPopularBots}
|
124 |
-
columns={4}
|
125 |
-
/>
|
126 |
-
<Section
|
127 |
-
title="熱門"
|
128 |
-
subtitle="近期最多人使用的工具"
|
129 |
-
bots={filteredTrendingBots}
|
130 |
-
columns={4}
|
131 |
-
/>
|
132 |
-
<Section
|
133 |
-
title="教學輔助"
|
134 |
-
subtitle="教學規劃與課程設計工具"
|
135 |
-
bots={teachingBots}
|
136 |
-
columns={4}
|
137 |
-
/>
|
138 |
-
<Section
|
139 |
-
title="評量工具"
|
140 |
-
subtitle="作業與評量相關工具"
|
141 |
-
bots={assessmentBots}
|
142 |
-
columns={4}
|
143 |
-
/>
|
144 |
-
<Section
|
145 |
-
title="教育資源"
|
146 |
-
subtitle="其他教育相關工具"
|
147 |
-
bots={tutorBots}
|
148 |
-
columns={4}
|
149 |
-
/>
|
150 |
-
</div>
|
151 |
-
);
|
152 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|