diff --git a/dashboard/siro-admin/js/app.js b/dashboard/siro-admin/js/app.js index c518448a..9c1fd4e3 100644 --- a/dashboard/siro-admin/js/app.js +++ b/dashboard/siro-admin/js/app.js @@ -1387,13 +1387,13 @@ el.driversTableBody.innerHTML = drivers.map((d) => ` #${esc(d.id)} - ${esc(`${d.first_name || ''} ${d.last_name || ''}`.trim() || 'Unnamed')} + ${esc(`${d.first_name || ''} ${d.last_name || ''}`.trim() || t('Unnamed'))} ${esc(maskPhone(d.phone))} ${esc(d.email || '—')} ${rating(d.passengerAverageRating)} ${fmtInt(d.countPassengerRide)} ${fmtInt(d.countPassengerCancel)} - ${esc(d.status || 'unknown')} + ${esc(d.status || t('Unknown'))} `).join(''); @@ -1409,13 +1409,13 @@ el.passengersTableBody.innerHTML = rows.map((p) => ` #${esc(p.id)} - ${esc(`${p.first_name || ''} ${p.last_name || ''}`.trim() || 'Unnamed')} + ${esc(`${p.first_name || ''} ${p.last_name || ''}`.trim() || t('Unnamed'))} ${esc(p.email || maskPhone(p.phone))} ${fmtInt(p.countPassengerRide)} ${rating(p.passengerAverageRating)} ${fmtInt(p.countPassengerCancel)} ${esc(fmtDate(p.created_at, true))} - ${esc(p.status || 'unknown')} + ${esc(p.status || t('Unknown'))} `).join(''); @@ -1455,13 +1455,13 @@ } async function decideApproval(adminId, action) { - if (!confirm(`Set admin #${adminId} to "${action}"?`)) return; + if (!confirm(t('Set admin') + ` #${adminId} ` + t('to') + ` "${action}"?`)) return; try { const form = new FormData(); form.append('admin_id', adminId); form.append('action', action); await api('/Admin/auth/approve_admin.php', { method: 'POST', body: form }); - toast(`Admin #${adminId} ${action}.`, 'success'); + toast(`${t('Admin')} #${adminId} ${t(action)}.`, 'success'); loadApprovals(); } catch (err) { if (!handleApiError(err, 'approve')) toast(err.message, 'danger'); @@ -2307,25 +2307,25 @@ const label = type === 'driver' ? 'captain' : 'passenger'; if (!phone) { - toast('Enter the phone number of the account to remove.', 'warning'); + toast(t('Enter the phone number of the account to remove.'), 'warning'); return; } if (confirmPhone !== phone) { - toast('The retyped phone does not match — nothing was deleted.', 'danger'); + toast(t('The retyped phone does not match — nothing was deleted.'), 'danger'); return; } if (type === 'driver' && !id) { - toast('Removing a captain requires their account ID.', 'warning'); + toast(t('Removing a captain requires their account ID.'), 'warning'); return; } if (!confirm( - `Permanently delete the ${label} on ${phone} and blacklist that number?\n\n` + - `${reason ? `Reason: ${reason}\n\n` : ''}` + + t('Permanently delete') + ` ${label} ${t('on')} ${phone} ` + t('and blacklist that number?') + '\n\n' + + `${reason ? t('Reason') + `: ${reason}\n\n` : ''}` + 'The account is deleted from the database. This cannot be undone.' )) return; - busy($('rmSubmit'), true, 'Deleting…'); + busy($('rmSubmit'), true, t('Deleting…')); status.textContent = ''; try { if (type === 'driver') { @@ -2335,14 +2335,14 @@ params: { id, phone, reason }, }); } - status.textContent = `Removed and blacklisted ${phone}`; - toast(`${label === 'captain' ? 'Captain' : 'Passenger'} removed and blacklisted.`, 'success'); + status.textContent = t('Removed and blacklisted') + ` ${phone}`; + toast(label === 'captain' ? t('Captain removed and blacklisted.') : t('Passenger removed and blacklisted.'), 'success'); ['rmPhone', 'rmId', 'rmReason', 'rmConfirmPhone'].forEach((f) => { $(f).value = ''; }); loadBlacklist(); } catch (err) { if (!handleApiError(err, 'remove-account')) toast(err.message, 'danger'); } finally { - busy($('rmSubmit'), false, 'Delete and blacklist'); + busy($('rmSubmit'), false, t('Delete and blacklist')); } } @@ -2352,25 +2352,25 @@ const status = $('ubStatus'); if (!phone) { - toast('Enter the blocked phone number.', 'warning'); + toast(t('Enter the blocked phone number.'), 'warning'); return; } - if (!confirm(`Lift the block on ${phone}? They will be able to register again.`)) return; + if (!confirm(t('Lift the block on') + ` ${phone}? ` + t('They will be able to register again.'))) return; - busy($('ubSubmit'), true, 'Working…'); + busy($('ubSubmit'), true, t('Working…')); try { const path = type === 'driver' ? '/Admin/driver/remove_from_blacklist.php' : '/Admin/passenger/admin_unblacklist.php'; await api(path, { params: { phone } }); - status.textContent = `Block lifted for ${phone}`; - toast('Block lifted.', 'success'); + status.textContent = t('Block lifted for') + ` ${phone}`; + toast(t('Block lifted.'), 'success'); $('ubPhone').value = ''; loadBlacklist(); } catch (err) { if (!handleApiError(err, 'lift-block')) toast(err.message, 'danger'); } finally { - busy($('ubSubmit'), false, 'Lift block'); + busy($('ubSubmit'), false, t('Lift block')); } } @@ -2443,13 +2443,13 @@ if (!isPreview) { if (signature !== previewedCampaign) { - toast('Parameters changed since the preview — preview again before launching.', 'warning'); + toast(t('Parameters changed since the preview') + ' — ' + t('preview again before launching'), 'warning'); $('cmpLaunch').disabled = true; return; } if (!confirm( - `Launch this campaign in ${params.country_code}?\n\n` + - 'It creates a discount code valid for 7 days and pushes a notification to every passenger there.\n\n' + + t('Launch this campaign in') + ` ${params.country_code}?\n\n` + + t('It creates a discount code valid for 7 days and pushes a notification to every passenger there.') + '\n\n' + 'This cannot be undone.' )) return; } @@ -2471,13 +2471,13 @@ previewedCampaign = signature; $('cmpLaunch').disabled = false; $('cmpStatus').textContent = opportunity === false - ? 'The AI found no opportunity — launching would still send.' + ? t('The AI found no opportunity — launching would still send.') : `Previewed ${params.country_code}. Launch is now enabled.`; } else { previewedCampaign = null; $('cmpLaunch').disabled = true; - $('cmpStatus').textContent = `Launched at ${new Date().toLocaleTimeString()}`; - toast('Campaign dispatched.', 'success'); + $('cmpStatus').textContent = t('Launched at') + ` ${new Date().toLocaleTimeString()}`; + toast(t('Campaign dispatched.'), 'success'); loadCampaignLog(); } } catch (err) { @@ -2486,7 +2486,7 @@ toast(err.message, 'danger'); } } finally { - busy(btn, false, isPreview ? 'Preview' : 'Launch campaign'); + busy(btn, false, isPreview ? t('Preview') : t('Launch campaign')); // busy() clears `disabled`, so re-apply the arming rule afterwards: // launching stays locked until the current parameters are previewed. $('cmpLaunch').disabled = previewedCampaign !== JSON.stringify(campaignParams()); @@ -2554,22 +2554,22 @@ const version = input.value.trim(); if (version === String(pkg.version ?? '')) { - toast('Version unchanged.', 'info'); + toast(t('Version unchanged.'), 'info'); return; } // Mirrors the server-side check so a typo is caught before the request. if (!/^\d+(\.\d+){0,3}$/.test(version)) { - toast('Use digits separated by dots, e.g. 1.4.2', 'warning'); + toast(t('Use digits separated by dots, e.g. 1.4.2'), 'warning'); return; } if (!confirm( - `Set ${pkg.name || `package #${pkg.id}`} to version ${version} (was ${pkg.version ?? '—'})?\n\n` + + t('Version set to') + ` ${pkg.name || `package #${pkg.id}`} \u2192 ${version} (${pkg.version ?? '—'})?\n\n` + 'Users on an older build may be prompted or forced to update.' )) return; try { await api('/serviceapp/updatePackages.php', { params: { id: pkg.id, version } }); - toast(`Version set to ${version}.`, 'success'); + toast(t('Version set to') + ` ${version}.`, 'success'); renderAppVersions(host); } catch (err) { if (!handleApiError(err, 'package-save')) toast(err.message, 'danger'); @@ -2615,7 +2615,7 @@
- + ${drivers.map((d) => ` @@ -2643,7 +2643,7 @@ async function showDriverDocs(driverId, host) { const panel = $('docsDetail'); - panel.innerHTML = '
Loading documents…
'; + panel.innerHTML = `
${t('Loading documents…')}
`; let driver = {}; let documents = []; @@ -2666,8 +2666,8 @@ panel.innerHTML = `

- ${esc(`${driver.first_name || ''} ${driver.last_name || ''}`.trim() || `Captain #${driverId}`)} - #${esc(driverId)} · ${esc(driver.status || 'unknown')} + ${esc(`${driver.first_name || ''} ${driver.last_name || ''}`.trim() || t('Captain #') + driverId)} + #${esc(driverId)} · ${esc(driver.status || t('Unknown'))}

IDNamePhone
${t('ID')}${t('Name')}${t('Phone')}