@airoom/nextmin-react 0.1.2 → 0.1.3
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/dist/auth/AuthPage.d.ts +6 -1
- package/dist/auth/AuthPage.js +4 -7
- package/dist/components/AdminApp.js +1 -1
- package/dist/nextmin.css +1 -1
- package/dist/providers/NextMinProvider.d.ts +2 -2
- package/dist/providers/NextMinProvider.js +2 -5
- package/dist/views/DashboardPage.js +15 -48
- package/dist/views/list/ListHeader.d.ts +1 -1
- package/dist/views/list/ListHeader.js +1 -1
- package/package.json +1 -1
package/dist/auth/AuthPage.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export declare function AuthPage(
|
|
1
|
+
export declare function AuthPage({ pathname, navigate, }: {
|
|
2
|
+
pathname: string | null | undefined;
|
|
3
|
+
navigate: (url: string, opts?: {
|
|
4
|
+
replace?: boolean;
|
|
5
|
+
}) => void;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/auth/AuthPage.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
-
import { usePathname, useRouter } from 'next/navigation';
|
|
5
4
|
import { useSelector } from 'react-redux';
|
|
6
5
|
import { SignInForm } from './SignInForm';
|
|
7
6
|
import { ForgotPasswordForm } from './ForgotPasswordForm';
|
|
8
|
-
export function AuthPage() {
|
|
9
|
-
const pathname = usePathname();
|
|
10
|
-
const router = useRouter();
|
|
7
|
+
export function AuthPage({ pathname, navigate, }) {
|
|
11
8
|
const token = useSelector((s) => s?.session?.token ?? null);
|
|
12
9
|
// If already authenticated on /admin/auth/* → go to dashboard
|
|
13
10
|
useEffect(() => {
|
|
14
11
|
if (token && pathname?.startsWith('/admin/auth')) {
|
|
15
|
-
|
|
12
|
+
navigate('/admin/dashboard', { replace: true });
|
|
16
13
|
}
|
|
17
|
-
}, [token, pathname,
|
|
14
|
+
}, [token, pathname, navigate]);
|
|
18
15
|
if (pathname?.startsWith('/admin/auth/forgot-password')) {
|
|
19
16
|
return _jsx(ForgotPasswordForm, {});
|
|
20
17
|
}
|
|
21
18
|
// Default = Sign in; SignInForm already stores token+user and updates Redux.
|
|
22
|
-
return _jsx(SignInForm, { onSuccess: () =>
|
|
19
|
+
return _jsx(SignInForm, { onSuccess: () => navigate('/admin/dashboard', { replace: true }) });
|
|
23
20
|
}
|
|
@@ -121,7 +121,7 @@ export function AdminApp() {
|
|
|
121
121
|
// - elsewhere: show loader while redirecting to sign-in
|
|
122
122
|
if (!haveToken) {
|
|
123
123
|
if (onAuthRoute)
|
|
124
|
-
return _jsx(AuthPage, {});
|
|
124
|
+
return (_jsx(AuthPage, { pathname: pathname, navigate: (url, opts) => opts?.replace ? router.replace(url) : router.push(url) }));
|
|
125
125
|
return _jsx(SectionLoader, { label: "Redirecting to sign in\u2026" });
|
|
126
126
|
}
|
|
127
127
|
// 3) Authed:
|