feat(notifications): add notification system and wire order/dispute events
This commit is contained in:
@@ -56,7 +56,7 @@ export default function NotificationsPage() {
|
||||
const systemNotifs = notifications.filter((notification) => notification.type === "system")
|
||||
|
||||
return (
|
||||
<div className="max-w-2xl space-y-6">
|
||||
<div className="max-w-2xl mx-auto space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<h1 className="text-2xl font-bold">通知中心</h1>
|
||||
@@ -76,13 +76,21 @@ export default function NotificationsPage() {
|
||||
<TabsTrigger value="system">系统</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent value="all" className="space-y-2 mt-4">
|
||||
{notifications.map((notification) => (
|
||||
<NotificationItem key={notification.id} notification={notification} />
|
||||
))}
|
||||
<TabsContent value="all" className="space-y-3 mt-4">
|
||||
{notifications.length === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center text-sm text-muted-foreground">
|
||||
暂无通知
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
notifications.map((notification) => (
|
||||
<NotificationItem key={notification.id} notification={notification} />
|
||||
))
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="order" className="space-y-2 mt-4">
|
||||
<TabsContent value="order" className="space-y-3 mt-4">
|
||||
{orderNotifs.length === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center text-sm text-muted-foreground">
|
||||
@@ -94,7 +102,7 @@ export default function NotificationsPage() {
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="community" className="space-y-2 mt-4">
|
||||
<TabsContent value="community" className="space-y-3 mt-4">
|
||||
{communityNotifs.length === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center text-sm text-muted-foreground">
|
||||
@@ -106,7 +114,7 @@ export default function NotificationsPage() {
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="system" className="space-y-2 mt-4">
|
||||
<TabsContent value="system" className="space-y-3 mt-4">
|
||||
{systemNotifs.length === 0 ? (
|
||||
<Card>
|
||||
<CardContent className="py-8 text-center text-sm text-muted-foreground">
|
||||
|
||||
@@ -17,7 +17,15 @@ import type { UserRole } from "@/lib/types"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { currentRole, verifiedRoles, switchRole, user, updateProfile } = useAuthStore()
|
||||
const {
|
||||
currentRole,
|
||||
verifiedRoles,
|
||||
switchRole,
|
||||
user,
|
||||
updateProfile,
|
||||
notificationPrefs,
|
||||
setNotificationPref,
|
||||
} = useAuthStore()
|
||||
const [nickname, setNickname] = useState(user?.nickname ?? "")
|
||||
const [bio, setBio] = useState(user?.bio ?? "")
|
||||
const [avatar, setAvatar] = useState(user?.avatar ?? "")
|
||||
@@ -26,7 +34,7 @@ export default function SettingsPage() {
|
||||
const isRoleVerified = (role: UserRole) => verifiedRoles.includes(role)
|
||||
|
||||
return (
|
||||
<div className="max-w-2xl space-y-6">
|
||||
<div className="max-w-2xl mx-auto space-y-6">
|
||||
<h1 className="text-2xl font-bold">个人设置</h1>
|
||||
|
||||
<Card>
|
||||
@@ -176,7 +184,10 @@ export default function SettingsPage() {
|
||||
<p className="text-sm font-medium">订单通知</p>
|
||||
<p className="text-xs text-muted-foreground">接单、完成、争议等状态变更</p>
|
||||
</div>
|
||||
<Switch defaultChecked />
|
||||
<Switch
|
||||
checked={notificationPrefs.order}
|
||||
onCheckedChange={(checked) => setNotificationPref("order", checked)}
|
||||
/>
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -184,7 +195,10 @@ export default function SettingsPage() {
|
||||
<p className="text-sm font-medium">社区通知</p>
|
||||
<p className="text-xs text-muted-foreground">点赞、评论、关注</p>
|
||||
</div>
|
||||
<Switch defaultChecked />
|
||||
<Switch
|
||||
checked={notificationPrefs.community}
|
||||
onCheckedChange={(checked) => setNotificationPref("community", checked)}
|
||||
/>
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -192,7 +206,10 @@ export default function SettingsPage() {
|
||||
<p className="text-sm font-medium">系统通知</p>
|
||||
<p className="text-xs text-muted-foreground">平台公告、活动推送</p>
|
||||
</div>
|
||||
<Switch />
|
||||
<Switch
|
||||
checked={notificationPrefs.system}
|
||||
onCheckedChange={(checked) => setNotificationPref("system", checked)}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user