Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): check numbers as typed and stop a refused run

Yudhi Armyndharisa971c1381e28
diff --git a/dashboard/src/pages/NumberChecker.css b/dashboard/src/pages/NumberChecker.css
index c34e62b62..12119ca0b 100644
--- a/dashboard/src/pages/NumberChecker.css
+++ b/dashboard/src/pages/NumberChecker.css
@@ -575,3 +575,11 @@
color: var(--text-muted);
font-size: 0.75rem;
}
+
+.number-checker .nc-batch-limit {
+ display: block;
+ margin-top: 0.5rem;
+ font-size: 0.8125rem;
+ font-weight: 600;
+ color: var(--error-text);
+}
diff --git a/dashboard/src/pages/NumberChecker.test.ts b/dashboard/src/pages/NumberChecker.test.ts
index aa9fa5a94..132e1aa7b 100644
--- a/dashboard/src/pages/NumberChecker.test.ts
+++ b/dashboard/src/pages/NumberChecker.test.ts
@@ -8,6 +8,7 @@ type RTL = typeof import('@testing-library/react');
let rtl: RTL;
let NumberChecker: typeof import('./NumberChecker.tsx').NumberChecker;
+let NUMBER_CHECK_BATCH_MAX: typeof import('./NumberChecker.tsx').NUMBER_CHECK_BATCH_MAX;
let ToastProvider: typeof import('../components/Toast.tsx').ToastProvider;
let MemoryRouter: typeof import('react-router-dom').MemoryRouter;
let RoleProvider: typeof import('../components/RoleProvider.tsx').RoleProvider;
@@ -46,6 +47,29 @@ function renderComponent(role = 'operator') {
);
}
+// Answers every number lookup with `answer(number)` and returns the numbers looked up, in order.
+function stubLookups(answer: (number: string) => Response): string[] {
+ const lookups: string[] = [];
+ globalThis.fetch = ((input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.includes('/contacts/check/')) {
+ const number = url.split('/contacts/check/')[1];
+ lookups.push(number);
+ return Promise.resolve(answer(number));
+ }
+ return defaultFetch(input);
+ }) as typeof fetch;
+ return lookups;
+}
+
+const registered = (number: string) => jsonResponse({ number, exists: true, whatsappId: `${number}@c.us` });
+
+async function openBulkTab(): Promise<HTMLTextAreaElement> {
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Bulk/i }));
+ await rtl.screen.findByRole('option', { name: /Primary Session/ });
+ return rtl.screen.getByPlaceholderText(/9612345678/i) as HTMLTextAreaElement;
+}
+
before(async () => {
const { installJsdomGlobals } = await import('../test-helpers/jsdom.ts');
await installJsdomGlobals();
@@ -68,7 +92,7 @@ before(async () => {
({ MemoryRouter } = await import('react-router-dom'));
({ ToastProvider } = await import('../components/Toast.tsx'));
({ RoleProvider } = await import('../components/RoleProvider.tsx'));
- ({ NumberChecker } = await import('./NumberChecker.tsx'));
+ ({ NumberChecker, NUMBER_CHECK_BATCH_MAX } = await import('./NumberChecker.tsx'));
});
afterEach(() => {
@@ -80,7 +104,7 @@ afterEach(() => {
test('NumberChecker: renders single check form and tabs', () => {
const { getByText, getByPlaceholderText } = renderComponent();
assert.ok(getByText('Check Single Account'));
- assert.ok(getByPlaceholderText('e.g. 9876543210 (10 digits) or 919876543210 (12 digits)'));
+ assert.ok(getByPlaceholderText('e.g. 919876543210 or 6281234567890 (with country code)'));
});
test('NumberChecker: switches to bulk / batch tab when clicked', () => {
@@ -91,13 +115,20 @@ test('NumberChecker: switches to bulk / batch tab when clicked', () => {
assert.ok(headings.length >= 1);
});
+// The +91 rewrite is opt-in: `autoPrefix` is whether the box is ticked before the number is checked.
for (const [raw, autoPrefix, expected] of [
['+65 8123 4567', true, '6581234567'],
['0065 8123 4567', true, '6581234567'],
+ ['+65 8123 4567', false, '6581234567'],
+ ['0065 8123 4567', false, '6581234567'],
+ ['08123456789', false, '08123456789'],
+ ['4155552671', false, '4155552671'],
+ ['9876543210', false, '9876543210'],
['09876543210', false, '09876543210'],
['9109876543210', false, '9109876543210'],
['9876543210', true, '919876543210'],
['09876543210', true, '919876543210'],
+ ['08123456789', true, '918123456789'],
] as const) {
test(`NumberChecker: checks ${raw} as ${expected} with auto-prefix ${autoPrefix}`, async () => {
const lookups: string[] = [];
@@ -113,7 +144,8 @@ for (const [raw, autoPrefix, expected] of [
const { container } = renderComponent();
await rtl.screen.findByRole('option', { name: /Primary Session/ });
- if (!autoPrefix) rtl.fireEvent.click(rtl.screen.getByRole('checkbox'));
+ if (autoPrefix) rtl.fireEvent.click(rtl.screen.getByRole('checkbox'));
+ assert.equal((rtl.screen.getByRole('checkbox') as HTMLInputElement).checked, autoPrefix);
rtl.fireEvent.change(rtl.screen.getByPlaceholderText(/9876543210/), { target: { value: raw } });
if (raw.startsWith('+') || raw.startsWith('00')) {
assert.ok(!container.querySelector('.nc-format-preview')?.textContent?.includes('auto-prefixed'));
@@ -137,11 +169,9 @@ test('NumberChecker: bulk parsing deduplicates explicit international numbers wi
}) as typeof fetch;
renderComponent();
- rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Bulk/i }));
- await rtl.screen.findByRole('option', { name: /Primary Session/ });
- rtl.fireEvent.change(rtl.screen.getByPlaceholderText(/9612345678/i), {
- target: { value: '+65 8123 4567\n0065 8123 4567' },
- });
+ const textarea = await openBulkTab();
+ rtl.fireEvent.click(rtl.screen.getByRole('checkbox'));
+ rtl.fireEvent.change(textarea, { target: { value: '+65 8123 4567\n0065 8123 4567' } });
assert.match(rtl.screen.getByText(/ten-digit/).textContent ?? '', /0 ten-digit/);
rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
await rtl.screen.findByText('+6581234567');
@@ -336,3 +366,184 @@ test('NumberChecker: Stop followed by Start while lookup is pending cancels earl
const regBox = rtl.screen.getByText('Registered', { selector: '.nc-stat-label' }).parentElement;
assert.ok(regBox?.textContent?.includes('1'));
});
+
+test('NumberChecker: the +91 rule is off by default in both tabs and the hints say numbers are checked as typed', async () => {
+ renderComponent();
+ await rtl.screen.findByRole('option', { name: /Primary Session/ });
+ assert.equal((rtl.screen.getByRole('checkbox') as HTMLInputElement).checked, false);
+ assert.ok(rtl.screen.getByText(/checked as typed/));
+
+ const textarea = await openBulkTab();
+ const box = rtl.screen.getByRole('checkbox') as HTMLInputElement;
+ assert.equal(box.checked, false);
+ assert.ok(rtl.screen.getByText(/checked as typed/));
+ rtl.fireEvent.change(textarea, { target: { value: '08123456789\n4155552671' } });
+ assert.equal(rtl.screen.queryByText(/ten-digit/), null);
+
+ rtl.fireEvent.click(box);
+ assert.match(rtl.screen.getByText(/ten-digit/).textContent ?? '', /2 ten-digit/);
+ assert.equal(rtl.screen.queryByText(/checked as typed/), null);
+});
+
+test('NumberChecker: a bulk run looks numbers up as typed by default', async () => {
+ const lookups = stubLookups(number => jsonResponse({ number, exists: false, whatsappId: null }));
+ renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '08123456789\n4155552671' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+ await rtl.screen.findByText('Completed checking 2 numbers.', {}, { timeout: 3000 });
+ assert.deepEqual(lookups, ['08123456789', '4155552671']);
+});
+
+test('NumberChecker: the pacing delay starts at one second and offers nothing faster', async () => {
+ renderComponent();
+ await openBulkTab();
+ const select = rtl.screen.getByLabelText('Safe Pacing Delay (ms)') as HTMLSelectElement;
+ assert.equal(select.value, '1000');
+ assert.deepEqual(
+ [...select.options].map(option => option.value),
+ ['1000', '2000', '3000'],
+ );
+});
+
+test('NumberChecker: a list over the per-run limit blocks Start and names the limit and the count', async () => {
+ stubLookups(registered);
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ const list = (count: number) =>
+ Array.from({ length: count }, (_, i) => `628120${String(i).padStart(6, '0')}`).join('\n');
+ const start = () => rtl.screen.getByRole('button', { name: /Start Batch Check/i }) as HTMLButtonElement;
+
+ rtl.fireEvent.change(textarea, { target: { value: list(NUMBER_CHECK_BATCH_MAX) } });
+ assert.equal(start().disabled, false);
+ assert.equal(container.querySelector('.nc-batch-limit'), null);
+
+ rtl.fireEvent.change(textarea, { target: { value: list(NUMBER_CHECK_BATCH_MAX + 1) } });
+ assert.equal(start().disabled, true);
+ const message = container.querySelector('.nc-batch-limit')?.textContent ?? '';
+ assert.match(message, new RegExp(`${NUMBER_CHECK_BATCH_MAX + 1} parsed`));
+ assert.match(message, new RegExp(`at most ${NUMBER_CHECK_BATCH_MAX} per run`));
+
+ // Repeats collapse before the limit applies.
+ rtl.fireEvent.change(textarea, { target: { value: `${list(NUMBER_CHECK_BATCH_MAX)}\n${list(5)}` } });
+ assert.equal(start().disabled, false);
+ assert.equal(container.querySelector('.nc-batch-limit'), null);
+});
+
+const statValue = (label: string) =>
+ rtl.screen.getByText(label, { selector: '.nc-stat-label' }).parentElement?.querySelector('.nc-stat-number')
+ ?.textContent;
+
+test('NumberChecker: a gateway refusal stops the batch and the numbers never reached get no rows', async () => {
+ const lookups = stubLookups(number =>
+ number === '912222222222' ? jsonResponse({ message: 'Rate limit exceeded (HTTP 429)' }, 429) : registered(number),
+ );
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '911111111111\n912222222222\n913333333333\n914444444444' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+
+ await rtl.screen.findByText('Batch stopped', { selector: 'strong' }, { timeout: 3000 });
+ const notice = container.querySelector('.nc-batch-stopped')?.textContent ?? '';
+ assert.match(notice, /The gateway rate limit was reached \(HTTP 429\)/);
+ assert.match(notice, /Stopped at number 2 of 4; 2 numbers were not sent/);
+
+ // The refused lookup is a failed row; the two numbers behind it were never sent, so they have none.
+ assert.ok(rtl.screen.getByText('+911111111111'));
+ assert.ok(rtl.screen.getByText('Rate limit exceeded (HTTP 429)'));
+ assert.equal(rtl.screen.queryByText('+913333333333'), null);
+ assert.equal(rtl.screen.queryByText('+914444444444'), null);
+ assert.equal(statValue('Checked'), '2');
+ assert.equal(statValue('Failed'), '1');
+ assert.equal(statValue('Remaining'), '2');
+ assert.equal(rtl.screen.queryByText(/Completed checking/), null);
+ assert.equal((rtl.screen.getByRole('button', { name: /Start Batch Check/i }) as HTMLButtonElement).disabled, false);
+
+ // Past the pacing delay, which is when a run that went on would have looked up the third number.
+ await new Promise(resolve => setTimeout(resolve, 1_200));
+ assert.deepEqual(lookups, ['911111111111', '912222222222']);
+});
+
+const STOP_REASON: Record<number, RegExp> = {
+ 409: /The session is not connected \(HTTP 409\)/,
+ 429: /The gateway rate limit was reached \(HTTP 429\)/,
+ 503: /WhatsApp did not answer a lookup \(HTTP 503\)/,
+};
+
+for (const status of [409, 429, 503]) {
+ test(`NumberChecker: HTTP ${status} on the first lookup stops the batch before the second`, async () => {
+ const lookups = stubLookups(() => jsonResponse({ message: `refused ${status}` }, status));
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '911111111111\n912222222222' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+
+ await rtl.screen.findByText('Batch stopped', { selector: 'strong' });
+ const notice = container.querySelector('.nc-batch-stopped')?.textContent ?? '';
+ assert.match(notice, STOP_REASON[status]);
+ // Number 1 was sent and refused, so only number 2 was never sent.
+ assert.match(notice, /Stopped at number 1 of 2; 1 number was not sent/);
+ assert.deepEqual(lookups, ['911111111111']);
+ assert.equal(rtl.screen.queryByText(/Completed checking/), null);
+ });
+}
+
+test('NumberChecker: a refusal on the last number says so instead of counting numbers left unsent', async () => {
+ const lookups = stubLookups(number =>
+ number === '912222222222' ? jsonResponse({ message: 'Rate limit exceeded (HTTP 429)' }, 429) : registered(number),
+ );
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '911111111111\n912222222222' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+
+ await rtl.screen.findByText('Batch stopped', { selector: 'strong' }, { timeout: 3000 });
+ const notice = container.querySelector('.nc-batch-stopped')?.textContent ?? '';
+ assert.match(notice, /The last lookup failed/);
+ assert.doesNotMatch(notice, /not sent/);
+ assert.deepEqual(lookups, ['911111111111', '912222222222']);
+ assert.equal(rtl.screen.queryByText(/Completed checking/), null);
+});
+
+test('NumberChecker: a lookup error that is not a gateway refusal fails that number and the run goes on', async () => {
+ const lookups = stubLookups(number =>
+ number === '911111111111' ? jsonResponse({ message: 'engine hiccup' }, 500) : registered(number),
+ );
+ const { container } = renderComponent();
+ const textarea = await openBulkTab();
+ rtl.fireEvent.change(textarea, { target: { value: '911111111111\n912222222222' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /Start Batch Check/i }));
+
+ await rtl.screen.findByText('Completed checking 2 numbers.', {}, { timeout: 3000 });
+ assert.deepEqual(lookups, ['911111111111', '912222222222']);
+ assert.ok(rtl.screen.getByText('engine hiccup'));
+ assert.ok(rtl.screen.getByText('+912222222222'));
+ assert.equal(statValue('Failed'), '1');
+ assert.equal(container.querySelector('.nc-batch-stopped'), null);
+});
+
+// The Clipboard API is missing over plain HTTP on a LAN address, where the Copy button used to throw
+// before it could report anything. The house helper falls back to the textarea route.
+test('NumberChecker: Copy works where navigator.clipboard does not exist', async t => {
+ stubLookups(registered);
+ const copy = t.mock.fn(() => true);
+ const hadExecCommand = Object.getOwnPropertyDescriptor(document, 'execCommand');
+ Object.defineProperty(document, 'execCommand', { value: copy, configurable: true, writable: true });
+ t.after(() => {
+ if (hadExecCommand) Object.defineProperty(document, 'execCommand', hadExecCommand);
+ else delete (document as unknown as Record<string, unknown>).execCommand;
+ });
+ assert.equal(navigator.clipboard, undefined);
+
+ renderComponent();
+ await rtl.screen.findByRole('option', { name: /Primary Session/ });
+ rtl.fireEvent.change(rtl.screen.getByPlaceholderText(/9876543210/), { target: { value: '919876543210' } });
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: 'Check' }));
+ await rtl.screen.findByText('Registered', { selector: '.nc-status-badge' });
+
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /^Copy$/ }));
+
+ await rtl.screen.findByRole('button', { name: /Copied/ });
+ assert.equal(copy.mock.callCount(), 1);
+ assert.deepEqual(copy.mock.calls[0].arguments, ['copy']);
+});
diff --git a/dashboard/src/pages/NumberChecker.tsx b/dashboard/src/pages/NumberChecker.tsx
index 864db7771..5dac30e3d 100644
--- a/dashboard/src/pages/NumberChecker.tsx
+++ b/dashboard/src/pages/NumberChecker.tsx
@@ -18,15 +18,45 @@ import {
} from 'lucide-react';
import { PageHeader } from '../components/PageHeader';
import { useDocumentTitle } from '../hooks/useDocumentTitle';
+import { copyToClipboard } from '../utils/clipboard';
import { useSessionsQuery } from '../hooks/queries';
import { contactApi, type CheckNumberResponse } from '../services/api';
import { useToast } from '../hooks/useToast';
import { useRole } from '../hooks/useRole';
import { escapeCsvCell } from '../utils/csv';
+import { isGatewayRefusal } from '../utils/groupSelection';
import './NumberChecker.css';
export type CheckStatus = 'registered' | 'unregistered' | 'failed';
+// Every lookup is an outbound WhatsApp query that counts against the gateway's per-IP limit on this route
+// (100 a minute by default) and against the linked account's standing, so one run is capped.
+export const NUMBER_CHECK_BATCH_MAX = 100;
+
+interface BatchStop {
+ status: number;
+ attempted: number;
+ total: number;
+}
+
+// What each stopping status means, so a single unanswered lookup is not reported as the gateway refusing.
+const STOP_REASONS: Record<number, string> = {
+ 409: 'The session is not connected',
+ 429: 'The gateway rate limit was reached',
+ 503: 'WhatsApp did not answer a lookup',
+};
+
+// `attempted` counts the lookup that stopped the run, which is the last one sent; only the rest were never sent.
+function batchStopMessage({ status, attempted, total }: BatchStop): string {
+ const reason = STOP_REASONS[status] ?? 'The gateway refused a lookup';
+ const unsent = total - attempted;
+ const where =
+ unsent > 0
+ ? `Stopped at number ${attempted} of ${total}; ${unsent} ${unsent === 1 ? 'number was' : 'numbers were'} not sent.`
+ : 'The last lookup failed.';
+ return `${reason} (HTTP ${status}). ${where} Try again later.`;
+}
+
export interface CheckResultItem extends CheckNumberResponse {
status: CheckStatus;
error?: string | null;
@@ -41,10 +71,7 @@ export function NumberChecker() {
const { canWrite } = useRole();
const { data: sessions = [], isLoading: loadingSessions } = useSessionsQuery();
- const readySessions = useMemo(
- () => sessions.filter(s => s.status?.toLowerCase() === 'ready' || s.status?.toLowerCase() === 'authenticated'),
- [sessions],
- );
+ const readySessions = useMemo(() => sessions.filter(s => s.status === 'ready'), [sessions]);
const [selectedSession, setSelectedSession] = useState<string>('');
const [activeTab, setActiveTab] = useState<'single' | 'batch'>('single');
@@ -66,6 +93,7 @@ export function NumberChecker() {
const [batchResults, setBatchResults] = useState<CheckResultItem[]>([]);
const [batchProgress, setBatchProgress] = useState({ current: 0, total: 0 });
const [batchFilter, setBatchFilter] = useState<'all' | 'registered' | 'unregistered' | 'failed'>('all');
+ const [batchStop, setBatchStop] = useState<BatchStop | null>(null);
const batchRunIdRef = useRef<number>(0);
useEffect(() => {
@@ -75,8 +103,8 @@ export function NumberChecker() {
};
}, []);
- // Auto-prefix country code state
- const [autoPrefix91, setAutoPrefix91] = useState(true);
+ // Opt-in: the +91 rewrite would turn any other country's 10-digit or 0-prefixed number into an Indian one.
+ const [autoPrefix91, setAutoPrefix91] = useState(false);
// Format and clean phone number based on digit rules
const formatNumberForCheck = useCallback(
@@ -152,6 +180,7 @@ export function NumberChecker() {
list: Array.from(uniqueFormatted),
};
}, [batchInput, autoPrefix91, formatNumberForCheck]);
+ const batchOverLimit = batchParsedStats.uniqueCount > NUMBER_CHECK_BATCH_MAX;
// Perform single check
const handleSingleCheck = async () => {
@@ -197,10 +226,12 @@ export function NumberChecker() {
};
// Copy WhatsApp ID
- const handleCopy = (id: string) => {
- navigator.clipboard.writeText(id);
- setCopiedId(true);
- setTimeout(() => setCopiedId(false), 2000);
+ const handleCopy = async (id: string) => {
+ // The house helper: over plain HTTP on a LAN address navigator.clipboard does not exist.
+ if (await copyToClipboard(id)) {
+ setCopiedId(true);
+ setTimeout(() => setCopiedId(false), 2000);
+ }
};
// Perform batch check
@@ -220,9 +251,11 @@ export function NumberChecker() {
const runId = ++batchRunIdRef.current;
setIsCheckingBatch(true);
setBatchResults([]);
+ setBatchStop(null);
setBatchProgress({ current: 0, total: numbers.length });
const results: CheckResultItem[] = [];
+ let refusedWith: number | undefined;
for (let i = 0; i < numbers.length; i++) {
if (batchRunIdRef.current !== runId) return;
@@ -253,6 +286,14 @@ export function NumberChecker() {
timestamp: new Date().toLocaleTimeString(),
});
setBatchResults([...results]);
+
+ // The gateway keeps refusing this route for the rest of its window, so every number after this one
+ // would only become a false "Failed" row (and spend more of the limit).
+ if (isGatewayRefusal(err)) {
+ refusedWith = (err as { status: number }).status;
+ setBatchProgress({ current: i + 1, total: numbers.length });
+ break;
+ }
}
if (batchRunIdRef.current !== runId) return;
@@ -266,6 +307,12 @@ export function NumberChecker() {
if (batchRunIdRef.current !== runId) return;
setIsCheckingBatch(false);
+ if (refusedWith !== undefined) {
+ const stop = { status: refusedWith, attempted: results.length, total: numbers.length };
+ setBatchStop(stop);
+ toast.error('Batch stopped', batchStopMessage(stop));
+ return;
+ }
toast.success(`Completed checking ${results.length} numbers.`);
};
@@ -385,7 +432,7 @@ export function NumberChecker() {
<input
type="text"
className="nc-input"
- placeholder="e.g. 9876543210 (10 digits) or 919876543210 (12 digits)"
+ placeholder="e.g. 919876543210 or 6281234567890 (with country code)"
value={phoneNumber}
onChange={e => setPhoneNumber(e.target.value)}
onKeyDown={e => {
@@ -437,8 +484,8 @@ export function NumberChecker() {
)}
<span className="nc-hint">
{autoPrefix91
- ? '10-digit numbers automatically get +91 prepended. 12-digit numbers remain unchanged.'
- : 'Numbers are checked exactly as entered.'}
+ ? 'Adds +91 to 10-digit numbers and to 11 digits with a leading 0. Numbers with + or 00 stay as typed.'
+ : 'Numbers are checked as typed, digits only, so include the country code.'}
</span>
</div>
@@ -634,13 +681,13 @@ export function NumberChecker() {
onChange={e => setBatchDelay(Number(e.target.value))}
disabled={isCheckingBatch}
>
- <option value={500}>500 ms (Fast)</option>
<option value={1000}>1000 ms / 1 sec (Recommended)</option>
<option value={2000}>2000 ms / 2 sec (Extra Safe)</option>
<option value={3000}>3000 ms / 3 sec (High Volume Safe)</option>
</select>
<span className="nc-hint">
- Adds spacing between consecutive queries to prevent WhatsApp rate limits.
+ Waits between lookups to stay under the gateway&apos;s request limit (100 a minute by default). The
+ run stops if the gateway refuses further lookups.
</span>
</div>
@@ -659,7 +706,9 @@ export function NumberChecker() {
</span>
</label>
<span className="nc-hint">
- 10-digit numbers (e.g. 96...) will get +91 prepended. 12-digit numbers will be checked as-is.
+ {autoPrefix91
+ ? 'Adds +91 to 10-digit numbers (e.g. 96...) and to 11 digits with a leading 0. Numbers with + or 00 stay as typed.'
+ : 'Numbers are checked as typed, digits only, so include the country code.'}
</span>
</div>
</div>
@@ -669,7 +718,7 @@ export function NumberChecker() {
<label className="nc-label">Numbers to Check (One per line or comma-separated)</label>
<textarea
className="nc-textarea"
- placeholder="9612345678 (10 digits)&#10;919612345678 (12 digits)&#10;14155552671"
+ placeholder="919612345678&#10;6281234567890&#10;14155552671"
value={batchInput}
onChange={e => setBatchInput(e.target.value)}
disabled={isCheckingBatch}
@@ -691,7 +740,13 @@ export function NumberChecker() {
</div>
) : (
<span className="nc-hint">
- Paste raw 10-digit or 12-digit phone numbers. One per line or comma-separated.
+ Paste phone numbers with the country code, one per line or comma-separated. Up to{' '}
+ {NUMBER_CHECK_BATCH_MAX} numbers per run.
+ </span>
+ )}
+ {batchOverLimit && (
+ <span className="nc-batch-limit" role="status">
+ {`Too many numbers: ${batchParsedStats.uniqueCount} parsed, at most ${NUMBER_CHECK_BATCH_MAX} per run. Remove ${batchParsedStats.uniqueCount - NUMBER_CHECK_BATCH_MAX} to start.`}
</span>
)}
</div>
@@ -703,7 +758,7 @@ export function NumberChecker() {
<button
className="nc-btn nc-btn-primary"
onClick={handleStartBatch}
- disabled={!canWrite || !batchInput.trim() || readySessions.length === 0}
+ disabled={!canWrite || !batchInput.trim() || readySessions.length === 0 || batchOverLimit}
>
<UserCheck size={18} /> Start Batch Check
</button>
@@ -720,6 +775,18 @@ export function NumberChecker() {
)}
</div>
+ {batchStop && (
+ <div className="nc-alert warning nc-batch-stopped">
+ <div className="nc-alert-icon">
+ <AlertCircle size={22} />
+ </div>
+ <div className="nc-alert-content">
+ <strong>Batch stopped</strong>
+ <p style={{ margin: '0.25rem 0 0' }}>{batchStopMessage(batchStop)}</p>
+ </div>
+ </div>
+ )}
+
{/* Progress & Counters */}
{(isCheckingBatch || batchResults.length > 0) && (
<>