fix: try fix lint

Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
2026-01-15 19:55:04 +08:00
parent 9965b3e1ce
commit a7caf9fdf5
4 changed files with 57 additions and 42 deletions

View File

@@ -53,6 +53,11 @@ auth.get("/callback", async (c) => {
// Exchange code for user access token and user info // Exchange code for user access token and user info
const userData = await feishuClient.getUserAccessToken(code); const userData = await feishuClient.getUserAccessToken(code);
if (!userData) {
logger.error("[Auth] Failed to get user data from code");
return c.json({ error: "Failed to get user info from Feishu" }, 500);
}
// Check if user exists, otherwise create // Check if user exists, otherwise create
let user = await db.query.users.findFirst({ let user = await db.query.users.findFirst({
where: eq(users.feishuUserId, userData.open_id), where: eq(users.feishuUserId, userData.open_id),

View File

@@ -8,6 +8,9 @@ export interface UserAccessTokenData {
refresh_token: string; refresh_token: string;
refresh_expires_in: number; refresh_expires_in: number;
scope: string; scope: string;
name: string;
open_id: string;
email?: string;
} }
export class FeishuClient { export class FeishuClient {

View File

@@ -35,30 +35,33 @@ export default function AdminView() {
<button <button
type="button" type="button"
onClick={() => setActiveTab("load")} onClick={() => setActiveTab("load")}
className={`${activeTab === "load" className={`${
activeTab === "load"
? "border-indigo-500 text-indigo-600" ? "border-indigo-500 text-indigo-600"
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`} } whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
> >
System Load System Load
</button> </button>
<button <button
type="button" type="button"
onClick={() => setActiveTab("requests")} onClick={() => setActiveTab("requests")}
className={`${activeTab === "requests" className={`${
activeTab === "requests"
? "border-indigo-500 text-indigo-600" ? "border-indigo-500 text-indigo-600"
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`} } whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
> >
Topic Requests Topic Requests
</button> </button>
<button <button
type="button" type="button"
onClick={() => setActiveTab("topics")} onClick={() => setActiveTab("topics")}
className={`${activeTab === "topics" className={`${
activeTab === "topics"
? "border-indigo-500 text-indigo-600" ? "border-indigo-500 text-indigo-600"
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`} } whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
> >
All Topics All Topics
</button> </button>
@@ -167,12 +170,13 @@ function TopicsManagement() {
</td> </td>
<td className="px-6 py-4 whitespace-nowrap"> <td className="px-6 py-4 whitespace-nowrap">
<span <span
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${topic.status === "approved" className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
topic.status === "approved"
? "bg-green-100 text-green-800" ? "bg-green-100 text-green-800"
: topic.status === "rejected" : topic.status === "rejected"
? "bg-red-100 text-red-800" ? "bg-red-100 text-red-800"
: "bg-yellow-100 text-yellow-800" : "bg-yellow-100 text-yellow-800"
}`} }`}
> >
{topic.status} {topic.status}
</span> </span>

View File

@@ -219,20 +219,20 @@ export default function TopicsView() {
const updatedSubs = isSubscribed const updatedSubs = isSubscribed
? t.subscriptions.filter((s) => s.userId !== userId) ? t.subscriptions.filter((s) => s.userId !== userId)
: [ : [
...t.subscriptions, ...t.subscriptions,
{ {
userId, userId,
user: user:
users.find((u) => u.id === userId) || users.find((u) => u.id === userId) ||
(currentUser (currentUser
? { ? {
id: currentUser.id, id: currentUser.id,
name: currentUser.name, name: currentUser.name,
email: currentUser.email, email: currentUser.email,
} }
: { id: "unknown", name: "Unknown" }), : { id: "unknown", name: "Unknown" }),
}, },
]; ];
return { ...t, subscriptions: updatedSubs }; return { ...t, subscriptions: updatedSubs };
} }
return t; return t;
@@ -244,20 +244,20 @@ export default function TopicsView() {
const updatedSubs = isSubscribed const updatedSubs = isSubscribed
? selectedTopic.subscriptions.filter((s) => s.userId !== userId) ? selectedTopic.subscriptions.filter((s) => s.userId !== userId)
: [ : [
...selectedTopic.subscriptions, ...selectedTopic.subscriptions,
{ {
userId, userId,
user: user:
users.find((u) => u.id === userId) || users.find((u) => u.id === userId) ||
(currentUser (currentUser
? { ? {
id: currentUser.id, id: currentUser.id,
name: currentUser.name, name: currentUser.name,
email: currentUser.email, email: currentUser.email,
} }
: { id: "unknown", name: "Unknown" }), : { id: "unknown", name: "Unknown" }),
}, },
]; ];
setSelectedTopic({ ...selectedTopic, subscriptions: updatedSubs }); setSelectedTopic({ ...selectedTopic, subscriptions: updatedSubs });
} }
@@ -429,10 +429,11 @@ export default function TopicsView() {
<button <button
type="button" type="button"
onClick={() => handleSelfSubscribe(topic)} onClick={() => handleSelfSubscribe(topic)}
className={`inline-flex items-center px-3 py-1 border text-xs font-medium rounded-md ${isSubscribedToTopic(topic) className={`inline-flex items-center px-3 py-1 border text-xs font-medium rounded-md ${
isSubscribedToTopic(topic)
? "border-red-300 text-red-700 bg-red-50 hover:bg-red-100" ? "border-red-300 text-red-700 bg-red-50 hover:bg-red-100"
: "border-green-300 text-green-700 bg-green-50 hover:bg-green-100" : "border-green-300 text-green-700 bg-green-50 hover:bg-green-100"
}`} }`}
> >
{isSubscribedToTopic(topic) ? ( {isSubscribedToTopic(topic) ? (
<> <>
@@ -584,12 +585,13 @@ export default function TopicsView() {
</p> </p>
<div className="flex items-center"> <div className="flex items-center">
<span <span
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${req.status === "approved" className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
req.status === "approved"
? "bg-green-100 text-green-800" ? "bg-green-100 text-green-800"
: req.status === "rejected" : req.status === "rejected"
? "bg-red-100 text-red-800" ? "bg-red-100 text-red-800"
: "bg-yellow-100 text-yellow-800" : "bg-yellow-100 text-yellow-800"
}`} }`}
> >
{req.status === "approved" {req.status === "approved"
? "Approved" ? "Approved"
@@ -688,10 +690,11 @@ export default function TopicsView() {
</div> </div>
{submitStatus && ( {submitStatus && (
<div <div
className={`p-3 rounded-md text-sm ${submitStatus.type === "success" className={`p-3 rounded-md text-sm ${
submitStatus.type === "success"
? "bg-green-50 text-green-800" ? "bg-green-50 text-green-800"
: "bg-red-50 text-red-800" : "bg-red-50 text-red-800"
}`} }`}
> >
{submitStatus.message} {submitStatus.message}
</div> </div>