Files
role-user/src/app/(app)/store/page.tsx
T
2026-06-02 14:46:39 +08:00

72 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { MapPin, Phone, Store } from "lucide-react";
import { EmptyState } from "@/components/empty-state";
import { PageHeader } from "@/components/page-header";
import { StatusPill } from "@/components/status-pill";
import { getCurrentStore, getCurrentStoreEmployees, getCurrentUser, getPermissionPayload } from "@/lib/mobile-data";
export default async function StorePage() {
const [user, permissions] = await Promise.all([getCurrentUser(), getPermissionPayload()]);
const canViewStoreEmployees =
permissions.permissions.includes("*") ||
permissions.permissions.includes("employee:view:store") ||
permissions.permissions.includes("employee:view:all");
const [store, employees] = await Promise.all([
getCurrentStore(user),
canViewStoreEmployees ? getCurrentStoreEmployees(user) : Promise.resolve([])
]);
const storeName = store?.name || user.storeName || "未绑定门店";
return (
<div className="page-stack">
<PageHeader title="门店" description="当前登录员工所属门店信息。" />
<section className="store-panel">
<Store aria-hidden size={28} />
<div>
<h2>{storeName}</h2>
<p>门店 ID:{store?.id ?? user.storeId ?? "暂无"}</p>
</div>
<StatusPill tone={store?.status === "INACTIVE" ? "warning" : "success"}>
{store?.status === "INACTIVE" ? "停用" : "正常"}
</StatusPill>
</section>
<section className="info-list">
<div>
<MapPin aria-hidden size={18} />
<span>地址</span>
<strong>{store?.address || "暂无"}</strong>
</div>
<div>
<Phone aria-hidden size={18} />
<span>电话</span>
<strong>{store?.phone || "暂无"}</strong>
</div>
</section>
{canViewStoreEmployees && employees.length > 0 ? (
<section className="section-block">
<div className="section-title">
<h2>本店员工</h2>
</div>
<div className="list-stack">
{employees.map((employee) => (
<article className="list-card" key={employee.id}>
<div>
<h3>{employee.name}</h3>
<p>{employee.phone || employee.roles.map((role) => role.name).join("、") || "未分配角色"}</p>
</div>
<StatusPill tone={employee.status === "INACTIVE" ? "warning" : "success"}>
{employee.status === "INACTIVE" ? "停用" : "在职"}
</StatusPill>
</article>
))}
</div>
</section>
) : canViewStoreEmployees ? (
<EmptyState title="暂无本店员工" description="有查看权限,但当前接口没有返回员工数据。" />
) : (
<EmptyState title="仅展示门店资料" description="当前账号没有查看本店员工列表的权限。" />
)}
</div>
);
}