) =>
diff --git a/apps/web/src/components/confirm-dialog.tsx b/apps/web/src/components/confirm-dialog.tsx
new file mode 100644
index 0000000..eab5b7a
--- /dev/null
+++ b/apps/web/src/components/confirm-dialog.tsx
@@ -0,0 +1,53 @@
+import { Button } from '@/components/ui/button';
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+
+// FE-Q2: the three list pages each carried a copy-pasted delete confirmation.
+export function ConfirmDialog({
+ open,
+ onOpenChange,
+ title,
+ description,
+ confirmLabel,
+ cancelLabel,
+ onConfirm,
+ loading = false,
+}: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ title: string;
+ description: string;
+ confirmLabel: string;
+ cancelLabel: string;
+ onConfirm: () => void;
+ loading?: boolean;
+}) {
+ return (
+
+ );
+}
diff --git a/apps/web/src/components/link-table-cells.tsx b/apps/web/src/components/link-table-cells.tsx
index ef874d3..acdcb50 100644
--- a/apps/web/src/components/link-table-cells.tsx
+++ b/apps/web/src/components/link-table-cells.tsx
@@ -8,23 +8,26 @@ import { useTranslation } from '@/i18n';
import {
buildShortUrl,
copyToClipboard,
- expiryLabel,
+ expiryParts,
isExpired,
isSafeUrl,
} from '@/lib/utils';
export function LinkSlugCell({ slug }: { slug: string }) {
+ const { t } = useTranslation();
return (
{slug}
);
}
diff --git a/apps/web/src/pages/admin/AdminSettingsPage.tsx b/apps/web/src/pages/admin/AdminSettingsPage.tsx
index cf6107b..7d77ab0 100644
--- a/apps/web/src/pages/admin/AdminSettingsPage.tsx
+++ b/apps/web/src/pages/admin/AdminSettingsPage.tsx
@@ -15,6 +15,7 @@ import { Label } from '@/components/ui/label';
import { Switch } from '@/components/ui/switch';
import { useAppConfig } from '@/contexts/AppConfigContext';
import { useTranslation } from '@/i18n';
+import { toastApiError } from '@/lib/toast';
export default function AdminSettingsPage() {
const { t } = useTranslation();
@@ -78,10 +79,14 @@ export default function AdminSettingsPage() {
await adminApi.updateSettings({
registration_enabled: enabled ? 'true' : 'false',
});
- toast.success(`Registration ${enabled ? 'enabled' : 'disabled'}`);
+ toast.success(
+ enabled
+ ? t('toast.registrationEnabled')
+ : t('toast.registrationDisabled'),
+ );
} catch (err) {
setRegistrationEnabled(!enabled);
- toast.error(err instanceof Error ? err.message : 'Failed');
+ toastApiError(err, t('toast.requestFailed'));
}
};
@@ -98,7 +103,7 @@ export default function AdminSettingsPage() {
);
} catch (err) {
setRequireEmailVerification(!enabled);
- toast.error(err instanceof Error ? err.message : 'Failed');
+ toastApiError(err, t('toast.requestFailed'));
}
};
@@ -108,9 +113,9 @@ export default function AdminSettingsPage() {
try {
await adminApi.updateSettings({ app_name: appName });
reloadAppConfig();
- toast.success('App name updated');
+ toast.success(t('toast.appNameUpdated'));
} catch (err) {
- toast.error(err instanceof Error ? err.message : 'Failed');
+ toastApiError(err, t('toast.requestFailed'));
} finally {
setSavingAppName(false);
}
@@ -134,9 +139,9 @@ export default function AdminSettingsPage() {
if (resendApiKey !== '') payload.resend_api_key = resendApiKey;
if (smtpPass !== '') payload.smtp_pass = smtpPass;
await adminApi.updateSettings(payload);
- toast.success('Email settings saved');
+ toast.success(t('toast.emailSettingsSaved'));
} catch (err) {
- toast.error(err instanceof Error ? err.message : 'Failed');
+ toastApiError(err, t('toast.requestFailed'));
} finally {
setSavingEmail(false);
}
diff --git a/apps/web/src/pages/admin/AdminUsersPage.tsx b/apps/web/src/pages/admin/AdminUsersPage.tsx
index 5de72d4..177cc90 100644
--- a/apps/web/src/pages/admin/AdminUsersPage.tsx
+++ b/apps/web/src/pages/admin/AdminUsersPage.tsx
@@ -3,6 +3,7 @@ import { Search, Trash2, UserPlus } from 'lucide-react';
import { useState } from 'react';
import { toast } from 'sonner';
import { adminApi } from '@/api/client';
+import { ConfirmDialog } from '@/components/confirm-dialog';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
@@ -16,7 +17,10 @@ import {
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { useAuth } from '@/contexts/AuthContext';
+import { useDebouncedValue } from '@/hooks/use-debounced-value';
import { useTranslation } from '@/i18n';
+import { SEARCH_DEBOUNCE_MS } from '@/lib/constants';
+import { toastApiError } from '@/lib/toast';
import { formatDate } from '@/lib/utils';
export default function AdminUsersPage() {
@@ -24,13 +28,15 @@ export default function AdminUsersPage() {
const { t } = useTranslation();
const queryClient = useQueryClient();
const [search, setSearch] = useState('');
+ const debouncedSearch = useDebouncedValue(search, SEARCH_DEBOUNCE_MS);
const [page, setPage] = useState(1);
const [deleteId, setDeleteId] = useState(null);
const [showCreate, setShowCreate] = useState(false);
const { data, isLoading } = useQuery({
- queryKey: ['admin-users', page, search],
- queryFn: () => adminApi.users({ page, search: search || undefined }),
+ queryKey: ['admin-users', page, debouncedSearch],
+ queryFn: () =>
+ adminApi.users({ page, search: debouncedSearch || undefined }),
});
const updateMutation = useMutation({
@@ -43,23 +49,33 @@ export default function AdminUsersPage() {
}) => adminApi.updateUser(id, payload),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['admin-users'] });
- toast.success('User updated');
+ toast.success(t('toast.userUpdated'));
},
- onError: (err) =>
- toast.error(err instanceof Error ? err.message : 'Failed'),
+ onError: (err) => toastApiError(err, t('toast.updateUserFailed')),
});
const deleteMutation = useMutation({
mutationFn: (id: string) => adminApi.deleteUser(id),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['admin-users'] });
- toast.success('User deleted');
+ toast.success(t('toast.userDeleted'));
setDeleteId(null);
},
- onError: (err) =>
- toast.error(err instanceof Error ? err.message : 'Failed'),
+ onError: (err) => toastApiError(err, t('toast.deleteUserFailed')),
});
+ // FE-C5: while any mutation (update or delete) is in flight for a user, all of
+ // that user's controls are disabled — otherwise a PATCH could race the DELETE
+ // (or a second PATCH) and fire conflicting requests.
+ const updatePendingId = updateMutation.isPending
+ ? updateMutation.variables?.id
+ : undefined;
+ const deletePendingId = deleteMutation.isPending
+ ? deleteMutation.variables
+ : undefined;
+ const isRowPending = (id: string) =>
+ id === updatePendingId || id === deletePendingId;
+
return (
@@ -126,7 +142,7 @@ export default function AdminUsersPage() {
| |