courrier multi account restore compose
This commit is contained in:
parent
d3ff8e6b19
commit
5981267f68
@ -1296,7 +1296,6 @@ export default function CourrierPage() {
|
||||
toast({ title: 'Password updated', description: 'Password changed successfully.' });
|
||||
setShowEditModal(false);
|
||||
setNewPassword('');
|
||||
// Refresh accounts (re-fetch or reload page)
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
toast({ title: 'Error', description: err instanceof Error ? err.message : 'Failed to update password', variant: 'destructive' });
|
||||
@ -1310,6 +1309,7 @@ export default function CourrierPage() {
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4">
|
||||
<Button type="button" variant="outline" onClick={() => setShowEditModal(false)}>Cancel</Button>
|
||||
<Button type="submit" disabled={editLoading}>{editLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Save'}</Button>
|
||||
</div>
|
||||
</form>
|
||||
</DialogContent>
|
||||
@ -1322,6 +1322,31 @@ export default function CourrierPage() {
|
||||
<AlertDialogTitle>Delete Account</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
Are you sure you want to delete this account? This action cannot be undone.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel onClick={() => setShowDeleteDialog(false)}>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction asChild>
|
||||
<Button variant="destructive" disabled={deleteLoading} onClick={async () => {
|
||||
if (!accountToDelete) return;
|
||||
setDeleteLoading(true);
|
||||
try {
|
||||
const res = await fetch(`/api/courrier/account?accountId=${accountToDelete.id}`, { method: 'DELETE' });
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Failed to delete account');
|
||||
toast({ title: 'Account deleted', description: 'The account was deleted successfully.' });
|
||||
setShowDeleteDialog(false);
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
toast({ title: 'Error', description: err instanceof Error ? err.message : 'Failed to delete account', variant: 'destructive' });
|
||||
} finally {
|
||||
setDeleteLoading(false);
|
||||
}
|
||||
}}>Delete</Button>
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user