@djangocfg/layouts 2.1.149 → 2.1.151
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/layouts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.151",
|
|
4
4
|
"description": "Simple, straightforward layout components for Next.js - import and use with props",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layouts",
|
|
@@ -74,12 +74,12 @@
|
|
|
74
74
|
"check": "tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@djangocfg/api": "^2.1.
|
|
78
|
-
"@djangocfg/centrifugo": "^2.1.
|
|
79
|
-
"@djangocfg/i18n": "^2.1.
|
|
80
|
-
"@djangocfg/ui-core": "^2.1.
|
|
81
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
82
|
-
"@djangocfg/ui-tools": "^2.1.
|
|
77
|
+
"@djangocfg/api": "^2.1.151",
|
|
78
|
+
"@djangocfg/centrifugo": "^2.1.151",
|
|
79
|
+
"@djangocfg/i18n": "^2.1.151",
|
|
80
|
+
"@djangocfg/ui-core": "^2.1.151",
|
|
81
|
+
"@djangocfg/ui-nextjs": "^2.1.151",
|
|
82
|
+
"@djangocfg/ui-tools": "^2.1.151",
|
|
83
83
|
"@hookform/resolvers": "^5.2.2",
|
|
84
84
|
"consola": "^3.4.2",
|
|
85
85
|
"lucide-react": "^0.545.0",
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
"uuid": "^11.1.0"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@djangocfg/api": "^2.1.
|
|
106
|
-
"@djangocfg/i18n": "^2.1.
|
|
107
|
-
"@djangocfg/centrifugo": "^2.1.
|
|
108
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
109
|
-
"@djangocfg/ui-core": "^2.1.
|
|
110
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
111
|
-
"@djangocfg/ui-tools": "^2.1.
|
|
105
|
+
"@djangocfg/api": "^2.1.151",
|
|
106
|
+
"@djangocfg/i18n": "^2.1.151",
|
|
107
|
+
"@djangocfg/centrifugo": "^2.1.151",
|
|
108
|
+
"@djangocfg/typescript-config": "^2.1.151",
|
|
109
|
+
"@djangocfg/ui-core": "^2.1.151",
|
|
110
|
+
"@djangocfg/ui-nextjs": "^2.1.151",
|
|
111
|
+
"@djangocfg/ui-tools": "^2.1.151",
|
|
112
112
|
"@types/node": "^24.7.2",
|
|
113
113
|
"@types/react": "^19.1.0",
|
|
114
114
|
"@types/react-dom": "^19.1.0",
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useAuth } from '@djangocfg/api/auth';
|
|
6
|
+
import { useT } from '@djangocfg/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook for logout with confirmation dialog
|
|
10
|
+
*
|
|
11
|
+
* Uses window.dialog.confirm for beautiful shadcn dialog
|
|
12
|
+
* with i18n translations from layouts.logout.*
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function UserMenu() {
|
|
17
|
+
* const handleLogout = useLogout();
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <Button onClick={handleLogout}>Logout</Button>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function useLogout() {
|
|
26
|
+
const { logout } = useAuth();
|
|
27
|
+
const t = useT();
|
|
28
|
+
|
|
29
|
+
const handleLogout = useCallback(async () => {
|
|
30
|
+
const confirmed = await window.dialog.confirm({
|
|
31
|
+
title: t('layouts.logout.title'),
|
|
32
|
+
message: t('layouts.logout.message'),
|
|
33
|
+
confirmText: t('layouts.logout.confirm'),
|
|
34
|
+
cancelText: t('layouts.logout.cancel'),
|
|
35
|
+
variant: 'destructive',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (confirmed) {
|
|
39
|
+
logout();
|
|
40
|
+
}
|
|
41
|
+
}, [logout, t]);
|
|
42
|
+
|
|
43
|
+
return handleLogout;
|
|
44
|
+
}
|
|
@@ -32,6 +32,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
32
32
|
|
|
33
33
|
import { SetupStep } from '../AuthLayout/components/steps/SetupStep';
|
|
34
34
|
import { profileLogger } from '../../utils/logger';
|
|
35
|
+
import { useLogout } from '../../hooks';
|
|
35
36
|
|
|
36
37
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
38
|
// Types
|
|
@@ -333,9 +334,7 @@ const ProfileContent = ({
|
|
|
333
334
|
}
|
|
334
335
|
};
|
|
335
336
|
|
|
336
|
-
const handleLogout = ()
|
|
337
|
-
logout();
|
|
338
|
-
};
|
|
337
|
+
const handleLogout = useLogout();
|
|
339
338
|
|
|
340
339
|
// Loading state
|
|
341
340
|
if (isLoading) {
|
|
@@ -558,7 +557,7 @@ const DeleteAccountDialog = ({ open, onOpenChange }: { open: boolean; onOpenChan
|
|
|
558
557
|
const result = await deleteAccount();
|
|
559
558
|
if (result.success) {
|
|
560
559
|
onOpenChange(false);
|
|
561
|
-
|
|
560
|
+
logout();
|
|
562
561
|
}
|
|
563
562
|
};
|
|
564
563
|
|
|
@@ -50,8 +50,8 @@ export const DeleteAccountSection: React.FC = () => {
|
|
|
50
50
|
const result = await deleteAccount();
|
|
51
51
|
if (result.success) {
|
|
52
52
|
setShowDeleteDialog(false);
|
|
53
|
-
// Perform logout after successful deletion (
|
|
54
|
-
|
|
53
|
+
// Perform logout after successful deletion (no confirmation needed since user already confirmed deletion)
|
|
54
|
+
logout();
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -36,6 +36,8 @@ import React, { useMemo } from 'react';
|
|
|
36
36
|
|
|
37
37
|
import { useAuth } from '@djangocfg/api/auth';
|
|
38
38
|
import { useTypedT, type I18nTranslations } from '@djangocfg/i18n';
|
|
39
|
+
|
|
40
|
+
import { useLogout } from '../../hooks';
|
|
39
41
|
import {
|
|
40
42
|
Avatar, AvatarFallback, AvatarImage, Button, DropdownMenu, DropdownMenuContent,
|
|
41
43
|
DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator,
|
|
@@ -58,7 +60,8 @@ export function UserMenu({
|
|
|
58
60
|
groups,
|
|
59
61
|
authPath = '/auth',
|
|
60
62
|
}: UserMenuProps) {
|
|
61
|
-
const { user, isAuthenticated
|
|
63
|
+
const { user, isAuthenticated } = useAuth();
|
|
64
|
+
const handleLogout = useLogout();
|
|
62
65
|
const [mounted, setMounted] = React.useState(false);
|
|
63
66
|
const t = useTypedT<I18nTranslations>();
|
|
64
67
|
|
|
@@ -87,7 +90,7 @@ export function UserMenu({
|
|
|
87
90
|
items: [
|
|
88
91
|
{
|
|
89
92
|
label: labels.signOut,
|
|
90
|
-
onClick:
|
|
93
|
+
onClick: handleLogout,
|
|
91
94
|
icon: LogOut,
|
|
92
95
|
variant: 'destructive',
|
|
93
96
|
},
|
|
@@ -95,7 +98,7 @@ export function UserMenu({
|
|
|
95
98
|
});
|
|
96
99
|
|
|
97
100
|
return allGroups;
|
|
98
|
-
}, [groups,
|
|
101
|
+
}, [groups, handleLogout, labels.signOut]);
|
|
99
102
|
|
|
100
103
|
if (!mounted) {
|
|
101
104
|
return null;
|