diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 8a5a028..a2b8d7e 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -59,8 +59,8 @@
"@types/eslint": "^9.6.1",
"@types/eslint__js": "9.14.0",
"@types/lodash": "4.17.16",
- "@types/react": "19.1.2",
- "@types/react-dom": "19.1.3",
+ "@types/react": "^19.1.2",
+ "@types/react-dom": "^19.1.3",
"@types/react-router": "5.1.20",
"@types/react-router-dom": "5.3.3",
"@types/uuid": "^10.0.0",
diff --git a/frontend/package.json b/frontend/package.json
index 1a54ae0..173e1f4 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -89,8 +89,8 @@
"@types/eslint": "^9.6.1",
"@types/eslint__js": "9.14.0",
"@types/lodash": "4.17.16",
- "@types/react": "19.1.2",
- "@types/react-dom": "19.1.3",
+ "@types/react": "^19.1.2",
+ "@types/react-dom": "^19.1.3",
"@types/react-router": "5.1.20",
"@types/react-router-dom": "5.3.3",
"@types/uuid": "^10.0.0",
diff --git a/frontend/src/common/api/useGetCurrentUser.ts b/frontend/src/common/api/useGetCurrentUser.ts
index ad5ce8a..47c3f3d 100644
--- a/frontend/src/common/api/useGetCurrentUser.ts
+++ b/frontend/src/common/api/useGetCurrentUser.ts
@@ -28,7 +28,7 @@ export const useGetCurrentUser = () => {
username: cognitoUser.username || '',
attributes: {
// Extract whatever attributes are available from the user object
- email: cognitoUser.signInDetails?.loginId || '',
+ email: cognitoUser.attributes.email || '',
},
};
diff --git a/frontend/src/common/hooks/__tests__/useAuthOperations.test.ts b/frontend/src/common/hooks/__tests__/useAuthOperations.test.ts
index 8a3d972..86917be 100644
--- a/frontend/src/common/hooks/__tests__/useAuthOperations.test.ts
+++ b/frontend/src/common/hooks/__tests__/useAuthOperations.test.ts
@@ -6,6 +6,11 @@ import * as AuthErrorUtils from 'common/utils/auth-errors';
import { AuthError, UserTokens } from 'common/models/auth';
import { CognitoUser } from 'common/models/user';
import * as UserMapper from 'common/utils/user-mapper';
+import {
+ ConfirmSignUpCommandOutput,
+ ResendConfirmationCodeCommandOutput,
+ SignUpCommandOutput,
+} from '@aws-sdk/client-cognito-identity-provider';
// Mock the DirectCognitoAuthService
vi.mock('common/services/auth/direct-cognito-auth-service', () => ({
@@ -110,12 +115,11 @@ describe('useAuthOperations', () => {
describe('signUp', () => {
it('should call DirectCognitoAuthService.signUp with correct parameters', async () => {
- const mockSignUpResult = {
- username: 'test@example.com',
- userConfirmed: false,
- isSignUpComplete: false,
- nextStep: { signUpStep: 'CONFIRM_SIGN_UP' },
- } as unknown;
+ const mockSignUpResult: SignUpCommandOutput = {
+ UserConfirmed: false,
+ UserSub: 'test-sub',
+ $metadata: {},
+ };
vi.mocked(DirectCognitoAuthService.signUp).mockResolvedValueOnce(mockSignUpResult);
@@ -174,10 +178,9 @@ describe('useAuthOperations', () => {
describe('confirmSignUp', () => {
it('should call DirectCognitoAuthService.confirmSignUp with correct parameters', async () => {
- const mockConfirmResult = {
- isSignUpComplete: true,
- nextStep: { signUpStep: 'DONE' },
- } as unknown;
+ const mockConfirmResult: ConfirmSignUpCommandOutput = {
+ $metadata: {},
+ };
vi.mocked(DirectCognitoAuthService.confirmSignUp).mockResolvedValueOnce(mockConfirmResult);
@@ -198,11 +201,14 @@ describe('useAuthOperations', () => {
describe('resendConfirmationCode', () => {
it('should call DirectCognitoAuthService.resendConfirmationCode with correct email', async () => {
- const mockResult = {
- deliveryMedium: 'EMAIL',
- destination: 'test@example.com',
- attributeName: 'email',
- } as unknown;
+ const mockResult: ResendConfirmationCodeCommandOutput = {
+ CodeDeliveryDetails: {
+ AttributeName: 'email',
+ DeliveryMedium: 'EMAIL',
+ Destination: 'test@example.com',
+ },
+ $metadata: {},
+ };
vi.mocked(DirectCognitoAuthService.resendConfirmationCode).mockResolvedValueOnce(mockResult);
@@ -231,7 +237,16 @@ describe('useAuthOperations', () => {
const mockUser = { id: 'mock-id', username: 'test@example.com', email: 'test@example.com' };
// First, we need to set up the user by simulating a successful sign-in
- vi.mocked(DirectCognitoAuthService.signIn).mockResolvedValueOnce({});
+ const mockTokens: UserTokens = {
+ access_token: 'token',
+ id_token: 'id-token',
+ refresh_token: 'refresh-token',
+ token_type: 'bearer',
+ expires_in: 3600,
+ expires_at: new Date().toISOString(),
+ };
+
+ vi.mocked(DirectCognitoAuthService.signIn).mockResolvedValueOnce(mockTokens);
vi.mocked(UserMapper.mapCognitoUserToAppUser).mockReturnValueOnce(mockUser as CognitoUser);
await act(async () => {
diff --git a/frontend/src/common/models/user.ts b/frontend/src/common/models/user.ts
index a2dacec..bc5b607 100644
--- a/frontend/src/common/models/user.ts
+++ b/frontend/src/common/models/user.ts
@@ -35,6 +35,14 @@ export type User = {
company: Company;
};
+/**
+ * Login details from Cognito
+ */
+export type SignInDetails = {
+ loginId?: string;
+ // Add any other properties that might be needed
+};
+
/**
* Cognito User type aligned with AWS Cognito attributes
*/
@@ -63,4 +71,6 @@ export type CognitoUser = {
createdAt?: string;
// Updated date
updatedAt?: string;
+ // Sign-in details (optional)
+ signInDetails?: SignInDetails;
};
diff --git a/frontend/src/common/providers/AuthProvider.tsx b/frontend/src/common/providers/AuthProvider.tsx
index afc1547..d8d891f 100644
--- a/frontend/src/common/providers/AuthProvider.tsx
+++ b/frontend/src/common/providers/AuthProvider.tsx
@@ -126,7 +126,7 @@ const AuthProvider = ({ children }: PropsWithChildren): JSX.Element => {
const userData = {
username: currentUser.username || '',
attributes: {
- email: currentUser.signInDetails?.loginId || '',
+ email: currentUser.attributes.email || '',
given_name: currentUser.username?.split('@')[0] || '',
family_name: '',
},
diff --git a/frontend/src/types/react.d.ts b/frontend/src/types/react.d.ts
new file mode 100644
index 0000000..fecc9bc
--- /dev/null
+++ b/frontend/src/types/react.d.ts
@@ -0,0 +1,12 @@
+///
+
+declare namespace JSX {
+ // Added a property to avoid the "interface declaring no members is equivalent to its supertype" error
+ interface Element
+ extends React.ReactElement, React.ElementType> {
+ _jsx_element?: true;
+ }
+ interface IntrinsicElements {
+ [elemName: string]: React.DetailedHTMLProps, HTMLElement>;
+ }
+}
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 5d6c84c..fb64999 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -15,7 +15,7 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
- "types": ["eslint"],
+ "types": ["eslint", "react", "react-dom"],
/* Absolute imports */
"paths": {