diff --git a/apps/backoffice/src/app/features/auth/pages/LoginPage.tsx b/apps/backoffice/src/app/features/auth/pages/LoginPage.tsx
index b4545349a..2ca197106 100644
--- a/apps/backoffice/src/app/features/auth/pages/LoginPage.tsx
+++ b/apps/backoffice/src/app/features/auth/pages/LoginPage.tsx
@@ -1,5 +1 @@
-import { LoginForm } from '../components/LoginForm';
-
-export function LoginPage() {
- return ;
-}
+export { Login as LoginPage } from '@tria-plc/iamui-common';
diff --git a/apps/backoffice/src/app/features/auth/pages/SetPasswordPage.tsx b/apps/backoffice/src/app/features/auth/pages/SetPasswordPage.tsx
index 41e311be9..d8143fe06 100644
--- a/apps/backoffice/src/app/features/auth/pages/SetPasswordPage.tsx
+++ b/apps/backoffice/src/app/features/auth/pages/SetPasswordPage.tsx
@@ -1,137 +1 @@
-import {
- Paper,
- TextInput,
- PasswordInput,
- Button,
- Stack,
- Title,
- Text,
-} from '@mantine/core';
-import { useForm } from 'react-hook-form';
-import { zodResolver } from '@hookform/resolvers/zod';
-import { z } from 'zod';
-import { useNavigate, useLocation } from 'react-router-dom';
-import { useAppDispatch, useAppSelector } from '../../../store/hooks';
-import {
- setPasswordStart,
- setPasswordSuccess,
- setPasswordFailure,
-} from '../store/set-password.slice';
-import { notify } from '@ema-platform/ui';
-
-const BASE_API_URL =
- (import.meta as { env?: Record }).env?.['VITE_BASE_API_URL'] ??
- 'http://localhost:3001/api';
-
-const schema = z
- .object({
- userId: z.string().min(1, 'User ID is required'),
- email: z.string().email('Enter a valid email'),
- verificationCode: z.string().min(1, 'Verification code is required'),
- newPassword: z.string().min(6, 'Password must be at least 6 characters'),
- confirmPassword: z.string().min(6, 'Confirm your password'),
- })
- .refine((data) => data.newPassword === data.confirmPassword, {
- message: 'Passwords do not match',
- path: ['confirmPassword'],
- });
-
-type FormValues = z.infer;
-
-export function SetPasswordPage() {
- const navigate = useNavigate();
- const dispatch = useAppDispatch();
- const location = useLocation();
- const { loading } = useAppSelector((s) => s.setPassword);
- const signupEmail = (location.state as { email?: string } | null)?.email ?? '';
-
- const {
- register,
- handleSubmit,
- formState: { errors },
- } = useForm({
- resolver: zodResolver(schema),
- defaultValues: { email: signupEmail },
- });
-
- const onSubmit = async (values: FormValues) => {
- dispatch(setPasswordStart());
- try {
- const res = await fetch(`${BASE_API_URL}/auth/set-password`, {
- method: 'PATCH',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- userId: values.userId,
- email: values.email,
- verificationCode: values.verificationCode,
- newPassword: values.newPassword,
- confirmPassword: values.confirmPassword,
- }),
- });
-
- if (!res.ok) {
- const errorData = await res.json().catch(() => null);
- throw new Error(errorData?.message ?? 'Failed to set password');
- }
-
- dispatch(setPasswordSuccess());
- notify.success('Password set successfully');
- navigate('/dashboard');
- } catch (err) {
- const msg = err instanceof Error ? err.message : 'Something went wrong';
- dispatch(setPasswordFailure(msg));
- notify.error(msg);
- }
- };
-
- return (
-
-
-
- Set your password
-
- A verification code has been sent to your email. Enter it below along
- with your new password to complete registration.
-
-
-
-
-
- );
-}
+export { SetPasswordPage } from '@tria-plc/iamui-common';
diff --git a/apps/backoffice/src/app/iam/IamProviders.tsx b/apps/backoffice/src/app/iam/IamProviders.tsx
index 2fd3ef6e0..2646c545a 100644
--- a/apps/backoffice/src/app/iam/IamProviders.tsx
+++ b/apps/backoffice/src/app/iam/IamProviders.tsx
@@ -29,3 +29,13 @@ export function IamProviders({ children }: IamProvidersProps) {
);
}
+
+export function AuthProviders({ children }: { children: ReactNode }) {
+ return (
+
+
+ {children}
+
+
+ );
+}
diff --git a/apps/backoffice/src/app/layouts/AuthLayout.tsx b/apps/backoffice/src/app/layouts/AuthLayout.tsx
index b058d16b7..2004d76b8 100644
--- a/apps/backoffice/src/app/layouts/AuthLayout.tsx
+++ b/apps/backoffice/src/app/layouts/AuthLayout.tsx
@@ -1,12 +1,5 @@
-import { Center, Box } from '@mantine/core';
import { Outlet } from 'react-router-dom';
export function AuthLayout() {
- return (
-
-
-
-
-
- );
+ return ;
}
diff --git a/apps/backoffice/src/app/layouts/components/AppHeader.tsx b/apps/backoffice/src/app/layouts/components/AppHeader.tsx
index fd61de307..f9ec47ee3 100644
--- a/apps/backoffice/src/app/layouts/components/AppHeader.tsx
+++ b/apps/backoffice/src/app/layouts/components/AppHeader.tsx
@@ -1,14 +1,14 @@
import { Group, Text, ActionIcon, Burger } from '@mantine/core';
import { IconLogout } from '@tabler/icons-react';
import { useNavigate } from 'react-router-dom';
-import { useAuth } from '../../features/auth/hooks/useAuth';
+import { useAuthUser } from '@tria-plc/iamui-common';
interface AppHeaderProps {
onToggle: () => void;
}
export function AppHeader({ onToggle }: AppHeaderProps) {
- const { logout } = useAuth();
+ const { logout } = useAuthUser();
const navigate = useNavigate();
const handleLogout = () => {
diff --git a/apps/backoffice/src/app/router/index.tsx b/apps/backoffice/src/app/router/index.tsx
index 35bbc46f4..b91446d3e 100644
--- a/apps/backoffice/src/app/router/index.tsx
+++ b/apps/backoffice/src/app/router/index.tsx
@@ -1,5 +1,7 @@
import { createBrowserRouter, RouterProvider, Navigate } from 'react-router-dom';
import {
+ Login,
+ SetPasswordPage,
UserManagementLayout,
UserManagementPage,
BulkUploadPage,
@@ -11,17 +13,18 @@ import {
import { ProtectedRoute } from './ProtectedRoute';
import { BackofficeLayout } from '../layouts/BackofficeLayout';
import { AuthLayout } from '../layouts/AuthLayout';
-import { LoginPage } from '../features/auth/pages/LoginPage';
-import { SignupPage } from '../features/auth/pages/SignupPage';
-import { SetPasswordPage } from '../features/auth/pages/SetPasswordPage';
import { DashboardPage } from '../features/dashboard/pages/DashboardPage';
import { ItemPage } from '../features/item/pages/ItemPage';
import { AuditLogPageWrapper } from '../iam/pages/AuditLogPage';
-import { IamProviders } from '../iam/IamProviders';
+import { IamProviders, AuthProviders } from '../iam/IamProviders';
const router = createBrowserRouter([
{
- element: ,
+ element: (
+
+
+
+ ),
children: [
{
element: ,
@@ -51,10 +54,13 @@ const router = createBrowserRouter([
],
},
{
- element: ,
+ element: (
+
+
+
+ ),
children: [
- { path: '/login', element: },
- { path: '/signup', element: },
+ { path: '/login', element: },
{ path: '/set-password', element: },
],
},