improvement: QRcode and shared link added to cases inorder to make it possible for staff users to share a case info with other staffs or other clinics.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { CaseTasksFocusView } from '@/components/ui/lab/CaseTasksFocusView';
|
||||
|
||||
interface LabCaseAccessPageProps {
|
||||
params: Promise<{ token: string }>;
|
||||
}
|
||||
|
||||
export default async function LabCaseAccessPage({ params }: LabCaseAccessPageProps) {
|
||||
const { token } = await params;
|
||||
return <CaseTasksFocusView token={token} />;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { useTranslations } from 'next-intl';
|
||||
import { Menu } from 'lucide-react';
|
||||
import { usePathname, useRouter } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { storeAuthRedirectFromPath } from '@/lib/auth/postAuthRedirect';
|
||||
import Sidebar from '@/components/ui/shared/Sidebar';
|
||||
import { TopBarControls } from '@/components/ui/shared/TopBarControls';
|
||||
import { DashboardAccountMenu } from '@/components/ui/dashboard/DashboardAccountMenu';
|
||||
@@ -40,7 +41,12 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
if (!isAuthReady) return;
|
||||
|
||||
if (!user) {
|
||||
router.replace('/login');
|
||||
if (pathname && pathname !== '/login') {
|
||||
storeAuthRedirectFromPath(pathname);
|
||||
router.replace(`/login?from=${encodeURIComponent(pathname)}`);
|
||||
} else {
|
||||
router.replace('/login');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { Suspense, useState, useEffect, useMemo } from 'react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { useRouter } from '@/i18n/navigation';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
@@ -15,6 +16,10 @@ import { AuthPageShell } from '@/components/ui/auth/AuthPageShell';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Checkbox } from '@/components/ui/shared/Checkbox';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
import {
|
||||
consumeAuthRedirect,
|
||||
storeAuthRedirectFromPath,
|
||||
} from '@/lib/auth/postAuthRedirect';
|
||||
|
||||
type LoginForm = {
|
||||
email: string;
|
||||
@@ -22,13 +27,14 @@ type LoginForm = {
|
||||
rememberMe: boolean;
|
||||
};
|
||||
|
||||
export default function LoginPage() {
|
||||
function LoginPageContent() {
|
||||
const t = useTranslations('auth');
|
||||
const tCommon = useTranslations('common');
|
||||
const tValidation = useTranslations('validation');
|
||||
const tErrors = useTranslations('errors');
|
||||
const { login, isLoading, user, isAuthReady } = useAuth();
|
||||
const { login, isLoading, user, isAuthReady, organizations, currentOrganization } = useAuth();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [savedEmail] = useState(() => getRememberedEmail());
|
||||
|
||||
@@ -43,10 +49,18 @@ export default function LoginPage() {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthReady && user) {
|
||||
router.push('/today');
|
||||
const from = searchParams.get('from');
|
||||
if (from) {
|
||||
storeAuthRedirectFromPath(from);
|
||||
}
|
||||
}, [user, isAuthReady, router]);
|
||||
}, [searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuthReady || !user || isLoading) return;
|
||||
const orgReady = organizations.length <= 1 || currentOrganization;
|
||||
if (!orgReady) return;
|
||||
router.push(consumeAuthRedirect() ?? '/today');
|
||||
}, [isAuthReady, user, isLoading, organizations, currentOrganization, router]);
|
||||
|
||||
const {
|
||||
register,
|
||||
@@ -152,3 +166,21 @@ export default function LoginPage() {
|
||||
</AuthPageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function LoginPageFallback() {
|
||||
const tCommon = useTranslations('common');
|
||||
|
||||
return (
|
||||
<div className="min-h-[100dvh] app-web-bg flex items-center justify-center px-4">
|
||||
<p className="text-text-secondary">{tCommon('loading')}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<Suspense fallback={<LoginPageFallback />}>
|
||||
<LoginPageContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user