门店端子账号管理界面调整
CI / verify (pull_request) Has been cancelled

This commit is contained in:
2026-07-15 18:01:19 +08:00
parent d6ac4b5e1c
commit e7d39f7390
3 changed files with 768 additions and 157 deletions
+103 -25
View File
@@ -13,9 +13,12 @@ export default function SelectStorePage() {
const navigate = useNavigate();
const { applySession, store, authenticated } = useStoreSession();
const [stores, setStores] = useState<ShopStoreOption[]>(store?.stores ?? []);
const [loading, setLoading] = useState(false);
const [loadingId, setLoadingId] = useState<string | null>(null);
const [msg, setMsg] = useState('');
const currentStoreId = store?.storeId || '';
const canGoBack = Boolean(currentStoreId);
useEffect(() => {
if (!authenticated) {
navigate('/login', { replace: true });
@@ -27,7 +30,12 @@ export default function SelectStorePage() {
}, [authenticated, navigate]);
async function onSelect(storeId: string) {
setLoading(true);
if (loadingId) return;
if (storeId === currentStoreId) {
navigate('/', { replace: true });
return;
}
setLoadingId(storeId);
setMsg('');
try {
const session = await selectStore(storeId);
@@ -36,7 +44,7 @@ export default function SelectStorePage() {
} catch (e) {
setMsg(e instanceof Error ? e.message : '选店失败');
} finally {
setLoading(false);
setLoadingId(null);
}
}
@@ -48,31 +56,101 @@ export default function SelectStorePage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [stores.length]);
function statusLabel(status: string) {
if (status === 'OPEN') return '营业中';
if (status === 'PAUSED') return '暂停营业';
return status || '门店';
}
return (
<div className="shop-select-store-page">
<header className="shop-select-store-header">
<h1></h1>
<p></p>
<header className="shop-subpage-header">
{canGoBack ? (
<button
type="button"
className="shop-subpage-back"
onClick={() => navigate('/mine')}
aria-label="返回"
>
<span className="material-symbols-outlined">arrow_back</span>
</button>
) : (
<span className="shop-subpage-header-spacer" />
)}
<h1 className="app-page-title"></h1>
<span className="shop-subpage-header-spacer" />
</header>
{msg ? <p className="shop-select-store-msg">{msg}</p> : null}
<ul className="shop-select-store-list">
{stores.map((item) => (
<li key={item.storeId}>
<button
type="button"
className="shop-select-store-item"
disabled={loading}
onClick={() => void onSelect(item.storeId)}
>
<span className="shop-select-store-name">{item.name}</span>
<span className="shop-select-store-meta">
{[item.district, item.address].filter(Boolean).join(' · ') || item.status}
</span>
</button>
</li>
))}
</ul>
{!stores.length && !msg ? <p className="shop-select-store-empty"></p> : null}
<div className="shop-subpage-content">
<section className="shop-subpage-hero">
<div className="shop-subpage-hero-icon">
<span className="material-symbols-outlined shop-fill-icon">store</span>
</div>
<div>
<h2 className="shop-subpage-hero-title"></h2>
<p className="shop-subpage-hero-desc">
{stores.length || '多'}
</p>
</div>
</section>
{msg ? (
<p className="shop-subpage-msg" role="alert">
{msg}
</p>
) : null}
<section>
<h3 className="shop-subpage-section-title"></h3>
<ul className="shop-select-store-list">
{stores.map((item) => {
const active = item.storeId === currentStoreId;
const busy = loadingId === item.storeId;
return (
<li key={item.storeId}>
<button
type="button"
className={`shop-select-store-item${active ? ' is-active' : ''}`}
disabled={Boolean(loadingId)}
onClick={() => void onSelect(item.storeId)}
>
<div className="shop-select-store-item-icon">
<span className="material-symbols-outlined shop-fill-icon">storefront</span>
</div>
<div className="shop-select-store-item-body">
<div className="shop-select-store-item-top">
<span className="shop-select-store-name">{item.name}</span>
{active ? (
<span className="shop-select-store-badge"></span>
) : (
<span className="shop-select-store-status">{statusLabel(item.status)}</span>
)}
</div>
<span className="shop-select-store-meta">
{[item.district, item.address].filter(Boolean).join(' · ') ||
statusLabel(item.status)}
</span>
</div>
<span className="shop-select-store-item-action">
{busy ? (
'进入中…'
) : (
<span className="material-symbols-outlined">chevron_right</span>
)}
</span>
</button>
</li>
);
})}
</ul>
{!stores.length && !msg ? (
<div className="shop-subpage-empty">
<span className="material-symbols-outlined">store</span>
<p></p>
</div>
) : null}
</section>
</div>
</div>
);
}