feat(web): prioritize SMS operations workspace

This commit is contained in:
chick
2026-07-19 10:30:52 +08:00
parent 0112e3320a
commit f7d69a0fa7
10 changed files with 532 additions and 68 deletions
+21 -3
View File
@@ -41,6 +41,7 @@ export function MessagesModule({ instance, dataSource, refreshSignal }: Messages
const [retry, setRetry] = useState(0);
const [phoneNumber, setPhoneNumber] = useState('');
const [content, setContent] = useState('');
const [pendingSend, setPendingSend] = useState<SendMessageInput>();
const [sending, setSending] = useState(false);
const [sendState, setSendState] = useState<'success' | 'error'>();
@@ -61,13 +62,14 @@ export function MessagesModule({ instance, dataSource, refreshSignal }: Messages
return () => controller.abort();
}, [dataSource, instance.id, refreshSignal, retry]);
async function send(): Promise<void> {
async function send(input: SendMessageInput): Promise<void> {
if (!dataSource || sending) return;
setSending(true);
setSendState(undefined);
try {
await dataSource.send(instance.id, { phoneNumber, content });
await dataSource.send(instance.id, input);
setContent('');
setPendingSend(undefined);
setSendState('success');
setRetry((value) => value + 1);
} catch {
@@ -92,7 +94,7 @@ export function MessagesModule({ instance, dataSource, refreshSignal }: Messages
<form
onSubmit={(event) => {
event.preventDefault();
void send();
setPendingSend({ phoneNumber: phoneNumber.trim(), content: content.trim() });
}}
>
<label>
@@ -122,6 +124,22 @@ export function MessagesModule({ instance, dataSource, refreshSignal }: Messages
</form>
{sendState === 'success' ? <p role="status"></p> : null}
{sendState === 'error' ? <p role="alert"></p> : null}
{pendingSend ? (
<section className="send-confirmation" role="region" aria-label="确认发送短信">
<h3></h3>
<p>{pendingSend.phoneNumber}</p>
<p>{pendingSend.content}</p>
<p></p>
<div className="fleet-card-actions">
<button type="button" disabled={sending} onClick={() => void send(pendingSend)}>
{sending ? '正在发送…' : '确认并发送'}
</button>
<button type="button" disabled={sending} onClick={() => setPendingSend(undefined)}>
</button>
</div>
</section>
) : null}
</section>
<section className="messages-card" aria-labelledby="sms-list-title">