refactor: extract shared constants to lib/constants.ts
This commit is contained in:
@@ -9,6 +9,7 @@ import { z } from "zod"
|
|||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
|
import { currentUser } from "@/lib/mock-data"
|
||||||
import { useAuthStore } from "@/store/auth"
|
import { useAuthStore } from "@/store/auth"
|
||||||
|
|
||||||
const loginSchema = z.object({
|
const loginSchema = z.object({
|
||||||
@@ -29,7 +30,7 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
const onSubmit = async (_data: z.infer<typeof loginSchema>) => {
|
const onSubmit = async (_data: z.infer<typeof loginSchema>) => {
|
||||||
await new Promise((r) => setTimeout(r, 500))
|
await new Promise((r) => setTimeout(r, 500))
|
||||||
login()
|
login(currentUser, ["consumer", "player", "owner"])
|
||||||
router.push("/")
|
router.push("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,22 +7,12 @@ import { Badge } from "@/components/ui/badge"
|
|||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||||
|
import { statusLabels } from "@/lib/constants"
|
||||||
import { mockChatSessions, mockOrders } from "@/lib/mock-data"
|
import { mockChatSessions, mockOrders } from "@/lib/mock-data"
|
||||||
import type { OrderStatus } from "@/lib/types"
|
import type { OrderStatus } from "@/lib/types"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { useAuthStore } from "@/store/auth"
|
import { useAuthStore } from "@/store/auth"
|
||||||
|
|
||||||
const statusLabels: Record<OrderStatus, string> = {
|
|
||||||
pending_payment: "待支付",
|
|
||||||
pending_accept: "待接单",
|
|
||||||
in_progress: "进行中",
|
|
||||||
pending_close: "待结单",
|
|
||||||
pending_review: "待评价",
|
|
||||||
disputed: "争议中",
|
|
||||||
completed: "已完成",
|
|
||||||
cancelled: "已取消",
|
|
||||||
}
|
|
||||||
|
|
||||||
const statusColors: Record<OrderStatus, string> = {
|
const statusColors: Record<OrderStatus, string> = {
|
||||||
pending_payment: "bg-yellow-100 text-yellow-800",
|
pending_payment: "bg-yellow-100 text-yellow-800",
|
||||||
pending_accept: "bg-blue-100 text-blue-800",
|
pending_accept: "bg-blue-100 text-blue-800",
|
||||||
|
|||||||
+20
-20
@@ -24,7 +24,7 @@ export const mockUsers: User[] = [
|
|||||||
avatar: "/avatars/u1.jpg",
|
avatar: "/avatars/u1.jpg",
|
||||||
role: "consumer",
|
role: "consumer",
|
||||||
phone: "138****1234",
|
phone: "138****1234",
|
||||||
bio: "下班打两把,周末经常熬夜",
|
bio: "工作日打两三把,周末偶尔通宵",
|
||||||
createdAt: "2025-01-15",
|
createdAt: "2025-01-15",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ export const mockUsers: User[] = [
|
|||||||
avatar: "/avatars/u2.jpg",
|
avatar: "/avatars/u2.jpg",
|
||||||
role: "player",
|
role: "player",
|
||||||
phone: "139****5678",
|
phone: "139****5678",
|
||||||
bio: "主打峡谷双排,逆风也会认真打",
|
bio: "晚上在线多,逆风不摆,能语音更快",
|
||||||
createdAt: "2024-11-20",
|
createdAt: "2024-11-20",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ export const mockUsers: User[] = [
|
|||||||
avatar: "/avatars/u3.jpg",
|
avatar: "/avatars/u3.jpg",
|
||||||
role: "owner",
|
role: "owner",
|
||||||
phone: "137****9012",
|
phone: "137****9012",
|
||||||
bio: "白天管店,晚上回消息慢一点",
|
bio: "店里就三个人,忙的时候回消息会慢点",
|
||||||
createdAt: "2024-08-10",
|
createdAt: "2024-08-10",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ export const mockUsers: User[] = [
|
|||||||
nickname: "阿辰",
|
nickname: "阿辰",
|
||||||
avatar: "/avatars/u4.jpg",
|
avatar: "/avatars/u4.jpg",
|
||||||
role: "player",
|
role: "player",
|
||||||
bio: "练枪党,报点快,话不多",
|
bio: "主狙和突破都打,报点直给",
|
||||||
createdAt: "2025-02-01",
|
createdAt: "2025-02-01",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -62,7 +62,7 @@ export const mockUsers: User[] = [
|
|||||||
nickname: "甜甜酱",
|
nickname: "甜甜酱",
|
||||||
avatar: "/avatars/u5.jpg",
|
avatar: "/avatars/u5.jpg",
|
||||||
role: "player",
|
role: "player",
|
||||||
bio: "主辅和原神日常,社恐但不摆烂",
|
bio: "主辅+原神日常,社恐,但会认真打",
|
||||||
createdAt: "2025-01-05",
|
createdAt: "2025-01-05",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -84,8 +84,8 @@ export const mockServices: PlayerService[] = [
|
|||||||
playerId: "u2",
|
playerId: "u2",
|
||||||
gameId: "g1",
|
gameId: "g1",
|
||||||
gameName: "英雄联盟",
|
gameName: "英雄联盟",
|
||||||
title: "LOL双排冲分",
|
title: "LOL双排稳一点上分",
|
||||||
description: "我打野和中路都行,逆风不甩锅,打完会说两句思路",
|
description: "主打野/中,前两把先磨合。逆风会讲思路,不闷着。",
|
||||||
price: 33,
|
price: 33,
|
||||||
unit: "局",
|
unit: "局",
|
||||||
rankRange: "铂金-大师",
|
rankRange: "铂金-大师",
|
||||||
@@ -96,9 +96,9 @@ export const mockServices: PlayerService[] = [
|
|||||||
playerId: "u2",
|
playerId: "u2",
|
||||||
gameId: "g2",
|
gameId: "g2",
|
||||||
gameName: "王者荣耀",
|
gameName: "王者荣耀",
|
||||||
title: "王者补位上星",
|
title: "王者补位冲星",
|
||||||
description: "单排连跪就来组队,能补位,想冲几星先聊清楚",
|
description: "连跪想止损就来,射手辅助都能补。冲几星先说,我按你节奏来。",
|
||||||
price: 29,
|
price: 27,
|
||||||
unit: "星",
|
unit: "星",
|
||||||
rankRange: "星耀-王者80星",
|
rankRange: "星耀-王者80星",
|
||||||
availability: ["每天 18:30-00:30"],
|
availability: ["每天 18:30-00:30"],
|
||||||
@@ -109,8 +109,8 @@ export const mockServices: PlayerService[] = [
|
|||||||
gameId: "g3",
|
gameId: "g3",
|
||||||
gameName: "CS2",
|
gameName: "CS2",
|
||||||
title: "CS2车队位",
|
title: "CS2车队位",
|
||||||
description: "不整花活,先报点再打,节奏比较快",
|
description: "语音里先报点,残局我来喊。不开喷,失误就下一把拉回来。",
|
||||||
price: 58,
|
price: 57,
|
||||||
unit: "局",
|
unit: "局",
|
||||||
rankRange: "白银-超凡",
|
rankRange: "白银-超凡",
|
||||||
availability: ["每天 15:00-01:00"],
|
availability: ["每天 15:00-01:00"],
|
||||||
@@ -121,8 +121,8 @@ export const mockServices: PlayerService[] = [
|
|||||||
gameId: "g1",
|
gameId: "g1",
|
||||||
gameName: "英雄联盟",
|
gameName: "英雄联盟",
|
||||||
title: "LOL轻松双排",
|
title: "LOL轻松双排",
|
||||||
description: "主辅位,能聊也能安静打,连跪会及时换玩法",
|
description: "主辅位,偏保人打法。想聊天就聊,不想说话也行。",
|
||||||
price: 23,
|
price: 22,
|
||||||
unit: "局",
|
unit: "局",
|
||||||
availability: ["周末 11:00-23:30"],
|
availability: ["周末 11:00-23:30"],
|
||||||
},
|
},
|
||||||
@@ -132,8 +132,8 @@ export const mockServices: PlayerService[] = [
|
|||||||
gameId: "g5",
|
gameId: "g5",
|
||||||
gameName: "原神",
|
gameName: "原神",
|
||||||
title: "原神日常清体力",
|
title: "原神日常清体力",
|
||||||
description: "委托、树脂、活动都能代,做完会发截图",
|
description: "每日委托、树脂、活动本都能清。做完发截图,不乱动你号。",
|
||||||
price: 17,
|
price: 19,
|
||||||
unit: "次",
|
unit: "次",
|
||||||
availability: ["工作日 21:00-24:00", "周末白天可"],
|
availability: ["工作日 21:00-24:00", "周末白天可"],
|
||||||
},
|
},
|
||||||
@@ -185,16 +185,16 @@ export const mockShops: Shop[] = [
|
|||||||
owner: mockUsers[2],
|
owner: mockUsers[2],
|
||||||
name: "王者电竞工作室",
|
name: "王者电竞工作室",
|
||||||
banner: "/banners/shop1.jpg",
|
banner: "/banners/shop1.jpg",
|
||||||
description: "店里人不算多,主打晚间在线,接单后会先确认你的需求",
|
description: "晚上在线的人多一点,接单前会先问清楚你想怎么打。",
|
||||||
rating: 4.3,
|
rating: 4.4,
|
||||||
totalOrders: 210,
|
totalOrders: 68,
|
||||||
playerCount: 7,
|
playerCount: 7,
|
||||||
commissionType: "percentage",
|
commissionType: "percentage",
|
||||||
commissionValue: 15,
|
commissionValue: 15,
|
||||||
allowMultiShop: false,
|
allowMultiShop: false,
|
||||||
allowIndependentOrders: true,
|
allowIndependentOrders: true,
|
||||||
dispatchMode: "manual",
|
dispatchMode: "manual",
|
||||||
announcements: ["晚高峰单子多,排队会慢一点", "这周新加了原神代肝档位"],
|
announcements: ["晚上9点后单子多,等位可能会慢", "这周加了原神日常代清,截图回传"],
|
||||||
templateConfig: {
|
templateConfig: {
|
||||||
sections: [
|
sections: [
|
||||||
{ type: "banner", enabled: true, order: 0 },
|
{ type: "banner", enabled: true, order: 0 },
|
||||||
|
|||||||
Reference in New Issue
Block a user