feature: localization's first implmentation
This commit is contained in:
@@ -1,241 +0,0 @@
|
||||
// src/app/login/page.tsx
|
||||
// 'use client';
|
||||
// import { useState } from 'react';
|
||||
// import { useForm } from 'react-hook-form';
|
||||
// import { zodResolver } from '@hookform/resolvers/zod';
|
||||
// import * as z from 'zod';
|
||||
// import Link from 'next/link';
|
||||
// import { Mail, Lock } from 'lucide-react';
|
||||
// import { useAuth } from '@/lib/hooks/useAuth';
|
||||
// import { Button } from '@/components/ui/Button';
|
||||
// import { Input } from '@/components/ui/Input';
|
||||
// const loginSchema = z.object({
|
||||
// email: z.string().email('Please enter a valid email address'),
|
||||
// password: z.string().min(1, 'Password is required'),
|
||||
// });
|
||||
// type LoginForm = z.infer<typeof loginSchema>;
|
||||
// export default function LoginPage() {
|
||||
// const { login, isLoading } = useAuth();
|
||||
// const [error, setError] = useState<string | null>(null);
|
||||
// const {
|
||||
// register,
|
||||
// handleSubmit,
|
||||
// formState: { errors },
|
||||
// } = useForm<LoginForm>({
|
||||
// resolver: zodResolver(loginSchema),
|
||||
// });
|
||||
// const onSubmit = async (data: LoginForm) => {
|
||||
// try {
|
||||
// setError(null);
|
||||
// await login(data.email, data.password);
|
||||
// } catch (err: any) {
|
||||
// setError(err.message || 'Invalid email or password');
|
||||
// }
|
||||
// };
|
||||
|
||||
// return (
|
||||
// <div className="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
// <div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
// <Link href="/" className="flex justify-center">
|
||||
// <span className="text-3xl font-bold text-primary-600">DyoLink</span>
|
||||
// </Link>
|
||||
// <h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
|
||||
// Sign in to your account
|
||||
// </h2>
|
||||
// <p className="mt-2 text-center text-sm text-gray-600">
|
||||
// Or{' '}
|
||||
// <Link href="/register" className="font-medium text-primary-600 hover:text-primary-500">
|
||||
// start your free trial
|
||||
// </Link>
|
||||
// </p>
|
||||
// </div>
|
||||
// <div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
// <div className="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
|
||||
// <form className="space-y-6" onSubmit={handleSubmit(onSubmit)}>
|
||||
// <Input
|
||||
// label="Email address"
|
||||
// {...register('email')}
|
||||
// type="email"
|
||||
// placeholder="you@example.com"
|
||||
// error={errors.email?.message}
|
||||
// icon={<Mail className="h-5 w-5 text-gray-400" />}
|
||||
// />
|
||||
// <Input
|
||||
// label="Password"
|
||||
// {...register('password')}
|
||||
// type="password"
|
||||
// placeholder="••••••••"
|
||||
// error={errors.password?.message}
|
||||
// icon={<Lock className="h-5 w-5 text-gray-400" />}
|
||||
// />
|
||||
// <div className="flex items-center justify-between">
|
||||
// <div className="flex items-center">
|
||||
// <input
|
||||
// id="remember-me"
|
||||
// name="remember-me"
|
||||
// type="checkbox"
|
||||
// className="h-4 w-4 text-primary-600 focus:ring-primary-500border-gray-300 rounded"
|
||||
// />
|
||||
// <label htmlFor="remember-me" className="ml-2 block text-sm text-gray-900">
|
||||
// Remember me
|
||||
// </label>
|
||||
// </div>
|
||||
// <div className="text-sm">
|
||||
// <Link href="/forgot-password" className="font-medium text-primary-600 hover:text-primary-500">
|
||||
// Forgot your password?
|
||||
// </Link>
|
||||
// </div>
|
||||
// </div>
|
||||
// {error && (
|
||||
// <div className="p-3 bg-red-50 border border-red-200 rounded-lg">
|
||||
// <p className="text-sm text-red-600">{error}</p>
|
||||
// </div>
|
||||
// )}
|
||||
// <Button
|
||||
// type="submit"
|
||||
// variant="primary"
|
||||
// isLoading={isLoading}
|
||||
// fullWidth
|
||||
// >
|
||||
// Sign in
|
||||
// </Button>
|
||||
// </form>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import Link from 'next/link';
|
||||
import { Mail, Lock } from 'lucide-react';
|
||||
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Please enter a valid email address'),
|
||||
password: z.string().min(1, 'Password is required'),
|
||||
});
|
||||
|
||||
type LoginForm = z.infer<typeof loginSchema>;
|
||||
|
||||
export default function LoginPage() {
|
||||
const { login, isLoading, user, isAuthReady } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthReady && user) {
|
||||
router.push('/today');
|
||||
}
|
||||
}, [user, isAuthReady, router]);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<LoginForm>({
|
||||
resolver: zodResolver(loginSchema),
|
||||
});
|
||||
|
||||
const onSubmit = async (data: LoginForm) => {
|
||||
try {
|
||||
setError(null);
|
||||
await login(data.email, data.password);
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Invalid email or password');
|
||||
}
|
||||
};
|
||||
|
||||
if (!isAuthReady) {
|
||||
return (
|
||||
<div className="min-h-screen app-web-bg flex items-center justify-center">
|
||||
<p className="text-text-secondary">Loading...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen app-web-bg flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Link href="/" className="flex justify-center">
|
||||
<span className="text-3xl font-semibold text-text-primary">DyoLink</span>
|
||||
</Link>
|
||||
<h2 className="mt-6 text-center text-3xl font-semibold text-text-primary">
|
||||
Sign in to your account
|
||||
</h2>
|
||||
<p className="mt-2 text-center text-sm text-text-secondary">
|
||||
Or{' '}
|
||||
<Link href="/register" className="font-medium text-primary hover:opacity-90">
|
||||
start your free trial
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="surface-card py-8 px-4 sm:px-10">
|
||||
<form className="space-y-6" onSubmit={handleSubmit(onSubmit)}>
|
||||
<Input
|
||||
label="Email address"
|
||||
{...register('email')}
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
error={errors.email?.message}
|
||||
icon={<Mail className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label="Password"
|
||||
{...register('password')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.password?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center">
|
||||
<input
|
||||
id="remember-me"
|
||||
name="remember-me"
|
||||
type="checkbox"
|
||||
className="h-4 w-4 rounded border-border bg-background-secondary text-primary focus:ring-primary/40"
|
||||
/>
|
||||
<label htmlFor="remember-me" className="ml-2 block text-sm text-text-secondary">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<Link href="/forgot-password" className="font-medium text-primary hover:opacity-90">
|
||||
Forgot your password?
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="p-3 bg-red-50 border border-red-200 rounded-lg">
|
||||
<p className="text-sm text-red-600">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
isLoading={isLoading}
|
||||
fullWidth
|
||||
>
|
||||
Sign in
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
// src/app/register/page.tsx\
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import Link from 'next/link';
|
||||
import { Mail, Lock, User } from 'lucide-react';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { OrganizationDetailsFields } from '@/components/ui/auth/OrganizationDetailsFields';
|
||||
import { RegistrationProgressSteps } from '@/components/ui/auth/RegistrationProgressSteps';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
const registerSchema = z.object({
|
||||
name: z.string().min(2, 'Name must be at least 2 characters'),
|
||||
email: z.string().email('Please enter a valid email address'),
|
||||
password: z.string()
|
||||
.min(8, 'Password must be at least 8 characters')
|
||||
.regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
|
||||
.regex(/[0-9]/, 'Password must contain at least one number'),
|
||||
confirmPassword: z.string(),
|
||||
organizationName: z.string().min(2, 'Organization name must be at least 2 characters'),
|
||||
organizationEmail: z.string().email('Please enter a valid organization email'),
|
||||
organizationType: z.enum(['CLINIC', 'LAB'], {
|
||||
message: 'Please select organization type',
|
||||
}),
|
||||
}).refine((data) => data.password === data.confirmPassword, {
|
||||
message: "Passwords don't match",
|
||||
path: ['confirmPassword'],
|
||||
});
|
||||
type RegisterForm = z.infer<typeof registerSchema>;
|
||||
|
||||
export default function RegisterPage() {
|
||||
const { registerTrial, isLoading } = useAuth();
|
||||
const [step, setStep] = useState(1);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
formState: { errors },
|
||||
trigger,
|
||||
setValue,
|
||||
} = useForm<RegisterForm>({
|
||||
resolver: zodResolver(registerSchema),
|
||||
mode: 'onChange',
|
||||
});
|
||||
const organizationType = watch('organizationType');
|
||||
const handleNext = async () => {
|
||||
const fieldsToValidate = step === 1
|
||||
? ['name', 'email', 'password', 'confirmPassword']
|
||||
: ['organizationName', 'organizationEmail', 'organizationType'];
|
||||
|
||||
const isValid = await trigger(fieldsToValidate as any);
|
||||
if (isValid) {
|
||||
setStep(step + 1);
|
||||
}
|
||||
};
|
||||
const onSubmit = async (data: RegisterForm) => {
|
||||
try {
|
||||
setError(null);
|
||||
await registerTrial(
|
||||
data.email,
|
||||
data.password,
|
||||
data.name,
|
||||
data.organizationName,
|
||||
data.organizationEmail,
|
||||
data.organizationType
|
||||
);
|
||||
// No need to redirect - auth context will handle it
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Registration failed. Please try again.');
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="min-h-screen app-web-bg flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Link href="/" className="flex justify-center">
|
||||
<span className="text-3xl font-semibold text-text-primary">DyoLink</span>
|
||||
</Link>
|
||||
<h2 className="mt-6 text-center text-3xl font-semibold text-text-primary">
|
||||
Start your 30-day free trial
|
||||
</h2>
|
||||
<p className="mt-2 text-center text-sm text-text-secondary">
|
||||
Already have an account?{' '}
|
||||
<Link href="/login" className="font-medium text-primary hover:opacity-90">
|
||||
Sign in
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="surface-card py-8 px-4 sm:px-10">
|
||||
<RegistrationProgressSteps step={step} />
|
||||
{/* Trial Info Banner */}
|
||||
<div className="mb-6 p-4 bg-primary-soft rounded-[var(--radius-md)] border border-primary/35">
|
||||
<h3 className="text-sm font-medium text-text-primary mb-2">Your trial
|
||||
includes:</h3>
|
||||
<ul className="text-sm text-text-secondary space-y-1">
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> Up to 5 team members
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> Full access to all features
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> 30 days free, no credit card
|
||||
required
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="space-y-6">
|
||||
{step === 1 && (
|
||||
<>
|
||||
<Input
|
||||
label="Full name"
|
||||
{...register('name')}
|
||||
placeholder="John Doe"
|
||||
error={errors.name?.message}
|
||||
icon={<User className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label="Email address"
|
||||
{...register('email')}
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
error={errors.email?.message}
|
||||
icon={<Mail className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label="Password"
|
||||
{...register('password')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.password?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label="Confirm password"
|
||||
{...register('confirmPassword')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.confirmPassword?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="primary"
|
||||
onClick={handleNext}
|
||||
fullWidth
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{step === 2 && (
|
||||
<>
|
||||
<OrganizationDetailsFields
|
||||
register={register as never}
|
||||
errors={errors as never}
|
||||
organizationType={organizationType}
|
||||
setValue={setValue as never}
|
||||
/>
|
||||
{error && (
|
||||
<div className="p-3 bg-red-950/30 border border-red-600/40 rounded-[var(--radius-md)]">
|
||||
<p className="text-sm text-red-600">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => setStep(1)}
|
||||
>
|
||||
Back
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
isLoading={isLoading}
|
||||
fullWidth
|
||||
>
|
||||
Start my free trial
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</form>
|
||||
<p className="mt-6 text-xs text-center text-text-muted">
|
||||
By signing up, you agree to our{' '}
|
||||
<Link href="/terms" className="text-primary hover:opacity-90">
|
||||
Terms of Service
|
||||
</Link>{' '}
|
||||
and{' '}
|
||||
<Link href="/privacy" className="text-primary hover:opacity-90">
|
||||
Privacy Policy
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import { memo, useEffect } from 'react';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { usePathname, useRouter } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import Sidebar from '@/components/ui/shared/Sidebar';
|
||||
import { ThemeToggle } from '@/components/ui/shared/ThemeToggle';
|
||||
import { TopBarControls } from '@/components/ui/shared/TopBarControls';
|
||||
import { DashboardAccountMenu } from '@/components/ui/dashboard/DashboardAccountMenu';
|
||||
import {
|
||||
canAccessAppointmentsSection,
|
||||
@@ -14,11 +15,11 @@ import {
|
||||
} from '@/components/shared/permissions';
|
||||
|
||||
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
const t = useTranslations('common');
|
||||
const { user, currentOrganization, isAuthReady } = useAuth();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
|
||||
// ✅ AUTH GUARD (runs once per navigation group)
|
||||
useEffect(() => {
|
||||
if (!isAuthReady) return;
|
||||
|
||||
@@ -44,11 +45,10 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
}
|
||||
}, [isAuthReady, user, currentOrganization, router, pathname]);
|
||||
|
||||
// ✅ LOADING ONLY FOR INITIAL LOAD
|
||||
if (!isAuthReady) {
|
||||
return (
|
||||
<div className="h-screen flex items-center justify-center app-web-bg">
|
||||
Loading app...
|
||||
{t('loadingApp')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
if (!user || !currentOrganization) {
|
||||
return (
|
||||
<div className="h-screen flex items-center justify-center app-web-bg">
|
||||
Loading workspace...
|
||||
{t('loadingWorkspace')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -88,9 +88,9 @@ const DashboardHeader = memo(function DashboardHeader({
|
||||
<h2 className="text-lg font-medium truncate min-w-0">{organizationName}</h2>
|
||||
|
||||
<div className="flex items-center gap-3 shrink-0">
|
||||
<ThemeToggle />
|
||||
<TopBarControls />
|
||||
<DashboardAccountMenu />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
|
||||
export default function AccountSettingsPage() {
|
||||
return (
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import { OrganizationSelectorContent } from '@/components/ui/organizations/OrganizationSelectorContent';
|
||||
|
||||
export default function DashboardOrganizationsSettingsPage() {
|
||||
@@ -1,8 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Link, useRouter } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { authApi } from '@/lib/api/auth';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/i18n/navigation';
|
||||
import {
|
||||
firstAccessibleDashboardPath,
|
||||
canEditStaff,
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { Card } from '@/components/ui/shared/Card';
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Suspense } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Link, useRouter } from '@/i18n/navigation';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
import { staffApi } from '@/lib/api/staff';
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { Suspense, useEffect, useMemo, useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Link, useRouter } from '@/i18n/navigation';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { useForm, type FieldErrors, type UseFormRegister, type UseFormSetValue } from 'react-hook-form';
|
||||
import type { OrganizationDetailsFormValues } from '@/components/ui/auth/OrganizationDetailsFields';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
144
frontend/src/app/[locale]/(public)/login/page.tsx
Normal file
144
frontend/src/app/[locale]/(public)/login/page.tsx
Normal file
@@ -0,0 +1,144 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { useRouter } from '@/i18n/navigation';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import { Mail, Lock } from 'lucide-react';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
import { TopBarControls } from '@/components/ui/shared/TopBarControls';
|
||||
|
||||
type LoginForm = {
|
||||
email: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export default function LoginPage() {
|
||||
const t = useTranslations('auth');
|
||||
const tCommon = useTranslations('common');
|
||||
const tValidation = useTranslations('validation');
|
||||
const { login, isLoading, user, isAuthReady } = useAuth();
|
||||
const router = useRouter();
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const loginSchema = useMemo(
|
||||
() =>
|
||||
z.object({
|
||||
email: z.string().email(tValidation('emailInvalid')),
|
||||
password: z.string().min(1, tValidation('passwordRequired')),
|
||||
}),
|
||||
[tValidation],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthReady && user) {
|
||||
router.push('/today');
|
||||
}
|
||||
}, [user, isAuthReady, router]);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
} = useForm<LoginForm>({
|
||||
resolver: zodResolver(loginSchema),
|
||||
});
|
||||
|
||||
const onSubmit = async (data: LoginForm) => {
|
||||
try {
|
||||
setError(null);
|
||||
await login(data.email, data.password);
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : t('invalidCredentials');
|
||||
setError(message || t('invalidCredentials'));
|
||||
}
|
||||
};
|
||||
|
||||
if (!isAuthReady) {
|
||||
return (
|
||||
<div className="min-h-screen app-web-bg flex items-center justify-center">
|
||||
<p className="text-text-secondary">{tCommon('loading')}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="relative min-h-screen app-web-bg flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="absolute top-4 right-4">
|
||||
<TopBarControls />
|
||||
</div>
|
||||
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Link href="/" className="flex justify-center">
|
||||
<span className="text-3xl font-semibold text-text-primary">{tCommon('appName')}</span>
|
||||
</Link>
|
||||
<h2 className="mt-6 text-center text-3xl font-semibold text-text-primary">
|
||||
{t('signInTitle')}
|
||||
</h2>
|
||||
<p className="mt-2 text-center text-sm text-text-secondary">
|
||||
Or{' '}
|
||||
<Link href="/register" className="font-medium text-primary hover:opacity-90">
|
||||
{t('startTrialLink')}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="surface-card py-8 px-4 sm:px-10">
|
||||
<form className="space-y-6" onSubmit={handleSubmit(onSubmit)}>
|
||||
<Input
|
||||
label={t('email')}
|
||||
{...register('email')}
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
error={errors.email?.message}
|
||||
icon={<Mail className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label={t('password')}
|
||||
{...register('password')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.password?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center">
|
||||
<input
|
||||
id="remember-me"
|
||||
name="remember-me"
|
||||
type="checkbox"
|
||||
className="h-4 w-4 rounded border-border bg-background-secondary text-primary focus:ring-primary/40"
|
||||
/>
|
||||
<label htmlFor="remember-me" className="ml-2 block text-sm text-text-secondary">
|
||||
{t('rememberMe')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<Link href="/forgot-password" className="font-medium text-primary hover:opacity-90">
|
||||
{t('forgotPassword')}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="p-3 bg-red-50 border border-red-200 rounded-lg">
|
||||
<p className="text-sm text-red-600">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button type="submit" variant="primary" isLoading={isLoading} fullWidth>
|
||||
{t('signIn')}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,120 +1,112 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { ThemeToggle } from '@/components/ui/shared/ThemeToggle';
|
||||
import { TopBarControls } from '@/components/ui/shared/TopBarControls';
|
||||
import { Building2, Beaker, Calendar, Shield, Clock, Users } from 'lucide-react';
|
||||
|
||||
export default function HomePage() {
|
||||
const t = useTranslations('landing');
|
||||
const tAuth = useTranslations('auth');
|
||||
const tCommon = useTranslations('common');
|
||||
const { user } = useAuth();
|
||||
|
||||
return (
|
||||
<div className="min-h-screen app-web-bg text-text-primary">
|
||||
|
||||
{/* Header */}
|
||||
<header className="border-b border-border/70 bg-background-secondary/65 backdrop-blur-sm fixed top-0 w-full z-10">
|
||||
<div className="container mx-auto px-4 py-4 flex justify-between items-center">
|
||||
<div className="text-2xl font-semibold text-text-primary">
|
||||
DyoLink
|
||||
{tCommon('appName')}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<ThemeToggle />
|
||||
<TopBarControls />
|
||||
{user ? (
|
||||
<Link href="/today">
|
||||
<Button variant="primary">Dashboard</Button>
|
||||
<Button variant="primary">{tAuth('dashboard')}</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<>
|
||||
<Link href="/login">
|
||||
<Button variant="outline">Login</Button>
|
||||
<Button variant="outline">{tAuth('login')}</Button>
|
||||
</Link>
|
||||
<Link href="/register">
|
||||
<Button variant="primary">Start Trial</Button>
|
||||
<Button variant="primary">{tAuth('startTrial')}</Button>
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* Hero Section */}
|
||||
<main className="container mx-auto px-4 pt-32 pb-20">
|
||||
|
||||
<div className="max-w-4xl mx-auto text-center">
|
||||
|
||||
<h1 className="text-5xl md:text-6xl font-semibold mb-6 leading-tight">
|
||||
Connect Dental Clinics & Labs
|
||||
<span className="text-primary"> Seamlessly</span>
|
||||
{t('heroTitle')}
|
||||
<span className="text-primary"> {t('heroHighlight')}</span>
|
||||
</h1>
|
||||
|
||||
<p className="text-lg text-text-secondary mb-8 max-w-2xl mx-auto">
|
||||
Streamline communication between dental professionals. Start with
|
||||
a 30-day free trial, no credit card required.
|
||||
{t('heroSubtitle')}
|
||||
</p>
|
||||
|
||||
{!user && (
|
||||
<Link href="/register">
|
||||
<Button size="lg" variant="primary" className="px-8">
|
||||
Start Free Trial
|
||||
{tAuth('startFreeTrial')}
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Features */}
|
||||
<div className="mt-20 grid md:grid-cols-3 gap-6">
|
||||
<FeatureCard
|
||||
icon={<Building2 className="h-6 w-6 icon-flat" />}
|
||||
title="For Clinics"
|
||||
description="Manage patients, appointments, and send cases to labs instantly."
|
||||
title={t('featureClinicsTitle')}
|
||||
description={t('featureClinicsDescription')}
|
||||
/>
|
||||
<FeatureCard
|
||||
icon={<Beaker className="h-6 w-6 icon-flat" />}
|
||||
title="For Labs"
|
||||
description="Receive cases, track progress, and communicate with clinics."
|
||||
title={t('featureLabsTitle')}
|
||||
description={t('featureLabsDescription')}
|
||||
/>
|
||||
<FeatureCard
|
||||
icon={<Users className="h-6 w-6 icon-flat" />}
|
||||
title="Team Management"
|
||||
description="Add up to 5 team members during trial. Scale as you grow."
|
||||
title={t('featureTeamTitle')}
|
||||
description={t('featureTeamDescription')}
|
||||
/>
|
||||
<FeatureCard
|
||||
icon={<Calendar className="h-6 w-6 icon-flat" />}
|
||||
title="30-Day Trial"
|
||||
description="Full access to all features. No credit card required."
|
||||
title={t('featureTrialTitle')}
|
||||
description={t('featureTrialDescription')}
|
||||
/>
|
||||
<FeatureCard
|
||||
icon={<Clock className="h-6 w-6 icon-flat" />}
|
||||
title="Real-time Updates"
|
||||
description="Get instant notifications on case status changes."
|
||||
title={t('featureRealtimeTitle')}
|
||||
description={t('featureRealtimeDescription')}
|
||||
/>
|
||||
<FeatureCard
|
||||
icon={<Shield className="h-6 w-6 icon-flat" />}
|
||||
title="Secure & Compliant"
|
||||
description="HIPAA-compliant with enterprise-grade security."
|
||||
title={t('featureSecurityTitle')}
|
||||
description={t('featureSecurityDescription')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="border-t border-border/70 bg-background-secondary/80">
|
||||
<div className="container mx-auto px-4 py-8 flex flex-col md:flex-row justify-between items-center text-sm text-text-secondary">
|
||||
|
||||
<div>© 2026 DyoLink. All rights reserved.</div>
|
||||
<div>{t('footerCopyright')}</div>
|
||||
|
||||
<div className="flex gap-6 mt-4 md:mt-0">
|
||||
<Link href="/terms" className="hover:text-primary transition-colors">
|
||||
Terms & Conditions
|
||||
{t('termsAndConditions')}
|
||||
</Link>
|
||||
<Link href="/privacy" className="hover:text-primary transition-colors">
|
||||
Privacy Policy
|
||||
{tAuth('privacyPolicy')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -132,19 +124,9 @@ function FeatureCard({
|
||||
}) {
|
||||
return (
|
||||
<div className="surface-card p-5 transition-all hover:border-primary/70 hover:shadow-[0_0_20px_rgba(0,194,255,0.12)]">
|
||||
|
||||
<div className="text-primary mb-4">
|
||||
{icon}
|
||||
</div>
|
||||
|
||||
<h3 className="text-base font-medium text-text-primary mb-2">
|
||||
{title}
|
||||
</h3>
|
||||
|
||||
<p className="text-sm text-text-secondary">
|
||||
{description}
|
||||
</p>
|
||||
|
||||
<div className="text-primary mb-4">{icon}</div>
|
||||
<h3 className="text-base font-medium text-text-primary mb-2">{title}</h3>
|
||||
<p className="text-sm text-text-secondary">{description}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
221
frontend/src/app/[locale]/(public)/register/page.tsx
Normal file
221
frontend/src/app/[locale]/(public)/register/page.tsx
Normal file
@@ -0,0 +1,221 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import { Mail, Lock, User } from 'lucide-react';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { OrganizationDetailsFields } from '@/components/ui/auth/OrganizationDetailsFields';
|
||||
import { RegistrationProgressSteps } from '@/components/ui/auth/RegistrationProgressSteps';
|
||||
import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
import { TopBarControls } from '@/components/ui/shared/TopBarControls';
|
||||
|
||||
type RegisterForm = {
|
||||
name: string;
|
||||
email: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
organizationName: string;
|
||||
organizationEmail: string;
|
||||
organizationType: 'CLINIC' | 'LAB';
|
||||
};
|
||||
|
||||
export default function RegisterPage() {
|
||||
const t = useTranslations('auth');
|
||||
const tCommon = useTranslations('common');
|
||||
const tValidation = useTranslations('validation');
|
||||
const { registerTrial, isLoading } = useAuth();
|
||||
const [step, setStep] = useState(1);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const registerSchema = useMemo(
|
||||
() =>
|
||||
z
|
||||
.object({
|
||||
name: z.string().min(2, tValidation('nameMinLength')),
|
||||
email: z.string().email(tValidation('emailInvalid')),
|
||||
password: z
|
||||
.string()
|
||||
.min(8, tValidation('passwordMinLength'))
|
||||
.regex(/[A-Z]/, tValidation('passwordUppercase'))
|
||||
.regex(/[0-9]/, tValidation('passwordNumber')),
|
||||
confirmPassword: z.string(),
|
||||
organizationName: z.string().min(2, tValidation('organizationNameMinLength')),
|
||||
organizationEmail: z.string().email(tValidation('organizationEmailInvalid')),
|
||||
organizationType: z.enum(['CLINIC', 'LAB'], {
|
||||
message: tValidation('organizationTypeRequired'),
|
||||
}),
|
||||
})
|
||||
.refine((data) => data.password === data.confirmPassword, {
|
||||
message: tValidation('passwordsDoNotMatch'),
|
||||
path: ['confirmPassword'],
|
||||
}),
|
||||
[tValidation],
|
||||
);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
formState: { errors },
|
||||
trigger,
|
||||
setValue,
|
||||
} = useForm<RegisterForm>({
|
||||
resolver: zodResolver(registerSchema),
|
||||
mode: 'onChange',
|
||||
});
|
||||
|
||||
const organizationType = watch('organizationType');
|
||||
|
||||
const handleNext = async () => {
|
||||
const fieldsToValidate =
|
||||
step === 1
|
||||
? (['name', 'email', 'password', 'confirmPassword'] as const)
|
||||
: (['organizationName', 'organizationEmail', 'organizationType'] as const);
|
||||
|
||||
const isValid = await trigger([...fieldsToValidate]);
|
||||
if (isValid) {
|
||||
setStep(step + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = async (data: RegisterForm) => {
|
||||
try {
|
||||
setError(null);
|
||||
await registerTrial(
|
||||
data.email,
|
||||
data.password,
|
||||
data.name,
|
||||
data.organizationName,
|
||||
data.organizationEmail,
|
||||
data.organizationType,
|
||||
);
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : t('registrationFailed');
|
||||
setError(message || t('registrationFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="relative min-h-screen app-web-bg flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="absolute top-4 right-4">
|
||||
<TopBarControls />
|
||||
</div>
|
||||
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Link href="/" className="flex justify-center">
|
||||
<span className="text-3xl font-semibold text-text-primary">{tCommon('appName')}</span>
|
||||
</Link>
|
||||
<h2 className="mt-6 text-center text-3xl font-semibold text-text-primary">
|
||||
{t('registerTitle')}
|
||||
</h2>
|
||||
<p className="mt-2 text-center text-sm text-text-secondary">
|
||||
{t('registerPrompt')}{' '}
|
||||
<Link href="/login" className="font-medium text-primary hover:opacity-90">
|
||||
{t('signInLink')}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="surface-card py-8 px-4 sm:px-10">
|
||||
<RegistrationProgressSteps step={step} />
|
||||
<div className="mb-6 p-4 bg-primary-soft rounded-[var(--radius-md)] border border-primary/35">
|
||||
<h3 className="text-sm font-medium text-text-primary mb-2">{t('trialIncludes')}</h3>
|
||||
<ul className="text-sm text-text-secondary space-y-1">
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> {t('trialTeamMembers')}
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> {t('trialFullAccess')}
|
||||
</li>
|
||||
<li className="flex items-center">
|
||||
<span className="mr-2">✓</span> {t('trialNoCard')}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="space-y-6">
|
||||
{step === 1 && (
|
||||
<>
|
||||
<Input
|
||||
label={t('fullName')}
|
||||
{...register('name')}
|
||||
placeholder="John Doe"
|
||||
error={errors.name?.message}
|
||||
icon={<User className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label={t('email')}
|
||||
{...register('email')}
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
error={errors.email?.message}
|
||||
icon={<Mail className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label={t('password')}
|
||||
{...register('password')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.password?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label={t('confirmPassword')}
|
||||
{...register('confirmPassword')}
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.confirmPassword?.message}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Button type="button" variant="primary" onClick={handleNext} fullWidth>
|
||||
{tCommon('continue')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{step === 2 && (
|
||||
<>
|
||||
<OrganizationDetailsFields
|
||||
register={register as never}
|
||||
errors={errors as never}
|
||||
organizationType={organizationType}
|
||||
setValue={setValue as never}
|
||||
/>
|
||||
{error && (
|
||||
<div className="p-3 bg-red-950/30 border border-red-600/40 rounded-[var(--radius-md)]">
|
||||
<p className="text-sm text-red-600">{error}</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex gap-3">
|
||||
<Button type="button" variant="outline" onClick={() => setStep(1)}>
|
||||
{tCommon('back')}
|
||||
</Button>
|
||||
<Button type="submit" variant="primary" isLoading={isLoading} fullWidth>
|
||||
{t('startMyFreeTrial')}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</form>
|
||||
|
||||
<p className="mt-6 text-xs text-center text-text-muted">
|
||||
By signing up, you agree to our{' '}
|
||||
<Link href="/terms" className="text-primary hover:opacity-90">
|
||||
{t('termsOfService')}
|
||||
</Link>{' '}
|
||||
and{' '}
|
||||
<Link href="/privacy" className="text-primary hover:opacity-90">
|
||||
{t('privacyPolicy')}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
56
frontend/src/app/[locale]/layout.tsx
Normal file
56
frontend/src/app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import { getMessages, setRequestLocale } from 'next-intl/server';
|
||||
import { hasLocale } from 'next-intl';
|
||||
import { notFound } from 'next/navigation';
|
||||
import Script from 'next/script';
|
||||
import '@/styles/globals.css';
|
||||
import '@/styles/background-web.css';
|
||||
import { AuthProvider } from '@/lib/hooks/useAuth';
|
||||
import { THEME_STORAGE_KEY } from '@/lib/theme';
|
||||
import { routing, localeHtmlLang } from '@/i18n/routing';
|
||||
import { LocaleSync } from '@/components/i18n/LocaleSync';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'DyoLink - Dental Clinic & Lab Communication Hub',
|
||||
description: 'Connect dental clinics and laboratories seamlessly',
|
||||
};
|
||||
|
||||
export function generateStaticParams() {
|
||||
return routing.locales.map((locale) => ({ locale }));
|
||||
}
|
||||
|
||||
export default async function LocaleLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ locale: string }>;
|
||||
}) {
|
||||
const { locale } = await params;
|
||||
|
||||
if (!hasLocale(routing.locales, locale)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
setRequestLocale(locale);
|
||||
const messages = await getMessages();
|
||||
|
||||
const themeInit = `(function(){try{var k=${JSON.stringify(THEME_STORAGE_KEY)};var t=localStorage.getItem(k);document.documentElement.setAttribute('data-theme',t==='light'||t==='dark'?t:'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();`;
|
||||
|
||||
return (
|
||||
<html lang={localeHtmlLang(locale)} dir="ltr" suppressHydrationWarning>
|
||||
<body>
|
||||
<Script id="theme-init" strategy="beforeInteractive">
|
||||
{themeInit}
|
||||
</Script>
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<AuthProvider>
|
||||
<LocaleSync />
|
||||
{children}
|
||||
</AuthProvider>
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -1,33 +1,7 @@
|
||||
// src/app/layout.tsx
|
||||
import type { Metadata } from 'next';
|
||||
import Script from 'next/script';
|
||||
import '@/styles/globals.css';
|
||||
import '@/styles/background-web.css';
|
||||
import { AuthProvider } from '@/lib/hooks/useAuth';
|
||||
import { THEME_STORAGE_KEY } from '@/lib/theme';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'DyoLink - Dental Clinic & Lab Communication Hub',
|
||||
description: 'Connect dental clinics and laboratories seamlessly',
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const themeInit = `(function(){try{var k=${JSON.stringify(THEME_STORAGE_KEY)};var t=localStorage.getItem(k);document.documentElement.setAttribute('data-theme',t==='light'||t==='dark'?t:'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();`;
|
||||
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body>
|
||||
<Script id="theme-init" strategy="beforeInteractive">
|
||||
{themeInit}
|
||||
</Script>
|
||||
<AuthProvider>
|
||||
{children}
|
||||
</AuthProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
27
frontend/src/components/i18n/LocaleSync.tsx
Normal file
27
frontend/src/components/i18n/LocaleSync.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useLocale } from 'next-intl';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { usePathname, useRouter } from '@/i18n/navigation';
|
||||
import type { AppLocale } from '@/i18n/routing';
|
||||
import { isAppLocale } from '@/i18n/routing';
|
||||
|
||||
/** Redirect authenticated users to their saved profile language when it differs from the URL. */
|
||||
export function LocaleSync() {
|
||||
const locale = useLocale();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { user, isAuthReady } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuthReady || !user?.language) return;
|
||||
|
||||
const preferred = user.language;
|
||||
if (!isAppLocale(preferred) || preferred === locale) return;
|
||||
|
||||
router.replace(pathname, { locale: preferred as AppLocale });
|
||||
}, [isAuthReady, user?.language, locale, pathname, router]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Link } from '@/i18n/navigation';
|
||||
import {
|
||||
Settings,
|
||||
AlertTriangle,
|
||||
@@ -15,16 +16,21 @@ import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { authApi } from '@/lib/api/auth';
|
||||
import type { SubscriptionAlertData } from '@/types/subscription';
|
||||
|
||||
function warningTooltip(data: SubscriptionAlertData | null): string {
|
||||
function warningTooltip(
|
||||
data: SubscriptionAlertData | null,
|
||||
t: ReturnType<typeof useTranslations<'accountMenu'>>,
|
||||
): string {
|
||||
if (!data?.showWarning) return '';
|
||||
if (data.noActiveSubscription) return 'No active subscription — review Subscriptions';
|
||||
if (data.trialExpired) return 'Trial ended — review Subscriptions';
|
||||
if (data.trialEndingSoon) return 'Trial ending soon — review Subscriptions';
|
||||
if (data.seatsLow) return 'Seats running low — review Subscriptions';
|
||||
return 'Review Subscriptions';
|
||||
if (data.noActiveSubscription) return t('noActiveSubscription');
|
||||
if (data.trialExpired) return t('trialEnded');
|
||||
if (data.trialEndingSoon) return t('trialEndingSoon');
|
||||
if (data.seatsLow) return t('seatsLow');
|
||||
return t('reviewSubscriptions');
|
||||
}
|
||||
|
||||
export function DashboardAccountMenu() {
|
||||
const t = useTranslations('auth');
|
||||
const tAccount = useTranslations('accountMenu');
|
||||
const { user, currentOrganization, logout } = useAuth();
|
||||
const [open, setOpen] = useState(false);
|
||||
const menuRef = useRef<HTMLDivElement>(null);
|
||||
@@ -61,7 +67,7 @@ export function DashboardAccountMenu() {
|
||||
}, [isOwner, currentOrganization?.id]);
|
||||
|
||||
const showWarning = Boolean(isOwner && alert?.showWarning);
|
||||
const tooltip = useMemo(() => warningTooltip(alert), [alert]);
|
||||
const tooltip = useMemo(() => warningTooltip(alert, tAccount), [alert, tAccount]);
|
||||
|
||||
const handleLogout = useCallback(() => {
|
||||
setOpen(false);
|
||||
@@ -98,7 +104,7 @@ export function DashboardAccountMenu() {
|
||||
className="absolute right-0 mt-2 w-72 rounded-[var(--radius-md)] border border-border bg-background-secondary/95 py-2 shadow-lg z-[200] backdrop-blur-sm"
|
||||
>
|
||||
<div className="px-3 py-2 border-b border-border/60">
|
||||
<p className="text-xs text-text-muted">Signed in</p>
|
||||
<p className="text-xs text-text-muted">{t('signedIn')}</p>
|
||||
<p className="text-sm font-medium truncate">{user?.email}</p>
|
||||
<p className="text-xs text-text-secondary mt-1 truncate">
|
||||
{currentOrganization?.name}
|
||||
@@ -113,7 +119,7 @@ export function DashboardAccountMenu() {
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<Building2 className="h-4 w-4 icon-flat shrink-0" />
|
||||
Switch organization
|
||||
{t('switchOrganization')}
|
||||
</Link>
|
||||
|
||||
{isOwner && (
|
||||
@@ -124,7 +130,7 @@ export function DashboardAccountMenu() {
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<CreditCard className="h-4 w-4 icon-flat shrink-0" />
|
||||
Subscriptions
|
||||
{t('subscriptions')}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
@@ -135,7 +141,7 @@ export function DashboardAccountMenu() {
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
<User className="h-4 w-4 icon-flat shrink-0" />
|
||||
Account
|
||||
{t('account')}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -147,7 +153,7 @@ export function DashboardAccountMenu() {
|
||||
onClick={handleLogout}
|
||||
>
|
||||
<LogOut className="h-4 w-4 icon-flat shrink-0" />
|
||||
Log out
|
||||
{t('signOut')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
94
frontend/src/components/ui/shared/LanguageToggle.tsx
Normal file
94
frontend/src/components/ui/shared/LanguageToggle.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Globe, Check } from 'lucide-react';
|
||||
import { useLocale, useTranslations } from 'next-intl';
|
||||
import { usePathname, useRouter } from '@/i18n/navigation';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { authApi } from '@/lib/api/auth';
|
||||
import { locales, type AppLocale } from '@/i18n/routing';
|
||||
|
||||
const LOCALE_OPTIONS: AppLocale[] = [...locales];
|
||||
|
||||
export function LanguageToggle() {
|
||||
const t = useTranslations('language');
|
||||
const locale = useLocale() as AppLocale;
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { user, setUserLanguage } = useAuth();
|
||||
const [open, setOpen] = useState(false);
|
||||
const menuRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const onDocClick = (e: MouseEvent) => {
|
||||
if (menuRef.current && !menuRef.current.contains(e.target as Node)) {
|
||||
setOpen(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener('mousedown', onDocClick);
|
||||
return () => document.removeEventListener('mousedown', onDocClick);
|
||||
}, []);
|
||||
|
||||
const switchLocale = useCallback(
|
||||
async (next: AppLocale) => {
|
||||
if (next === locale) {
|
||||
setOpen(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (user) {
|
||||
setUserLanguage(next);
|
||||
try {
|
||||
await authApi.updateLanguage(next);
|
||||
} catch {
|
||||
/* keep optimistic locale in client state */
|
||||
}
|
||||
}
|
||||
|
||||
router.replace(pathname, { locale: next });
|
||||
setOpen(false);
|
||||
},
|
||||
[locale, pathname, router, setUserLanguage, user],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="relative" ref={menuRef}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
className="inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-[var(--radius-md)] border border-border/60 bg-background-secondary/80 px-2.5 text-text-primary hover:border-border-strong hover:bg-background-card/80 transition-colors"
|
||||
aria-label={t('selectLanguage')}
|
||||
aria-expanded={open}
|
||||
aria-haspopup="listbox"
|
||||
title={t('label')}
|
||||
>
|
||||
<Globe className="h-[18px] w-[18px] icon-flat" />
|
||||
<span className="text-xs font-medium uppercase">{locale}</span>
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<ul
|
||||
role="listbox"
|
||||
aria-label={t('selectLanguage')}
|
||||
className="absolute right-0 z-[200] mt-2 min-w-[10rem] rounded-[var(--radius-md)] border border-border bg-background-secondary/95 py-1 shadow-lg backdrop-blur-sm"
|
||||
>
|
||||
{LOCALE_OPTIONS.map((option) => {
|
||||
const selected = option === locale;
|
||||
return (
|
||||
<li key={option} role="option" aria-selected={selected}>
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-center justify-between gap-3 px-3 py-2 text-sm text-text-primary hover:bg-background-card/70"
|
||||
onClick={() => void switchLocale(option)}
|
||||
>
|
||||
<span>{t(option)}</span>
|
||||
{selected && <Check className="h-4 w-4 text-primary shrink-0" />}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { memo, useMemo } from 'react';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Link, usePathname } from '@/i18n/navigation';
|
||||
import {
|
||||
LayoutDashboard,
|
||||
Users,
|
||||
@@ -19,55 +19,46 @@ import {
|
||||
organizationTypeIcon,
|
||||
} from '@/components/shared/organizationTypeIcon';
|
||||
|
||||
const menu = [
|
||||
{ name: 'Dashboard', path: '/today', icon: LayoutDashboard, read: 'TAB_TODAY_READ' as const },
|
||||
{ name: 'Staff', path: '/staff', icon: UserCog, read: 'TAB_STAFF_READ' as const },
|
||||
{ name: 'Patients', path: '/patients', icon: Users, read: 'TAB_PATIENTS_READ' as const },
|
||||
{ name: 'Appointment', path: '/appointments', icon: Calendar, read: 'TAB_APPOINTMENTS_READ' as const },
|
||||
{ name: 'Treatment', path: '/treatment', icon: FlaskConical, read: 'TAB_TREATMENT_READ' as const },
|
||||
{ name: 'Billing', path: '/billing', icon: CreditCard, read: 'TAB_BILLING_READ' as const },
|
||||
{ name: 'Reports', path: '/reports', icon: FileText, read: 'TAB_REPORTS_READ' as const },
|
||||
];
|
||||
|
||||
function Sidebar() {
|
||||
const t = useTranslations('nav');
|
||||
const tCommon = useTranslations('common');
|
||||
const pathname = usePathname();
|
||||
const { currentOrganization } = useAuth();
|
||||
const counterpartLabel = currentOrganization?.type === 'LAB' ? 'Clinics' : 'Labs';
|
||||
const organizationsTabIcon = organizationTypeIcon(
|
||||
counterpartOrganizationType(currentOrganization?.type),
|
||||
|
||||
const menu = useMemo(
|
||||
() => [
|
||||
{ name: t('dashboard'), path: '/today', icon: LayoutDashboard, read: 'TAB_TODAY_READ' as const },
|
||||
{ name: t('staff'), path: '/staff', icon: UserCog, read: 'TAB_STAFF_READ' as const },
|
||||
{
|
||||
name: currentOrganization?.type === 'LAB' ? t('clinics') : t('labs'),
|
||||
path: '/organizations',
|
||||
icon: organizationTypeIcon(counterpartOrganizationType(currentOrganization?.type)),
|
||||
read: 'TAB_ORGANIZATIONS_READ' as const,
|
||||
},
|
||||
{ name: t('patients'), path: '/patients', icon: Users, read: 'TAB_PATIENTS_READ' as const },
|
||||
{ name: t('appointment'), path: '/appointments', icon: Calendar, read: 'TAB_APPOINTMENTS_READ' as const },
|
||||
{ name: t('treatment'), path: '/treatment', icon: FlaskConical, read: 'TAB_TREATMENT_READ' as const },
|
||||
{ name: t('billing'), path: '/billing', icon: CreditCard, read: 'TAB_BILLING_READ' as const },
|
||||
{ name: t('reports'), path: '/reports', icon: FileText, read: 'TAB_REPORTS_READ' as const },
|
||||
],
|
||||
[currentOrganization?.type, t],
|
||||
);
|
||||
|
||||
const visibleMenu = useMemo(
|
||||
() => {
|
||||
const withCounterpartTab = [
|
||||
menu[0],
|
||||
menu[1],
|
||||
{
|
||||
name: counterpartLabel,
|
||||
path: '/organizations',
|
||||
icon: organizationsTabIcon,
|
||||
read: 'TAB_ORGANIZATIONS_READ' as const,
|
||||
},
|
||||
menu[2],
|
||||
menu[3],
|
||||
menu[4],
|
||||
menu[5],
|
||||
menu[6],
|
||||
];
|
||||
return withCounterpartTab.filter((item) => {
|
||||
() =>
|
||||
menu.filter((item) => {
|
||||
if (item.path === '/appointments') {
|
||||
return canAccessAppointmentsSection(currentOrganization);
|
||||
}
|
||||
return canViewTab(currentOrganization, item.read);
|
||||
});
|
||||
},
|
||||
[counterpartLabel, organizationsTabIcon, currentOrganization],
|
||||
}),
|
||||
[currentOrganization, menu],
|
||||
);
|
||||
|
||||
return (
|
||||
<aside className="w-64 bg-background-secondary/90 border-r border-border text-text-primary flex flex-col">
|
||||
<div className="h-[71px] px-4 flex items-center">
|
||||
<h1 className="text-lg font-medium tracking-tight">DyoLink</h1>
|
||||
<h1 className="text-lg font-medium tracking-tight">{tCommon('appName')}</h1>
|
||||
</div>
|
||||
<div className="mx-4 border-b border-border/70" />
|
||||
|
||||
@@ -78,7 +69,7 @@ function Sidebar() {
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.name}
|
||||
key={item.path}
|
||||
href={item.path}
|
||||
prefetch
|
||||
className={`flex items-center gap-3 px-3 py-2.5 rounded-[var(--radius-sm)] border transition-colors ${
|
||||
@@ -97,4 +88,4 @@ function Sidebar() {
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(Sidebar);
|
||||
export default memo(Sidebar);
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { applyTheme, getStoredTheme, type ThemeMode } from '@/lib/theme';
|
||||
|
||||
export function ThemeToggle() {
|
||||
const t = useTranslations('theme');
|
||||
const [mode, setMode] = useState<ThemeMode | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -34,8 +36,8 @@ export function ThemeToggle() {
|
||||
type="button"
|
||||
onClick={handleClick}
|
||||
className="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-[var(--radius-md)] border border-border/60 bg-background-secondary/80 text-text-primary hover:border-border-strong hover:bg-background-card/80 transition-colors"
|
||||
aria-label={isDark ? 'Switch to light mode' : 'Switch to dark mode'}
|
||||
title={isDark ? 'Light mode' : 'Dark mode'}
|
||||
aria-label={isDark ? t('switchToLight') : t('switchToDark')}
|
||||
title={isDark ? t('lightMode') : t('darkMode')}
|
||||
>
|
||||
{isDark ? (
|
||||
<Sun className="h-[18px] w-[18px] icon-flat" />
|
||||
|
||||
13
frontend/src/components/ui/shared/TopBarControls.tsx
Normal file
13
frontend/src/components/ui/shared/TopBarControls.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { LanguageToggle } from '@/components/ui/shared/LanguageToggle';
|
||||
import { ThemeToggle } from '@/components/ui/shared/ThemeToggle';
|
||||
|
||||
export function TopBarControls({ className = '' }: { className?: string }) {
|
||||
return (
|
||||
<div className={`flex items-center gap-3 shrink-0 ${className}`.trim()}>
|
||||
<LanguageToggle />
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
5
frontend/src/i18n/navigation.ts
Normal file
5
frontend/src/i18n/navigation.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createNavigation } from 'next-intl/navigation';
|
||||
import { routing } from './routing';
|
||||
|
||||
export const { Link, redirect, usePathname, useRouter, getPathname } =
|
||||
createNavigation(routing);
|
||||
15
frontend/src/i18n/request.ts
Normal file
15
frontend/src/i18n/request.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { getRequestConfig } from 'next-intl/server';
|
||||
import { hasLocale } from 'next-intl';
|
||||
import { routing } from './routing';
|
||||
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
const requested = await requestLocale;
|
||||
const locale = hasLocale(routing.locales, requested)
|
||||
? requested
|
||||
: routing.defaultLocale;
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../../messages/${locale}.json`)).default,
|
||||
};
|
||||
});
|
||||
31
frontend/src/i18n/routing.ts
Normal file
31
frontend/src/i18n/routing.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { defineRouting } from 'next-intl/routing';
|
||||
|
||||
export const locales = ['en', 'fa', 'nl'] as const;
|
||||
export type AppLocale = (typeof locales)[number];
|
||||
|
||||
export const defaultLocale: AppLocale = 'en';
|
||||
|
||||
export const routing = defineRouting({
|
||||
locales,
|
||||
defaultLocale,
|
||||
localePrefix: 'always',
|
||||
});
|
||||
|
||||
export function localeHtmlLang(locale: string): string {
|
||||
if (locale === 'fa') return 'fa-IR';
|
||||
if (locale === 'nl') return 'nl';
|
||||
return 'en';
|
||||
}
|
||||
|
||||
export function isAppLocale(value: string): value is AppLocale {
|
||||
return locales.includes(value as AppLocale);
|
||||
}
|
||||
|
||||
export function stripLocaleFromPathname(pathname: string): string {
|
||||
const segments = pathname.split('/').filter(Boolean);
|
||||
if (segments.length > 0 && isAppLocale(segments[0])) {
|
||||
const rest = segments.slice(1).join('/');
|
||||
return rest ? `/${rest}` : '/';
|
||||
}
|
||||
return pathname || '/';
|
||||
}
|
||||
@@ -53,6 +53,13 @@ export const authApi = {
|
||||
await apiClient.post('/auth/logout');
|
||||
},
|
||||
|
||||
updateLanguage: async (
|
||||
language: string,
|
||||
): Promise<{ success: boolean; data: { user: { language: string } } }> => {
|
||||
const response = await apiClient.patch('/auth/profile/language', { language });
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Refresh token
|
||||
refreshToken: async (refreshToken: string): Promise<{ accessToken: string }> => {
|
||||
const response = await apiClient.post('/auth/refresh', { refreshToken });
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
'use client';
|
||||
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useRouter } from '@/i18n/navigation';
|
||||
import { authApi } from '@/lib/api/auth';
|
||||
import { User, Organization } from '@/types/organization';
|
||||
import { isAppLocale } from '@/i18n/routing';
|
||||
|
||||
interface AuthContextType {
|
||||
user: User | null;
|
||||
organizations: Organization[];
|
||||
currentOrganization: Organization | null;
|
||||
isLoading: boolean;
|
||||
isAuthReady: boolean; // ✅ NEW
|
||||
isAuthReady: boolean;
|
||||
error: string | null;
|
||||
registerTrial: (
|
||||
email: string,
|
||||
@@ -29,6 +30,7 @@ interface AuthContextType {
|
||||
organizationType: 'CLINIC' | 'LAB',
|
||||
planName?: string,
|
||||
) => Promise<string>;
|
||||
setUserLanguage: (language: string) => void;
|
||||
clearError: () => void;
|
||||
}
|
||||
|
||||
@@ -48,7 +50,13 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const organizations = payload?.organizations || [];
|
||||
|
||||
if (payload?.user) {
|
||||
return { user: payload.user as User, organizations };
|
||||
return {
|
||||
user: {
|
||||
...(payload.user as User),
|
||||
language: (payload.user as User).language ?? 'en',
|
||||
},
|
||||
organizations,
|
||||
};
|
||||
}
|
||||
|
||||
if (payload?.id && payload?.email && payload?.name) {
|
||||
@@ -57,6 +65,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
id: payload.id,
|
||||
email: payload.email,
|
||||
name: payload.name,
|
||||
language: payload.language ?? 'en',
|
||||
},
|
||||
organizations,
|
||||
};
|
||||
@@ -272,6 +281,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const clearError = useCallback(() => setError(null), []);
|
||||
|
||||
const setUserLanguage = useCallback((language: string) => {
|
||||
const normalized = isAppLocale(language) ? language : 'en';
|
||||
setUser((current) => (current ? { ...current, language: normalized } : current));
|
||||
}, []);
|
||||
|
||||
const contextValue = useMemo(
|
||||
() => ({
|
||||
user,
|
||||
@@ -285,6 +299,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
logout,
|
||||
selectOrganization,
|
||||
createOrganization,
|
||||
setUserLanguage,
|
||||
clearError,
|
||||
}),
|
||||
[
|
||||
@@ -299,6 +314,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
logout,
|
||||
selectOrganization,
|
||||
createOrganization,
|
||||
setUserLanguage,
|
||||
clearError,
|
||||
],
|
||||
);
|
||||
|
||||
8
frontend/src/middleware.ts
Normal file
8
frontend/src/middleware.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import createMiddleware from 'next-intl/middleware';
|
||||
import { routing } from './i18n/routing';
|
||||
|
||||
export default createMiddleware(routing);
|
||||
|
||||
export const config = {
|
||||
matcher: ['/', '/(en|fa|nl)/:path*'],
|
||||
};
|
||||
@@ -2,6 +2,7 @@ export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
export interface OrganizationPlan {
|
||||
|
||||
Reference in New Issue
Block a user