feat: 联动支付 CRM 后台(Next.js + TS + Prisma 重构)
从旧 Laravel 5.7 重构为现代技术栈,对接现有 MySQL。 - 技术栈: Next.js 15 App Router + TypeScript + Prisma + Auth.js + Tailwind v4 - 认证: 复用旧库 admins 的 bcrypt 密码,Auth.js Credentials - 客户管理: 列表(搜索/报单区间/分页)、增改删、Excel 导入导出 - 生日提醒: 阴阳历(lunar-typescript),口径对齐旧 overtrue 库 - RBAC: 管理员/角色/权限(菜单树) 完整 CRUD + 分配 - 控制台: 统计卡 + 月度新增报单柱状图 - 个人中心: 改昵称/改密码 - 现代 CMS 界面 + 联动支付品牌(logo/登录/底部/icon) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"use client";
|
||||
|
||||
import { useActionState, useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { updateProfile, changePassword, type MeState } from "./actions";
|
||||
|
||||
function useToastOnDone(state: MeState, okMsg: string) {
|
||||
useEffect(() => {
|
||||
if (state.ok) toast.success(okMsg);
|
||||
else if (state.error) toast.error(state.error);
|
||||
}, [state, okMsg]);
|
||||
}
|
||||
|
||||
export function ProfileForm({ nickname, username }: { nickname: string; username: string }) {
|
||||
const [state, action, pending] = useActionState(updateProfile, {});
|
||||
useToastOnDone(state, "资料已更新");
|
||||
return (
|
||||
<form action={action} className="max-w-md space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label>用户名</Label>
|
||||
<Input value={username} disabled />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="nickname">昵称</Label>
|
||||
<Input id="nickname" name="nickname" defaultValue={nickname} />
|
||||
</div>
|
||||
<Button type="submit" disabled={pending}>{pending ? "保存中…" : "保存资料"}</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export function PasswordForm() {
|
||||
const [state, action, pending] = useActionState(changePassword, {});
|
||||
useToastOnDone(state, "密码已修改");
|
||||
return (
|
||||
<form action={action} className="max-w-md space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="oldPassword">原密码</Label>
|
||||
<Input id="oldPassword" name="oldPassword" type="password" autoComplete="current-password" />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="newPassword">新密码</Label>
|
||||
<Input id="newPassword" name="newPassword" type="password" autoComplete="new-password" placeholder="至少 6 位" />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="confirmPassword">确认新密码</Label>
|
||||
<Input id="confirmPassword" name="confirmPassword" type="password" autoComplete="new-password" />
|
||||
</div>
|
||||
<Button type="submit" disabled={pending}>{pending ? "提交中…" : "修改密码"}</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user