fix(sid): harden admin assignment flow

This commit is contained in:
2026-09-08 13:01:41 +08:00
parent f243b7180b
commit c2dec1e711
2 changed files with 56 additions and 18 deletions
+12 -12
View File
@@ -50,7 +50,7 @@ export interface paths {
content: {
"application/json": {
/**
* @example archived
* @example all
* @enum {string|null}
*/
state?: "active" | "archived" | "trashed" | "all" | null;
@@ -539,7 +539,7 @@ export interface paths {
*/
language_code?: string;
/**
* @example draft
* @example published
* @enum {string}
*/
status?: "draft" | "awaiting_publish" | "published";
@@ -4685,7 +4685,7 @@ export interface paths {
content: {
"application/json": {
/**
* @example viewed
* @example taken_by_other
* @enum {string|null}
*/
status?: "sent" | "delivered" | "viewed" | "accepted" | "rejected" | "ignored" | "expired" | "taken_by_other" | null;
@@ -5163,7 +5163,7 @@ export interface paths {
content: {
"application/json": {
/**
* @example inactive
* @example busy
* @enum {string|null}
*/
status?: "offline" | "online" | "inactive" | "busy" | null;
@@ -5448,12 +5448,12 @@ export interface paths {
content: {
"application/json": {
/**
* @example private
* @example friends
* @enum {string|null}
*/
visibility?: "public" | "friends" | "private" | null;
/**
* @example blocked
* @example visible
* @enum {string|null}
*/
status?: "blocked" | "visible" | "all" | null;
@@ -5779,7 +5779,7 @@ export interface paths {
content: {
"application/json": {
/**
* @example all
* @example pending
* @enum {string|null}
*/
status?: "pending" | "blocked" | "all" | null;
@@ -9744,7 +9744,7 @@ export interface paths {
content: {
"application/json": {
/**
* @example all
* @example blocked
* @enum {string|null}
*/
status?: "pending" | "blocked" | "all" | null;
@@ -10107,11 +10107,11 @@ export interface paths {
content: {
"application/json": {
/**
* @example web
* @example android
* @enum {string|null}
*/
platform?: "ios" | "android" | "web" | "desktop" | null;
/** @example false */
/** @example true */
is_online?: boolean | null;
/**
* @description Must be at least 1.
@@ -11170,7 +11170,7 @@ export interface operations {
content: {
"application/json": {
/**
* @description SID /
* @description SID 3 6 /
* @example ABC-888888
*/
sid: string;
@@ -11214,7 +11214,7 @@ export interface operations {
*/
user_uid: string;
/**
* @description SID /
* @description SID 3 6 /
* @example ABC-168888
*/
sid: string;
+44 -6
View File
@@ -70,6 +70,18 @@ function RulesTab() {
}
}
if (rules.isPending) return <p className="text-sm text-muted-foreground"></p>
if (rules.isError) {
return (
<div className="text-sm text-destructive">
<p></p>
<Button className="mt-2" variant="outline" size="sm" onClick={() => void rules.refetch()}>
</Button>
</div>
)
}
return (
<div className="grid gap-3 md:grid-cols-2">
{(rules.data?.data ?? []).map((rule) => (
@@ -131,6 +143,18 @@ function LuckyTab() {
}
}
if (numbers.isPending) return <p className="text-sm text-muted-foreground"></p>
if (numbers.isError) {
return (
<div className="text-sm text-destructive">
<p></p>
<Button className="mt-2" variant="outline" size="sm" onClick={() => void numbers.refetch()}>
</Button>
</div>
)
}
return (
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-end gap-3">
@@ -140,8 +164,10 @@ function LuckyTab() {
id="lucky-number"
className="w-32 font-mono"
maxLength={3}
inputMode="numeric"
pattern="[0-9]{3}"
value={draft.number}
onChange={(e) => setDraft((d) => ({ ...d, number: e.target.value }))}
onChange={(e) => setDraft((d) => ({ ...d, number: e.target.value.replace(/\D/g, '') }))}
placeholder="888"
/>
</div>
@@ -198,6 +224,8 @@ function AssignTab() {
const [checkResult, setCheckResult] = useState<SidCheckResult | null>(null)
const [userUid, setUserUid] = useState('')
const [busy, setBusy] = useState(false)
const validSid = /^[A-HJ-NPR-Z]{3}-?\d{6}$/i.test(sid)
const validUid = /^[0-9A-HJKMNP-TV-Z]{26}$/i.test(userUid)
const check = async () => {
setBusy(true)
@@ -238,11 +266,14 @@ function AssignTab() {
id="sid-input"
className="font-mono"
value={sid}
onChange={(e) => setSid(e.target.value)}
placeholder="668888"
onChange={(e) => {
setSid(e.target.value.toUpperCase())
setCheckResult(null)
}}
placeholder="ABC-668888"
/>
</div>
<Button variant="outline" onClick={check} disabled={!sid || busy}>
<Button variant="outline" onClick={check} disabled={!validSid || busy}>
</Button>
</div>
@@ -270,14 +301,21 @@ function AssignTab() {
<Input
id="assign-uid"
className="font-mono"
maxLength={26}
value={userUid}
onChange={(e) => setUserUid(e.target.value)}
onChange={(e) => setUserUid(e.target.value.toUpperCase())}
placeholder="01JXXXXXXXXXXXXXXXXXXXXXXX"
/>
</div>
<Button
onClick={assign}
disabled={!sid || !userUid || busy || (checkResult?.reserved === true && !canOverride)}
disabled={
!validSid ||
!validUid ||
!checkResult ||
busy ||
(checkResult.reserved && !canOverride)
}
>
SID
</Button>