From f9f85c8c5996982cdff2c666cd51188690f27d9b Mon Sep 17 00:00:00 2001 From: JKaypa Date: Fri, 16 Aug 2024 11:47:53 -0500 Subject: [PATCH 01/70] OV-2: + add sign in string to AuthApiPath const --- shared/src/bundles/auth/enums/auth-api-path.enum.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/shared/src/bundles/auth/enums/auth-api-path.enum.ts b/shared/src/bundles/auth/enums/auth-api-path.enum.ts index 5833c6684..f64e5d59e 100644 --- a/shared/src/bundles/auth/enums/auth-api-path.enum.ts +++ b/shared/src/bundles/auth/enums/auth-api-path.enum.ts @@ -1,6 +1,7 @@ const AuthApiPath = { ROOT: '/', SIGN_UP: '/sign-up', + SIGN_IN: '/sign-in', } as const; export { AuthApiPath }; From 532a1197e11bf7cbe140bc7a55972680117014cd Mon Sep 17 00:00:00 2001 From: JKaypa Date: Fri, 16 Aug 2024 12:14:23 -0500 Subject: [PATCH 02/70] OV-2: + create user signin request dto type --- shared/src/bundles/users/types/types.ts | 1 + .../src/bundles/users/types/user-sign-in-request-dto.type.ts | 5 +++++ shared/src/bundles/users/users.ts | 1 + shared/src/index.ts | 1 + 4 files changed, 8 insertions(+) create mode 100644 shared/src/bundles/users/types/user-sign-in-request-dto.type.ts diff --git a/shared/src/bundles/users/types/types.ts b/shared/src/bundles/users/types/types.ts index 7564f70b2..f6fd8caa2 100644 --- a/shared/src/bundles/users/types/types.ts +++ b/shared/src/bundles/users/types/types.ts @@ -1,4 +1,5 @@ export { type UserGetAllItemResponseDto } from './user-get-all-item-response-dto.type.js'; export { type UserGetAllResponseDto } from './user-get-all-response-dto.type.js'; +export { type UserSignInRequestDto } from './user-sign-in-request-dto.type.js'; export { type UserSignUpRequestDto } from './user-sign-up-request-dto.type.js'; export { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; diff --git a/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts b/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts new file mode 100644 index 000000000..6d445fe1e --- /dev/null +++ b/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts @@ -0,0 +1,5 @@ +import { type UserSignUpRequestDto } from './types.js'; + +type UserSignInRequestDto = Pick; + +export { type UserSignInRequestDto }; diff --git a/shared/src/bundles/users/users.ts b/shared/src/bundles/users/users.ts index e65858985..f51c03f83 100644 --- a/shared/src/bundles/users/users.ts +++ b/shared/src/bundles/users/users.ts @@ -2,6 +2,7 @@ export { UsersApiPath, UserValidationMessage } from './enums/enums.js'; export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; diff --git a/shared/src/index.ts b/shared/src/index.ts index df887038b..62e27af88 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -2,6 +2,7 @@ export { AuthApiPath } from './bundles/auth/auth.js'; export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, UsersApiPath, From 8e9d770ef08fb351ec73878fdf5d4c52d381cf12 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sat, 17 Aug 2024 18:20:00 -0500 Subject: [PATCH 03/70] OV-2: + create user signin response dto type --- shared/src/bundles/users/types/types.ts | 1 + .../bundles/users/types/user-sign-in-response-dto.type.ts | 5 +++++ shared/src/bundles/users/users.ts | 1 + shared/src/index.ts | 1 + 4 files changed, 8 insertions(+) create mode 100644 shared/src/bundles/users/types/user-sign-in-response-dto.type.ts diff --git a/shared/src/bundles/users/types/types.ts b/shared/src/bundles/users/types/types.ts index f6fd8caa2..36cfa4fdb 100644 --- a/shared/src/bundles/users/types/types.ts +++ b/shared/src/bundles/users/types/types.ts @@ -1,5 +1,6 @@ export { type UserGetAllItemResponseDto } from './user-get-all-item-response-dto.type.js'; export { type UserGetAllResponseDto } from './user-get-all-response-dto.type.js'; export { type UserSignInRequestDto } from './user-sign-in-request-dto.type.js'; +export { type UserSignInResponseDto } from './user-sign-in-response-dto.type.js'; export { type UserSignUpRequestDto } from './user-sign-up-request-dto.type.js'; export { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; diff --git a/shared/src/bundles/users/types/user-sign-in-response-dto.type.ts b/shared/src/bundles/users/types/user-sign-in-response-dto.type.ts new file mode 100644 index 000000000..61be88ee0 --- /dev/null +++ b/shared/src/bundles/users/types/user-sign-in-response-dto.type.ts @@ -0,0 +1,5 @@ +import { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; + +type UserSignInResponseDto = UserSignUpResponseDto; + +export { type UserSignInResponseDto }; diff --git a/shared/src/bundles/users/users.ts b/shared/src/bundles/users/users.ts index f51c03f83..502faa91f 100644 --- a/shared/src/bundles/users/users.ts +++ b/shared/src/bundles/users/users.ts @@ -3,6 +3,7 @@ export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, type UserSignInRequestDto, + type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; diff --git a/shared/src/index.ts b/shared/src/index.ts index 62e27af88..3a0064087 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -3,6 +3,7 @@ export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, type UserSignInRequestDto, + type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, UsersApiPath, From 55df57e698a9bb8004f73bcfd0b4d04917b43a03 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 15:53:44 -0500 Subject: [PATCH 04/70] OV-2: + add 400 error code --- shared/src/framework/http/enums/http-code.enum.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/shared/src/framework/http/enums/http-code.enum.ts b/shared/src/framework/http/enums/http-code.enum.ts index 59a238f46..6d2ad89ba 100644 --- a/shared/src/framework/http/enums/http-code.enum.ts +++ b/shared/src/framework/http/enums/http-code.enum.ts @@ -1,6 +1,7 @@ const HttpCode = { OK: 200, CREATED: 201, + BAD_REQUEST: 400, UNPROCESSED_ENTITY: 422, INTERNAL_SERVER_ERROR: 500, } as const; From 6df4a10e6f3f7a51b168c4a00d10b0c6bb82e499 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 15:55:39 -0500 Subject: [PATCH 05/70] OV-2: * edit props order --- shared/src/bundles/auth/enums/auth-api-path.enum.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/bundles/auth/enums/auth-api-path.enum.ts b/shared/src/bundles/auth/enums/auth-api-path.enum.ts index f64e5d59e..79d9340e1 100644 --- a/shared/src/bundles/auth/enums/auth-api-path.enum.ts +++ b/shared/src/bundles/auth/enums/auth-api-path.enum.ts @@ -1,7 +1,7 @@ const AuthApiPath = { ROOT: '/', - SIGN_UP: '/sign-up', SIGN_IN: '/sign-in', + SIGN_UP: '/sign-up', } as const; export { AuthApiPath }; From 782952a70ec31f109651c10ca62496b3d87b444b Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 15:57:15 -0500 Subject: [PATCH 06/70] OV-2: + add validation message --- shared/src/bundles/users/enums/user-validation-message.enum.ts | 1 + shared/src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/shared/src/bundles/users/enums/user-validation-message.enum.ts b/shared/src/bundles/users/enums/user-validation-message.enum.ts index b28063d96..bba0dc6b7 100644 --- a/shared/src/bundles/users/enums/user-validation-message.enum.ts +++ b/shared/src/bundles/users/enums/user-validation-message.enum.ts @@ -1,6 +1,7 @@ const UserValidationMessage = { EMAIL_REQUIRE: 'Email is required', EMAIL_WRONG: 'Email is wrong', + WRONG_CREDENTIALS: 'Email or password are incorrect', } as const; export { UserValidationMessage }; diff --git a/shared/src/index.ts b/shared/src/index.ts index 3a0064087..33089cc13 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -8,6 +8,7 @@ export { type UserSignUpResponseDto, UsersApiPath, userSignUpValidationSchema, + UserValidationMessage, } from './bundles/users/users.js'; export { ApiPath, From 830ec5a097f973a5c5a5625bf365e89289a933c8 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:00:09 -0500 Subject: [PATCH 07/70] OV-2: * edit service, repository find method type --- backend/src/common/types/repository.type.ts | 2 +- backend/src/common/types/service.type.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/common/types/repository.type.ts b/backend/src/common/types/repository.type.ts index d69be849b..21b21ed88 100644 --- a/backend/src/common/types/repository.type.ts +++ b/backend/src/common/types/repository.type.ts @@ -1,5 +1,5 @@ type Repository = { - find(): Promise; + find(payload: string | number): Promise; findAll(): Promise; create(payload: unknown): Promise; update(): Promise; diff --git a/backend/src/common/types/service.type.ts b/backend/src/common/types/service.type.ts index 7b1a64ebb..31d498842 100644 --- a/backend/src/common/types/service.type.ts +++ b/backend/src/common/types/service.type.ts @@ -1,5 +1,5 @@ type Service = { - find(): Promise; + find(payload: string | number): Promise; findAll(): Promise<{ items: T[]; }>; From f07f147547fbc815826e33aa086994ec13f88e21 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:02:10 -0500 Subject: [PATCH 08/70] OV-2: * update repository find method --- backend/src/bundles/users/user.repository.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/bundles/users/user.repository.ts b/backend/src/bundles/users/user.repository.ts index be08919a1..9bbd2d3a9 100644 --- a/backend/src/bundles/users/user.repository.ts +++ b/backend/src/bundles/users/user.repository.ts @@ -9,8 +9,13 @@ class UserRepository implements Repository { this.userModel = userModel; } - public find(): ReturnType { - return Promise.resolve(null); + public async find(payload: string | number): Promise { + const user = await this.userModel + .query() + .findOne({ payload }) + .execute(); + + return user ? UserEntity.initialize(user) : null; } public async findAll(): Promise { From 1f7ec608907ee1f6e86503322ad25268f9d2261c Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:03:15 -0500 Subject: [PATCH 09/70] OV-2: * update service find method --- backend/src/bundles/users/user.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/bundles/users/user.service.ts b/backend/src/bundles/users/user.service.ts index 1616231f0..00c796c2e 100644 --- a/backend/src/bundles/users/user.service.ts +++ b/backend/src/bundles/users/user.service.ts @@ -16,8 +16,8 @@ class UserService implements Service { this.userRepository = userRepository; } - public find(): ReturnType { - return Promise.resolve(null); + public async find(payload: string | number): Promise { + return await this.userRepository.find(payload); } public async findAll(): Promise { From 483f1c87033dc47188da67ea1d429a9bca4e9a7f Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:04:29 -0500 Subject: [PATCH 10/70] OV-2: + implement sign in service method --- backend/src/bundles/auth/auth.service.ts | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/backend/src/bundles/auth/auth.service.ts b/backend/src/bundles/auth/auth.service.ts index 5ae168e63..3ae63790d 100644 --- a/backend/src/bundles/auth/auth.service.ts +++ b/backend/src/bundles/auth/auth.service.ts @@ -1,8 +1,14 @@ import { + type UserSignInRequestDto, + type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from '~/bundles/users/types/types.js'; import { type UserService } from '~/bundles/users/user.service.js'; +import { HttpCode, HttpError } from '~/common/http/http.js'; +import { cryptService } from '~/common/services/services.js'; + +import { UserValidationMessage } from './enums/enums.js'; class AuthService { private userService: UserService; @@ -11,6 +17,36 @@ class AuthService { this.userService = userService; } + public async signIn( + userRequestDto: UserSignInRequestDto, + ): Promise { + const { email, password } = userRequestDto; + const user = await this.userService.find(email); + + if (!user) { + throw new HttpError({ + message: UserValidationMessage.WRONG_CREDENTIALS, + status: HttpCode.BAD_REQUEST, + }); + } + + const { passwordHash } = user.toNewObject(); + + const isPwdCorrect = cryptService.compareSyncPassword( + password, + passwordHash, + ); + + if (!isPwdCorrect) { + throw new HttpError({ + message: UserValidationMessage.WRONG_CREDENTIALS, + status: HttpCode.BAD_REQUEST, + }); + } + + return user.toObject(); + } + public signUp( userRequestDto: UserSignUpRequestDto, ): Promise { From 4c449b62f23ec7d18ab2ff5f40928a4a4b21ec67 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:06:14 -0500 Subject: [PATCH 11/70] OV-2: + add sign in endpoint to auth controller --- backend/src/bundles/auth/auth.controller.ts | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/src/bundles/auth/auth.controller.ts b/backend/src/bundles/auth/auth.controller.ts index 7a64ed90f..bc650db0c 100644 --- a/backend/src/bundles/auth/auth.controller.ts +++ b/backend/src/bundles/auth/auth.controller.ts @@ -1,4 +1,7 @@ -import { type UserSignUpRequestDto } from '~/bundles/users/users.js'; +import { + type UserSignInRequestDto, + type UserSignUpRequestDto, +} from '~/bundles/users/users.js'; import { userSignUpValidationSchema } from '~/bundles/users/users.js'; import { type ApiHandlerOptions, @@ -20,6 +23,20 @@ class AuthController extends BaseController { this.authService = authService; + this.addRoute({ + path: AuthApiPath.SIGN_IN, + method: 'POST', + validation: { + body: userSignUpValidationSchema, + }, + handler: (options) => + this.signIn( + options as ApiHandlerOptions<{ + body: UserSignInRequestDto; + }>, + ), + }); + this.addRoute({ path: AuthApiPath.SIGN_UP, method: 'POST', @@ -65,6 +82,17 @@ class AuthController extends BaseController { * type: object * $ref: '#/components/schemas/User' */ + private async signIn( + options: ApiHandlerOptions<{ + body: UserSignInRequestDto; + }>, + ): Promise { + return { + payload: await this.authService.signIn(options.body), + status: HttpCode.OK, + }; + } + private async signUp( options: ApiHandlerOptions<{ body: UserSignUpRequestDto; From c32e1fa25d1676e01fc542f4284fb9749f49820d Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:07:39 -0500 Subject: [PATCH 12/70] OV-2: + import user validation messages --- backend/src/bundles/auth/enums/enums.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/bundles/auth/enums/enums.ts b/backend/src/bundles/auth/enums/enums.ts index 7cbd1669d..e208cd7f4 100644 --- a/backend/src/bundles/auth/enums/enums.ts +++ b/backend/src/bundles/auth/enums/enums.ts @@ -1 +1 @@ -export { AuthApiPath } from 'shared'; +export { AuthApiPath, UserValidationMessage } from 'shared'; From 1beb23aa7b49aae41b8e826104fa13087027af27 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Sun, 18 Aug 2024 16:09:59 -0500 Subject: [PATCH 13/70] OV-2: + import sign in dto types --- backend/src/bundles/users/types/types.ts | 2 ++ backend/src/bundles/users/users.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/backend/src/bundles/users/types/types.ts b/backend/src/bundles/users/types/types.ts index f44313789..6a3620c41 100644 --- a/backend/src/bundles/users/types/types.ts +++ b/backend/src/bundles/users/types/types.ts @@ -1,5 +1,7 @@ export { type UserGetAllResponseDto, + type UserSignInRequestDto, + type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from 'shared'; diff --git a/backend/src/bundles/users/users.ts b/backend/src/bundles/users/users.ts index 1ad8ad701..93afaa708 100644 --- a/backend/src/bundles/users/users.ts +++ b/backend/src/bundles/users/users.ts @@ -11,6 +11,8 @@ const userController = new UserController(logger, userService); export { userController, userService }; export { + type UserSignInRequestDto, + type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; From 913919756bf3190645388333338d4dacff258c7c Mon Sep 17 00:00:00 2001 From: JKaypa Date: Mon, 19 Aug 2024 10:01:33 -0500 Subject: [PATCH 14/70] OV-2: + implement validation --- backend/src/bundles/auth/auth.controller.ts | 7 ++-- backend/src/bundles/users/users.ts | 5 ++- .../validation-schemas/validation-schemas.ts | 2 +- .../enums/user-validation-message.enum.ts | 4 +++ .../users/enums/user-validation-rule.enum.ts | 5 ++- shared/src/bundles/users/users.ts | 5 ++- .../user-sig-in.validation-schema.ts | 36 +++++++++++++++++++ .../validation-schemas/validation-schemas.ts | 1 + shared/src/index.ts | 1 + 9 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 shared/src/bundles/users/validation-schemas/user-sig-in.validation-schema.ts diff --git a/backend/src/bundles/auth/auth.controller.ts b/backend/src/bundles/auth/auth.controller.ts index bc650db0c..462bb967d 100644 --- a/backend/src/bundles/auth/auth.controller.ts +++ b/backend/src/bundles/auth/auth.controller.ts @@ -2,7 +2,10 @@ import { type UserSignInRequestDto, type UserSignUpRequestDto, } from '~/bundles/users/users.js'; -import { userSignUpValidationSchema } from '~/bundles/users/users.js'; +import { + userSignInValidationSchema, + userSignUpValidationSchema, +} from '~/bundles/users/users.js'; import { type ApiHandlerOptions, type ApiHandlerResponse, @@ -27,7 +30,7 @@ class AuthController extends BaseController { path: AuthApiPath.SIGN_IN, method: 'POST', validation: { - body: userSignUpValidationSchema, + body: userSignInValidationSchema, }, handler: (options) => this.signIn( diff --git a/backend/src/bundles/users/users.ts b/backend/src/bundles/users/users.ts index 93afaa708..73f640e85 100644 --- a/backend/src/bundles/users/users.ts +++ b/backend/src/bundles/users/users.ts @@ -17,4 +17,7 @@ export { type UserSignUpResponseDto, } from './types/types.js'; export { UserModel } from './user.model.js'; -export { userSignUpValidationSchema } from './validation-schemas/validation-schemas.js'; +export { + userSignInValidationSchema, + userSignUpValidationSchema, +} from './validation-schemas/validation-schemas.js'; diff --git a/backend/src/bundles/users/validation-schemas/validation-schemas.ts b/backend/src/bundles/users/validation-schemas/validation-schemas.ts index 7bc9a09c5..5952fe0cf 100644 --- a/backend/src/bundles/users/validation-schemas/validation-schemas.ts +++ b/backend/src/bundles/users/validation-schemas/validation-schemas.ts @@ -1 +1 @@ -export { userSignUpValidationSchema } from 'shared'; +export { userSignInValidationSchema, userSignUpValidationSchema } from 'shared'; diff --git a/shared/src/bundles/users/enums/user-validation-message.enum.ts b/shared/src/bundles/users/enums/user-validation-message.enum.ts index bba0dc6b7..1a168422a 100644 --- a/shared/src/bundles/users/enums/user-validation-message.enum.ts +++ b/shared/src/bundles/users/enums/user-validation-message.enum.ts @@ -1,6 +1,10 @@ const UserValidationMessage = { EMAIL_REQUIRE: 'Email is required', EMAIL_WRONG: 'Email is wrong', + EMAIL_INVALID: 'Please enter a valid email', + FIELD_REQUIRE: 'Please fill out this field', + PASSWORD_LENGTH: 'Password must have from 6 to 12 characters', + INVALID_DATA: 'Incorrect email or password. Please try again.', WRONG_CREDENTIALS: 'Email or password are incorrect', } as const; diff --git a/shared/src/bundles/users/enums/user-validation-rule.enum.ts b/shared/src/bundles/users/enums/user-validation-rule.enum.ts index 36ca9c2e2..eb7d606aa 100644 --- a/shared/src/bundles/users/enums/user-validation-rule.enum.ts +++ b/shared/src/bundles/users/enums/user-validation-rule.enum.ts @@ -1,5 +1,8 @@ const UserValidationRule = { - EMAIL_MINIMUM_LENGTH: 1, + EMAIL_MINIMUM_LENGTH: 6, + EMAIL_MAXIMUM_LENGTH: 320, + PASSWORD_MINIMUM_LENGTH: 6, + PASSWORD_MAXIMUM_LENGTH: 12, } as const; export { UserValidationRule }; diff --git a/shared/src/bundles/users/users.ts b/shared/src/bundles/users/users.ts index 502faa91f..5a2147adc 100644 --- a/shared/src/bundles/users/users.ts +++ b/shared/src/bundles/users/users.ts @@ -7,4 +7,7 @@ export { type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; -export { userSignUp as userSignUpValidationSchema } from './validation-schemas/validation-schemas.js'; +export { + userSignIn as userSignInValidationSchema, + userSignUp as userSignUpValidationSchema, +} from './validation-schemas/validation-schemas.js'; diff --git a/shared/src/bundles/users/validation-schemas/user-sig-in.validation-schema.ts b/shared/src/bundles/users/validation-schemas/user-sig-in.validation-schema.ts new file mode 100644 index 000000000..100cb3dad --- /dev/null +++ b/shared/src/bundles/users/validation-schemas/user-sig-in.validation-schema.ts @@ -0,0 +1,36 @@ +import { z } from 'zod'; + +import { UserValidationMessage, UserValidationRule } from '../enums/enums.js'; + +type UserSignInRequestValidationDto = { + email: z.ZodString; + password: z.ZodString; +}; + +const userSignIn = z + .object({ + email: z + .string({ required_error: UserValidationMessage.FIELD_REQUIRE }) + .trim() + .min(UserValidationRule.EMAIL_MINIMUM_LENGTH, { + message: UserValidationMessage.EMAIL_INVALID, + }) + .max(UserValidationRule.EMAIL_MAXIMUM_LENGTH, { + message: UserValidationMessage.EMAIL_INVALID, + }) + .email({ + message: UserValidationMessage.EMAIL_INVALID, + }), + password: z + .string({ required_error: UserValidationMessage.FIELD_REQUIRE }) + .trim() + .min(UserValidationRule.PASSWORD_MINIMUM_LENGTH, { + message: UserValidationMessage.PASSWORD_LENGTH, + }) + .max(UserValidationRule.PASSWORD_MAXIMUM_LENGTH, { + message: UserValidationMessage.PASSWORD_LENGTH, + }), + }) + .required(); + +export { userSignIn }; diff --git a/shared/src/bundles/users/validation-schemas/validation-schemas.ts b/shared/src/bundles/users/validation-schemas/validation-schemas.ts index cb1c2ad60..58cd817cf 100644 --- a/shared/src/bundles/users/validation-schemas/validation-schemas.ts +++ b/shared/src/bundles/users/validation-schemas/validation-schemas.ts @@ -1 +1,2 @@ +export { userSignIn } from './user-sig-in.validation-schema.js'; export { userSignUp } from './user-sign-up.validation-schema.js'; diff --git a/shared/src/index.ts b/shared/src/index.ts index 33089cc13..d4b77ee0e 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -7,6 +7,7 @@ export { type UserSignUpRequestDto, type UserSignUpResponseDto, UsersApiPath, + userSignInValidationSchema, userSignUpValidationSchema, UserValidationMessage, } from './bundles/users/users.js'; From 375fde5c72372e002b69822022bde34b3089945d Mon Sep 17 00:00:00 2001 From: JKaypa Date: Mon, 19 Aug 2024 10:53:24 -0500 Subject: [PATCH 15/70] OV-2: * update imports from users/users --- backend/src/bundles/auth/auth.controller.ts | 4 +--- backend/src/bundles/auth/auth.service.ts | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/bundles/auth/auth.controller.ts b/backend/src/bundles/auth/auth.controller.ts index 462bb967d..148002532 100644 --- a/backend/src/bundles/auth/auth.controller.ts +++ b/backend/src/bundles/auth/auth.controller.ts @@ -1,11 +1,9 @@ import { type UserSignInRequestDto, type UserSignUpRequestDto, -} from '~/bundles/users/users.js'; -import { userSignInValidationSchema, - userSignUpValidationSchema, } from '~/bundles/users/users.js'; +import { userSignUpValidationSchema } from '~/bundles/users/users.js'; import { type ApiHandlerOptions, type ApiHandlerResponse, diff --git a/backend/src/bundles/auth/auth.service.ts b/backend/src/bundles/auth/auth.service.ts index 3ae63790d..c7a34fc24 100644 --- a/backend/src/bundles/auth/auth.service.ts +++ b/backend/src/bundles/auth/auth.service.ts @@ -1,10 +1,12 @@ import { - type UserSignInRequestDto, - type UserSignInResponseDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from '~/bundles/users/types/types.js'; import { type UserService } from '~/bundles/users/user.service.js'; +import { + type UserSignInRequestDto, + type UserSignInResponseDto, +} from '~/bundles/users/users.js'; import { HttpCode, HttpError } from '~/common/http/http.js'; import { cryptService } from '~/common/services/services.js'; From 333c400ff561229d2d18b9e2389824a5c02e83c2 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Mon, 19 Aug 2024 21:33:34 +0300 Subject: [PATCH 16/70] OV-11: * colors --- frontend/src/framework/theme/styles/colors.styles.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/framework/theme/styles/colors.styles.ts b/frontend/src/framework/theme/styles/colors.styles.ts index 75c91a9c5..c207ae8ac 100644 --- a/frontend/src/framework/theme/styles/colors.styles.ts +++ b/frontend/src/framework/theme/styles/colors.styles.ts @@ -3,6 +3,12 @@ const colors = { 900: '#1a365d', 200: '#b3e0ff', }, + background: { + 900: '#0a0049', + 600: '#35399a', + 300: '#3c9cf5', + 50: '#e2e1ec', + }, text: { default: '#36454f', accent: '#ff5733', From 4bcf5ab3ca0395ad3e34edc2082ad557d8046813 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Mon, 19 Aug 2024 21:34:23 +0300 Subject: [PATCH 17/70] OV-11: + header component --- .../common/components/header/header.tsx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 frontend/src/bundles/common/components/header/header.tsx diff --git a/frontend/src/bundles/common/components/header/header.tsx b/frontend/src/bundles/common/components/header/header.tsx new file mode 100644 index 000000000..96dd5229a --- /dev/null +++ b/frontend/src/bundles/common/components/header/header.tsx @@ -0,0 +1,33 @@ +import { Flex, Text } from '@chakra-ui/react'; + +const Header = (): JSX.Element => { + return ( + + + + Logo + + + + ); +}; + +export { Header }; From af83d0eff837bbc937bc536177580a7757169414 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Mon, 19 Aug 2024 21:36:01 +0300 Subject: [PATCH 18/70] OV-11: + header into app --- frontend/src/app/app.tsx | 7 ++++++- frontend/src/bundles/common/components/components.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/app.tsx b/frontend/src/app/app.tsx index e1f671b35..f7420ca51 100644 --- a/frontend/src/app/app.tsx +++ b/frontend/src/app/app.tsx @@ -1,5 +1,9 @@ import reactLogo from '~/assets/img/react.svg'; -import { Link, RouterOutlet } from '~/bundles/common/components/components.js'; +import { + Header, + Link, + RouterOutlet, +} from '~/bundles/common/components/components.js'; import { AppRoute } from '~/bundles/common/enums/enums.js'; import { useAppDispatch, @@ -27,6 +31,7 @@ const App: React.FC = () => { return ( <> +
logo
    diff --git a/frontend/src/bundles/common/components/components.ts b/frontend/src/bundles/common/components/components.ts index ce95bfe64..9f899df94 100644 --- a/frontend/src/bundles/common/components/components.ts +++ b/frontend/src/bundles/common/components/components.ts @@ -1,4 +1,5 @@ export { Button } from './button/button.js'; +export { Header } from './header/header.js'; export { Input } from './input/input.js'; export { Link } from './link/link.js'; export { RouterProvider } from './router-provider/router-provider.js'; From d5f4f15a90cb2cf08619ec19a69f4032787c72f3 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Mon, 19 Aug 2024 15:30:14 -0500 Subject: [PATCH 19/70] OV-2: * edit findByEmail methods --- backend/src/bundles/auth/auth.service.ts | 2 +- backend/src/bundles/users/user.repository.ts | 11 ++++++----- backend/src/bundles/users/user.service.ts | 8 ++++++-- backend/src/common/types/repository.type.ts | 3 ++- backend/src/common/types/service.type.ts | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/bundles/auth/auth.service.ts b/backend/src/bundles/auth/auth.service.ts index c7a34fc24..fabf0d934 100644 --- a/backend/src/bundles/auth/auth.service.ts +++ b/backend/src/bundles/auth/auth.service.ts @@ -23,7 +23,7 @@ class AuthService { userRequestDto: UserSignInRequestDto, ): Promise { const { email, password } = userRequestDto; - const user = await this.userService.find(email); + const user = await this.userService.findByEmail(email); if (!user) { throw new HttpError({ diff --git a/backend/src/bundles/users/user.repository.ts b/backend/src/bundles/users/user.repository.ts index 9bbd2d3a9..b4d6110d8 100644 --- a/backend/src/bundles/users/user.repository.ts +++ b/backend/src/bundles/users/user.repository.ts @@ -9,11 +9,12 @@ class UserRepository implements Repository { this.userModel = userModel; } - public async find(payload: string | number): Promise { - const user = await this.userModel - .query() - .findOne({ payload }) - .execute(); + public find(): ReturnType { + return Promise.resolve(null); + } + + public async findByEmail(email: string): Promise { + const user = await this.userModel.query().findOne({ email }).execute(); return user ? UserEntity.initialize(user) : null; } diff --git a/backend/src/bundles/users/user.service.ts b/backend/src/bundles/users/user.service.ts index 00c796c2e..778c8f95f 100644 --- a/backend/src/bundles/users/user.service.ts +++ b/backend/src/bundles/users/user.service.ts @@ -16,8 +16,12 @@ class UserService implements Service { this.userRepository = userRepository; } - public async find(payload: string | number): Promise { - return await this.userRepository.find(payload); + public find(): ReturnType { + return Promise.resolve(null); + } + + public async findByEmail(email: string): Promise { + return await this.userRepository.findByEmail(email); } public async findAll(): Promise { diff --git a/backend/src/common/types/repository.type.ts b/backend/src/common/types/repository.type.ts index 21b21ed88..4008a9251 100644 --- a/backend/src/common/types/repository.type.ts +++ b/backend/src/common/types/repository.type.ts @@ -1,6 +1,7 @@ type Repository = { - find(payload: string | number): Promise; + find(): Promise; findAll(): Promise; + findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; delete(): Promise; diff --git a/backend/src/common/types/service.type.ts b/backend/src/common/types/service.type.ts index 31d498842..245943234 100644 --- a/backend/src/common/types/service.type.ts +++ b/backend/src/common/types/service.type.ts @@ -1,8 +1,9 @@ type Service = { - find(payload: string | number): Promise; + find(): Promise; findAll(): Promise<{ items: T[]; }>; + findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; delete(): Promise; From 89bd1459e02966236595baa3da5e7a6b03eee7d8 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 10:41:25 +0300 Subject: [PATCH 20/70] OV-11: * header component --- frontend/src/bundles/common/components/header/header.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/bundles/common/components/header/header.tsx b/frontend/src/bundles/common/components/header/header.tsx index 96dd5229a..2a0322074 100644 --- a/frontend/src/bundles/common/components/header/header.tsx +++ b/frontend/src/bundles/common/components/header/header.tsx @@ -20,9 +20,9 @@ const Header = (): JSX.Element => { width="full" alignItems="center" maxWidth="1440px" - margin="0 auto" + justifyContent="space-between" > - + Logo From af7193f72d73fb3410eeeb27435cfae1dee1c266 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 11:52:05 +0300 Subject: [PATCH 21/70] OV-18: + Modal component --- .../bundles/common/components/components.ts | 1 + .../bundles/common/components/modal/modal.tsx | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 frontend/src/bundles/common/components/modal/modal.tsx diff --git a/frontend/src/bundles/common/components/components.ts b/frontend/src/bundles/common/components/components.ts index ce95bfe64..f25a0cb03 100644 --- a/frontend/src/bundles/common/components/components.ts +++ b/frontend/src/bundles/common/components/components.ts @@ -1,6 +1,7 @@ export { Button } from './button/button.js'; export { Input } from './input/input.js'; export { Link } from './link/link.js'; +export { Modal } from './modal/modal.js'; export { RouterProvider } from './router-provider/router-provider.js'; export { Box, diff --git a/frontend/src/bundles/common/components/modal/modal.tsx b/frontend/src/bundles/common/components/modal/modal.tsx new file mode 100644 index 000000000..e10682e5d --- /dev/null +++ b/frontend/src/bundles/common/components/modal/modal.tsx @@ -0,0 +1,36 @@ +import { + Modal as ChakraModal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalHeader, + ModalOverlay, +} from '@chakra-ui/react'; +import { type ReactNode } from 'react'; + +type Properties = { + isOpen: boolean; + closeModal: () => void; + title?: string; + children: ReactNode; +}; + +const Modal = ({ + isOpen, + closeModal, + title, + children, +}: Properties): JSX.Element => { + return ( + + + + {title} + + {children} + + + ); +}; + +export { Modal }; From 2faab74eadf7ae442224089171ea459a403a3c71 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 14:36:53 +0300 Subject: [PATCH 22/70] OV-18: + Tab component --- .../libs/components/tab/tab.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/tab/tab.tsx diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/tab/tab.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/tab/tab.tsx new file mode 100644 index 000000000..5853e7885 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/tab/tab.tsx @@ -0,0 +1,15 @@ +import { Tab as ChakraTab } from '@chakra-ui/react'; + +type Properties = { + label: string; +}; + +const Tab = ({ label }: Properties): JSX.Element => { + return ( + + {label} + + ); +}; + +export { Tab }; From d2340b62c4998546619fddcfdb42c6caeecd32c3 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 14:38:45 +0300 Subject: [PATCH 23/70] OV-18: + VideoModalSideBar component --- .../libs/components/components.ts | 1 + .../video-modal-side-bar.tsx | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts new file mode 100644 index 000000000..e5eeec838 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts @@ -0,0 +1 @@ +export { Tab } from './tab/tab.js'; diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx new file mode 100644 index 000000000..3948c46f6 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx @@ -0,0 +1,34 @@ +import { TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/react'; + +import { Tab } from './libs/components/components.js'; + +const VideoModalSideBar = (): JSX.Element => { + return ( + + + + + + + + +

    one!

    +
    + +

    two!

    +
    + +

    three!

    +
    +
    +
    + ); +}; + +export { VideoModalSideBar }; From fe050edba8c9f8c9d45b80eda562d10276f6113b Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 14:39:42 +0300 Subject: [PATCH 24/70] OV-18: + VideoModal component --- .../components/video-modal/libs/components/components.ts | 1 + .../bundles/common/components/video-modal/video-modal.tsx | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/components.ts create mode 100644 frontend/src/bundles/common/components/video-modal/video-modal.tsx diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/components.ts b/frontend/src/bundles/common/components/video-modal/libs/components/components.ts new file mode 100644 index 000000000..5f623fe39 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/components.ts @@ -0,0 +1 @@ +export { VideoModalSideBar } from './video-modal-side-bar/video-modal-side-bar.js'; diff --git a/frontend/src/bundles/common/components/video-modal/video-modal.tsx b/frontend/src/bundles/common/components/video-modal/video-modal.tsx new file mode 100644 index 000000000..77d5953e6 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/video-modal.tsx @@ -0,0 +1,7 @@ +import { VideoModalSideBar } from './libs/components/components.js'; + +const VideoModal = (): JSX.Element => { + return ; +}; + +export { VideoModal }; From 617444e3b92363e455781395e85c6288fa88a45b Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 14:46:08 +0300 Subject: [PATCH 25/70] OV-11: + conditional rendering --- frontend/src/app/app.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/app.tsx b/frontend/src/app/app.tsx index f7420ca51..309b4baca 100644 --- a/frontend/src/app/app.tsx +++ b/frontend/src/app/app.tsx @@ -31,7 +31,11 @@ const App: React.FC = () => { return ( <> -
    + {pathname === AppRoute.SIGN_UP || + pathname === AppRoute.SIGN_IN ? null : ( +
    + )} + logo
      From 7f48764819d40fd1da6a939ccd2cc331e114a1f1 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Tue, 20 Aug 2024 07:06:18 -0500 Subject: [PATCH 26/70] OV-2: - remove unnecessary types --- backend/src/common/types/repository.type.ts | 1 - backend/src/common/types/service.type.ts | 3 --- 2 files changed, 4 deletions(-) diff --git a/backend/src/common/types/repository.type.ts b/backend/src/common/types/repository.type.ts index 4008a9251..d69be849b 100644 --- a/backend/src/common/types/repository.type.ts +++ b/backend/src/common/types/repository.type.ts @@ -1,7 +1,6 @@ type Repository = { find(): Promise; findAll(): Promise; - findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; delete(): Promise; diff --git a/backend/src/common/types/service.type.ts b/backend/src/common/types/service.type.ts index 245943234..47673e6d3 100644 --- a/backend/src/common/types/service.type.ts +++ b/backend/src/common/types/service.type.ts @@ -1,8 +1,5 @@ type Service = { find(): Promise; - findAll(): Promise<{ - items: T[]; - }>; findByEmail(email: string): Promise; create(payload: unknown): Promise; update(): Promise; From 06fa5d15110343aeeec9684d51529a8bc657fdd1 Mon Sep 17 00:00:00 2001 From: JKaypa Date: Tue, 20 Aug 2024 07:21:08 -0500 Subject: [PATCH 27/70] OV-2: - * fix service types --- backend/src/common/types/service.type.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/common/types/service.type.ts b/backend/src/common/types/service.type.ts index 47673e6d3..7b1a64ebb 100644 --- a/backend/src/common/types/service.type.ts +++ b/backend/src/common/types/service.type.ts @@ -1,6 +1,8 @@ type Service = { find(): Promise; - findByEmail(email: string): Promise; + findAll(): Promise<{ + items: T[]; + }>; create(payload: unknown): Promise; update(): Promise; delete(): Promise; From cc693ceb776f357053892755fe6400924071a441 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Tue, 20 Aug 2024 15:39:49 +0300 Subject: [PATCH 28/70] OV-11: - header from app --- frontend/src/app/app.tsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/frontend/src/app/app.tsx b/frontend/src/app/app.tsx index 309b4baca..e1f671b35 100644 --- a/frontend/src/app/app.tsx +++ b/frontend/src/app/app.tsx @@ -1,9 +1,5 @@ import reactLogo from '~/assets/img/react.svg'; -import { - Header, - Link, - RouterOutlet, -} from '~/bundles/common/components/components.js'; +import { Link, RouterOutlet } from '~/bundles/common/components/components.js'; import { AppRoute } from '~/bundles/common/enums/enums.js'; import { useAppDispatch, @@ -31,11 +27,6 @@ const App: React.FC = () => { return ( <> - {pathname === AppRoute.SIGN_UP || - pathname === AppRoute.SIGN_IN ? null : ( -
      - )} - logo
        From cd43f07e5e901df61aaf790e769e8ba3bc19e642 Mon Sep 17 00:00:00 2001 From: Oleksandra Nedashkivska Date: Sun, 18 Aug 2024 15:07:06 +0300 Subject: [PATCH 29/70] OV-1: + password input --- frontend/package.json | 1 + .../auth/components/common/components.ts | 1 + .../common/password-input/password-input.tsx | 40 +++++++++++++++++++ .../bundles/common/components/components.ts | 6 +++ .../theme/styles/components.styles.ts | 10 +++++ package-lock.json | 13 ++++++ 6 files changed, 71 insertions(+) create mode 100644 frontend/src/bundles/auth/components/common/components.ts create mode 100644 frontend/src/bundles/auth/components/common/password-input/password-input.tsx diff --git a/frontend/package.json b/frontend/package.json index 881769413..41ff12932 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -27,6 +27,7 @@ "vite": "5.4.0" }, "dependencies": { + "@chakra-ui/icons": "2.1.1", "@chakra-ui/react": "2.8.2", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", diff --git a/frontend/src/bundles/auth/components/common/components.ts b/frontend/src/bundles/auth/components/common/components.ts new file mode 100644 index 000000000..b5b4684f7 --- /dev/null +++ b/frontend/src/bundles/auth/components/common/components.ts @@ -0,0 +1 @@ +export { PasswordInput } from './password-input/password-input.js'; diff --git a/frontend/src/bundles/auth/components/common/password-input/password-input.tsx b/frontend/src/bundles/auth/components/common/password-input/password-input.tsx new file mode 100644 index 000000000..a87a0e65b --- /dev/null +++ b/frontend/src/bundles/auth/components/common/password-input/password-input.tsx @@ -0,0 +1,40 @@ +import { + IconButton, + Input, + InputGroup, + InputRightElement, + ViewIcon, + ViewOffIcon, +} from '~/bundles/common/components/components.js'; +import { useCallback, useState } from '~/bundles/common/hooks/hooks.js'; + +const PasswordInput: React.FC = () => { + const [showPassword, setShowPassword] = useState(false); + + const handlePasswordIconClick = useCallback((): void => { + setShowPassword((previousShowPassword) => !previousShowPassword); + }, []); + + return ( + + + + : } + onClick={handlePasswordIconClick} + variant="ghostIcon" + /> + + + ); +}; + +export { PasswordInput }; diff --git a/frontend/src/bundles/common/components/components.ts b/frontend/src/bundles/common/components/components.ts index 71c774689..9da09a971 100644 --- a/frontend/src/bundles/common/components/components.ts +++ b/frontend/src/bundles/common/components/components.ts @@ -4,12 +4,18 @@ export { Link } from './link/link.js'; export { Loader } from './loader/loader.js'; export { Overlay } from './overlay/overlay.js'; export { RouterProvider } from './router-provider/router-provider.js'; +export { ViewIcon, ViewOffIcon } from '@chakra-ui/icons'; export { Box, + Center, Circle, ChakraProvider as ComponentsProvider, Flex, Heading, + IconButton, + InputGroup, + InputRightElement, + SimpleGrid, Text, VStack, } from '@chakra-ui/react'; diff --git a/frontend/src/framework/theme/styles/components.styles.ts b/frontend/src/framework/theme/styles/components.styles.ts index 417d40ef9..cb0d05804 100644 --- a/frontend/src/framework/theme/styles/components.styles.ts +++ b/frontend/src/framework/theme/styles/components.styles.ts @@ -78,6 +78,16 @@ const components = { }, }, }, + Button: { + variants: { + ghostIcon: { + color: 'white', + _hover: { + color: 'brand.secondary.300', + }, + }, + }, + }, }; export { components }; diff --git a/package-lock.json b/package-lock.json index 711edfde0..c679dfd41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,6 +71,7 @@ "frontend": { "version": "1.0.0", "dependencies": { + "@chakra-ui/icons": "2.1.1", "@chakra-ui/react": "2.8.2", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", @@ -803,6 +804,18 @@ "react": ">=18" } }, + "node_modules/@chakra-ui/icons": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@chakra-ui/icons/-/icons-2.1.1.tgz", + "integrity": "sha512-3p30hdo4LlRZTT5CwoAJq3G9fHI0wDc0pBaMHj4SUn0yomO+RcDRlzhdXqdr5cVnzax44sqXJVnf3oQG0eI+4g==", + "dependencies": { + "@chakra-ui/icon": "3.2.0" + }, + "peerDependencies": { + "@chakra-ui/system": ">=2.0.0", + "react": ">=18" + } + }, "node_modules/@chakra-ui/image": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@chakra-ui/image/-/image-2.1.0.tgz", From aaa8b5d9cfc54bf8b13a847d8b0b736490c2571d Mon Sep 17 00:00:00 2001 From: Oleksandra Nedashkivska Date: Sun, 18 Aug 2024 15:24:26 +0300 Subject: [PATCH 30/70] OV-1: + signin validation schema --- .../sign-in-form/constants/constants.ts | 8 +++++ frontend/src/bundles/users/types/types.ts | 1 + frontend/src/bundles/users/users.ts | 6 +++- .../validation-schemas/validation-schemas.ts | 2 +- .../enums/user-validation-message.enum.ts | 3 ++ .../users/enums/user-validation-rule.enum.ts | 5 ++- shared/src/bundles/users/types/types.ts | 1 + .../types/user-sign-in-request-dto.type.ts | 6 ++++ shared/src/bundles/users/users.ts | 6 +++- .../user-sign-in.validation-schema.ts | 36 +++++++++++++++++++ .../validation-schemas/validation-schemas.ts | 1 + shared/src/index.ts | 2 ++ 12 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 frontend/src/bundles/auth/components/sign-in-form/constants/constants.ts create mode 100644 shared/src/bundles/users/types/user-sign-in-request-dto.type.ts create mode 100644 shared/src/bundles/users/validation-schemas/user-sign-in.validation-schema.ts diff --git a/frontend/src/bundles/auth/components/sign-in-form/constants/constants.ts b/frontend/src/bundles/auth/components/sign-in-form/constants/constants.ts new file mode 100644 index 000000000..3e3264e83 --- /dev/null +++ b/frontend/src/bundles/auth/components/sign-in-form/constants/constants.ts @@ -0,0 +1,8 @@ +import { type UserSignInRequestDto } from '~/bundles/users/users.js'; + +const DEFAULT_SIGN_IN_PAYLOAD: UserSignInRequestDto = { + email: '', + password: '', +}; + +export { DEFAULT_SIGN_IN_PAYLOAD }; diff --git a/frontend/src/bundles/users/types/types.ts b/frontend/src/bundles/users/types/types.ts index fb8e20c76..0a38e94bf 100644 --- a/frontend/src/bundles/users/types/types.ts +++ b/frontend/src/bundles/users/types/types.ts @@ -1,6 +1,7 @@ export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from 'shared'; diff --git a/frontend/src/bundles/users/users.ts b/frontend/src/bundles/users/users.ts index 443083e1c..59ffe28cb 100644 --- a/frontend/src/bundles/users/users.ts +++ b/frontend/src/bundles/users/users.ts @@ -14,7 +14,11 @@ export { userApi }; export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; -export { userSignUpValidationSchema } from './validation-schemas/validation-schemas.js'; +export { + userSignInValidationSchema, + userSignUpValidationSchema, +} from './validation-schemas/validation-schemas.js'; diff --git a/frontend/src/bundles/users/validation-schemas/validation-schemas.ts b/frontend/src/bundles/users/validation-schemas/validation-schemas.ts index 7bc9a09c5..5952fe0cf 100644 --- a/frontend/src/bundles/users/validation-schemas/validation-schemas.ts +++ b/frontend/src/bundles/users/validation-schemas/validation-schemas.ts @@ -1 +1 @@ -export { userSignUpValidationSchema } from 'shared'; +export { userSignInValidationSchema, userSignUpValidationSchema } from 'shared'; diff --git a/shared/src/bundles/users/enums/user-validation-message.enum.ts b/shared/src/bundles/users/enums/user-validation-message.enum.ts index b28063d96..f369a8c1a 100644 --- a/shared/src/bundles/users/enums/user-validation-message.enum.ts +++ b/shared/src/bundles/users/enums/user-validation-message.enum.ts @@ -1,6 +1,9 @@ const UserValidationMessage = { EMAIL_REQUIRE: 'Email is required', EMAIL_WRONG: 'Email is wrong', + FIELD_REQUIRE: 'Please fill out this field', + EMAIL_INVALID: 'Please enter a valid email', + PASSWORD_LENGTH: 'Password must have from 6 to 12 characters', } as const; export { UserValidationMessage }; diff --git a/shared/src/bundles/users/enums/user-validation-rule.enum.ts b/shared/src/bundles/users/enums/user-validation-rule.enum.ts index 36ca9c2e2..eb7d606aa 100644 --- a/shared/src/bundles/users/enums/user-validation-rule.enum.ts +++ b/shared/src/bundles/users/enums/user-validation-rule.enum.ts @@ -1,5 +1,8 @@ const UserValidationRule = { - EMAIL_MINIMUM_LENGTH: 1, + EMAIL_MINIMUM_LENGTH: 6, + EMAIL_MAXIMUM_LENGTH: 320, + PASSWORD_MINIMUM_LENGTH: 6, + PASSWORD_MAXIMUM_LENGTH: 12, } as const; export { UserValidationRule }; diff --git a/shared/src/bundles/users/types/types.ts b/shared/src/bundles/users/types/types.ts index 7564f70b2..f6fd8caa2 100644 --- a/shared/src/bundles/users/types/types.ts +++ b/shared/src/bundles/users/types/types.ts @@ -1,4 +1,5 @@ export { type UserGetAllItemResponseDto } from './user-get-all-item-response-dto.type.js'; export { type UserGetAllResponseDto } from './user-get-all-response-dto.type.js'; +export { type UserSignInRequestDto } from './user-sign-in-request-dto.type.js'; export { type UserSignUpRequestDto } from './user-sign-up-request-dto.type.js'; export { type UserSignUpResponseDto } from './user-sign-up-response-dto.type.js'; diff --git a/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts b/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts new file mode 100644 index 000000000..8098c64cf --- /dev/null +++ b/shared/src/bundles/users/types/user-sign-in-request-dto.type.ts @@ -0,0 +1,6 @@ +type UserSignInRequestDto = { + email: string; + password: string; +}; + +export { type UserSignInRequestDto }; diff --git a/shared/src/bundles/users/users.ts b/shared/src/bundles/users/users.ts index e65858985..162c57439 100644 --- a/shared/src/bundles/users/users.ts +++ b/shared/src/bundles/users/users.ts @@ -2,7 +2,11 @@ export { UsersApiPath, UserValidationMessage } from './enums/enums.js'; export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, } from './types/types.js'; -export { userSignUp as userSignUpValidationSchema } from './validation-schemas/validation-schemas.js'; +export { + userSignIn as userSignInValidationSchema, + userSignUp as userSignUpValidationSchema, +} from './validation-schemas/validation-schemas.js'; diff --git a/shared/src/bundles/users/validation-schemas/user-sign-in.validation-schema.ts b/shared/src/bundles/users/validation-schemas/user-sign-in.validation-schema.ts new file mode 100644 index 000000000..100cb3dad --- /dev/null +++ b/shared/src/bundles/users/validation-schemas/user-sign-in.validation-schema.ts @@ -0,0 +1,36 @@ +import { z } from 'zod'; + +import { UserValidationMessage, UserValidationRule } from '../enums/enums.js'; + +type UserSignInRequestValidationDto = { + email: z.ZodString; + password: z.ZodString; +}; + +const userSignIn = z + .object({ + email: z + .string({ required_error: UserValidationMessage.FIELD_REQUIRE }) + .trim() + .min(UserValidationRule.EMAIL_MINIMUM_LENGTH, { + message: UserValidationMessage.EMAIL_INVALID, + }) + .max(UserValidationRule.EMAIL_MAXIMUM_LENGTH, { + message: UserValidationMessage.EMAIL_INVALID, + }) + .email({ + message: UserValidationMessage.EMAIL_INVALID, + }), + password: z + .string({ required_error: UserValidationMessage.FIELD_REQUIRE }) + .trim() + .min(UserValidationRule.PASSWORD_MINIMUM_LENGTH, { + message: UserValidationMessage.PASSWORD_LENGTH, + }) + .max(UserValidationRule.PASSWORD_MAXIMUM_LENGTH, { + message: UserValidationMessage.PASSWORD_LENGTH, + }), + }) + .required(); + +export { userSignIn }; diff --git a/shared/src/bundles/users/validation-schemas/validation-schemas.ts b/shared/src/bundles/users/validation-schemas/validation-schemas.ts index cb1c2ad60..f6c85f13c 100644 --- a/shared/src/bundles/users/validation-schemas/validation-schemas.ts +++ b/shared/src/bundles/users/validation-schemas/validation-schemas.ts @@ -1 +1,2 @@ +export { userSignIn } from './user-sign-in.validation-schema.js'; export { userSignUp } from './user-sign-up.validation-schema.js'; diff --git a/shared/src/index.ts b/shared/src/index.ts index df887038b..a0f2d2c57 100644 --- a/shared/src/index.ts +++ b/shared/src/index.ts @@ -2,9 +2,11 @@ export { AuthApiPath } from './bundles/auth/auth.js'; export { type UserGetAllItemResponseDto, type UserGetAllResponseDto, + type UserSignInRequestDto, type UserSignUpRequestDto, type UserSignUpResponseDto, UsersApiPath, + userSignInValidationSchema, userSignUpValidationSchema, } from './bundles/users/users.js'; export { From 9ecc8efbd9c75db7ce9c59e4049b9e2e4c5a593f Mon Sep 17 00:00:00 2001 From: Oleksandra Nedashkivska Date: Sun, 18 Aug 2024 15:26:32 +0300 Subject: [PATCH 31/70] OV-1: + button customization --- .../src/framework/theme/styles/components.styles.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/framework/theme/styles/components.styles.ts b/frontend/src/framework/theme/styles/components.styles.ts index cb0d05804..a64bd5171 100644 --- a/frontend/src/framework/theme/styles/components.styles.ts +++ b/frontend/src/framework/theme/styles/components.styles.ts @@ -80,6 +80,16 @@ const components = { }, Button: { variants: { + solid: { + color: 'white', + bgColor: 'brand.secondary.300', + _hover: { + bg: 'brand.secondary.600', + _disabled: { + bg: 'brand.secondary.600', + }, + }, + }, ghostIcon: { color: 'white', _hover: { From e7e9112f88ae169148cb9272a21bcedb04f9c680 Mon Sep 17 00:00:00 2001 From: Oleksandra Nedashkivska Date: Sun, 18 Aug 2024 15:51:16 +0300 Subject: [PATCH 32/70] OV-1: * signin form --- .../common/password-input/password-input.tsx | 10 ++- .../components/sign-in-form/sign-in-form.tsx | 64 ++++++++++++++++--- .../common/components/button/button.tsx | 11 +++- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/frontend/src/bundles/auth/components/common/password-input/password-input.tsx b/frontend/src/bundles/auth/components/common/password-input/password-input.tsx index a87a0e65b..2a2252066 100644 --- a/frontend/src/bundles/auth/components/common/password-input/password-input.tsx +++ b/frontend/src/bundles/auth/components/common/password-input/password-input.tsx @@ -8,7 +8,11 @@ import { } from '~/bundles/common/components/components.js'; import { useCallback, useState } from '~/bundles/common/hooks/hooks.js'; -const PasswordInput: React.FC = () => { +type Properties = { + hasError: boolean; +}; + +const PasswordInput: React.FC = ({ hasError }) => { const [showPassword, setShowPassword] = useState(false); const handlePasswordIconClick = useCallback((): void => { @@ -16,14 +20,14 @@ const PasswordInput: React.FC = () => { }, []); return ( - + - + void; + onSubmit: (payload: UserSignInRequestDto) => void; }; -const SignInForm: React.FC = () => ( - <> - Sign In +const SignInForm: React.FC = ({ onSubmit }) => { + const form = useAppForm({ + initialValues: DEFAULT_SIGN_IN_PAYLOAD, + validationSchema: userSignInValidationSchema, + onSubmit, + }); + + const { handleSubmit, errors } = form; -
        -
        + + + + ); +}; + +export { VideoPreview }; From 742e62ab7a0a112c72ff29a1422722d9fdd5f8a1 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 10:09:48 +0300 Subject: [PATCH 58/70] OV-18: + exports --- .../video-modal-content/libs/components/components.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/components.ts diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/components.ts b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/components.ts new file mode 100644 index 000000000..d179bd19c --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/components.ts @@ -0,0 +1,2 @@ +export { Tab } from './tab/tab.js'; +export { VideoPreview } from './video-preview/video-preview.js'; From 0dbf2cedf56d39a9d2d44c6a0d05fadc91c4c590 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 10:11:18 +0300 Subject: [PATCH 59/70] OV-18: - old files --- .../bundles/common/components/modal/modal.tsx | 36 ------------------- .../libs/components/components.ts | 1 - .../video-modal-side-bar.tsx | 34 ------------------ 3 files changed, 71 deletions(-) delete mode 100644 frontend/src/bundles/common/components/modal/modal.tsx delete mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts delete mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx diff --git a/frontend/src/bundles/common/components/modal/modal.tsx b/frontend/src/bundles/common/components/modal/modal.tsx deleted file mode 100644 index e10682e5d..000000000 --- a/frontend/src/bundles/common/components/modal/modal.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { - Modal as ChakraModal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalHeader, - ModalOverlay, -} from '@chakra-ui/react'; -import { type ReactNode } from 'react'; - -type Properties = { - isOpen: boolean; - closeModal: () => void; - title?: string; - children: ReactNode; -}; - -const Modal = ({ - isOpen, - closeModal, - title, - children, -}: Properties): JSX.Element => { - return ( - - - - {title} - - {children} - - - ); -}; - -export { Modal }; diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts deleted file mode 100644 index e5eeec838..000000000 --- a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/libs/components/components.ts +++ /dev/null @@ -1 +0,0 @@ -export { Tab } from './tab/tab.js'; diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx deleted file mode 100644 index 3948c46f6..000000000 --- a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-side-bar/video-modal-side-bar.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/react'; - -import { Tab } from './libs/components/components.js'; - -const VideoModalSideBar = (): JSX.Element => { - return ( - - - - - - - - -

        one!

        -
        - -

        two!

        -
        - -

        three!

        -
        -
        -
        - ); -}; - -export { VideoModalSideBar }; From 68796b7cfae4964828c834b6acf7bd79648b094c Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 10:12:34 +0300 Subject: [PATCH 60/70] OV-18: + VideoModalContent component --- .../video-modal/libs/components/components.ts | 2 +- .../video-modal-content.tsx | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/video-modal-content.tsx diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/components.ts b/frontend/src/bundles/common/components/video-modal/libs/components/components.ts index 5f623fe39..9ba9d1e9d 100644 --- a/frontend/src/bundles/common/components/video-modal/libs/components/components.ts +++ b/frontend/src/bundles/common/components/video-modal/libs/components/components.ts @@ -1 +1 @@ -export { VideoModalSideBar } from './video-modal-side-bar/video-modal-side-bar.js'; +export { VideoModalContent } from './video-modal-content/video-modal-content.js'; diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/video-modal-content.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/video-modal-content.tsx new file mode 100644 index 000000000..01524e5a7 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/video-modal-content.tsx @@ -0,0 +1,24 @@ +import { TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/react'; + +import { Tab, VideoPreview } from './libs/components/components.js'; + +const VideoModalContent = (): JSX.Element => { + return ( + + + + + + + + + + + ); +}; + +export { VideoModalContent }; From d2bec02e2ff5dbb6c612dd0478fea4204607485c Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 10:13:52 +0300 Subject: [PATCH 61/70] OV-18: + VideoModal component --- .../bundles/common/components/components.ts | 1 + .../components/video-modal/video-modal.tsx | 45 +++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/frontend/src/bundles/common/components/components.ts b/frontend/src/bundles/common/components/components.ts index c453d5f1a..82afbde76 100644 --- a/frontend/src/bundles/common/components/components.ts +++ b/frontend/src/bundles/common/components/components.ts @@ -4,6 +4,7 @@ export { Link } from './link/link.js'; export { Loader } from './loader/loader.js'; export { Overlay } from './overlay/overlay.js'; export { RouterProvider } from './router-provider/router-provider.js'; +export { VideoModal } from './video-modal/video-modal.js'; export { Box, ChakraProvider as ComponentsProvider, diff --git a/frontend/src/bundles/common/components/video-modal/video-modal.tsx b/frontend/src/bundles/common/components/video-modal/video-modal.tsx index 77d5953e6..934ca60c9 100644 --- a/frontend/src/bundles/common/components/video-modal/video-modal.tsx +++ b/frontend/src/bundles/common/components/video-modal/video-modal.tsx @@ -1,7 +1,46 @@ -import { VideoModalSideBar } from './libs/components/components.js'; +import { + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalHeader, + ModalOverlay, +} from '@chakra-ui/react'; -const VideoModal = (): JSX.Element => { - return ; +import { VideoModalContent } from './libs/components/components.js'; + +type Properties = { + isOpen: boolean; + closeModal: () => void; +}; + +const VideoModal = ({ isOpen, closeModal }: Properties): JSX.Element => { + return ( + + + + + Create video + + + + + + + + ); }; export { VideoModal }; From a6158d4f05a84e0d8a3d649abd8ea4d65c912c2a Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 11:29:38 +0300 Subject: [PATCH 62/70] OV-18: + enum --- .../libs/components/video-preview/libs/enums/enums.ts | 1 + .../components/video-preview/libs/enums/video-sizes.enum.ts | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/video-sizes.enum.ts diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/enums.ts b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/enums.ts index 42f29f46e..9a2f32d26 100644 --- a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/enums.ts +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/enums.ts @@ -1 +1,2 @@ export { VideoPreview } from './video-preview.enum.js'; +export { VideoSizeLabel } from './video-sizes.enum.js'; diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/video-sizes.enum.ts b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/video-sizes.enum.ts new file mode 100644 index 000000000..8be9ed814 --- /dev/null +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/libs/enums/video-sizes.enum.ts @@ -0,0 +1,6 @@ +const VideoSizeLabel = { + PORTRAIT: '1080 x 1920', + LANDSCAPE: '1920 x 1080', +} as const; + +export { VideoSizeLabel }; From 8270db92ea18df1027cd3ab9b59a037966facadf Mon Sep 17 00:00:00 2001 From: Sergiy Date: Wed, 21 Aug 2024 11:31:21 +0300 Subject: [PATCH 63/70] OV-18: + icon --- .../libs/components/tab/tab.tsx | 13 +++++-- .../video-preview/video-preview.tsx | 36 +++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/tab/tab.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/tab/tab.tsx index 1459629a9..ea8761154 100644 --- a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/tab/tab.tsx +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/tab/tab.tsx @@ -1,10 +1,13 @@ -import { Tab as ChakraTab } from '@chakra-ui/react'; +import { Icon, Tab as ChakraTab } from '@chakra-ui/react'; +import { type IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; type Properties = { label: string; + icon: IconDefinition; }; -const Tab = ({ label }: Properties): JSX.Element => { +const Tab = ({ label, icon }: Properties): JSX.Element => { return ( { textAlign="left" _selected={{ backgroundColor: 'gray.300' }} > + {' '} {label} ); diff --git a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/video-preview.tsx b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/video-preview.tsx index a86514b0c..8586316f2 100644 --- a/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/video-preview.tsx +++ b/frontend/src/bundles/common/components/video-modal/libs/components/video-modal-content/libs/components/video-preview/video-preview.tsx @@ -1,7 +1,12 @@ -import { Box, Button, Flex, Text } from '@chakra-ui/react'; +import { Button, Flex, Icon, Text } from '@chakra-ui/react'; +import { faPlay } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useCallback, useState } from 'react'; -import { VideoPreview as VideoPreviewValues } from './libs/enums/enums.js'; +import { + VideoPreview as VideoPreviewValues, + VideoSizeLabel, +} from './libs/enums/enums.js'; import { type VideoPreview as VideoPreviewType } from './libs/types/types.js'; const VideoPreview = (): JSX.Element => { @@ -19,23 +24,34 @@ const VideoPreview = (): JSX.Element => { return ( - - - {view === VideoPreviewValues.PORTRAIT - ? '1080 x 1920' - : '1920 x 1080'} - - + + + + {view === VideoPreviewValues.PORTRAIT + ? VideoSizeLabel.PORTRAIT + : VideoSizeLabel.LANDSCAPE} + + +