@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.
@@ -1 +1,6 @@
1
- export declare function AuthPage(): import("react/jsx-runtime").JSX.Element;
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;
@@ -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
- router.replace('/admin/dashboard');
12
+ navigate('/admin/dashboard', { replace: true });
16
13
  }
17
- }, [token, pathname, router]);
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: () => router.replace('/admin/dashboard') });
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: