Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
f12950757c
|
|
@ -1,4 +1,4 @@
|
|||
import { IsBoolean, IsEnum, IsOptional } from "class-validator";
|
||||
import { IsBoolean, IsEnum, IsInt, IsOptional } from "class-validator";
|
||||
|
||||
export enum DisplayLanguage {
|
||||
FR = 'fr-FR',
|
||||
|
|
@ -6,6 +6,7 @@ export enum DisplayLanguage {
|
|||
}
|
||||
|
||||
export class PreferencesDto {
|
||||
@IsInt() id: number;
|
||||
@IsBoolean() notifications: boolean;
|
||||
@IsOptional() @IsBoolean() is_dark_mode?: boolean;
|
||||
@IsEnum(DisplayLanguage) display_language: string;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export class PreferencesService {
|
|||
const user_preferences = await this.prisma.preferences.findUnique({
|
||||
where: { user_id: user_id.data },
|
||||
select: {
|
||||
id: true,
|
||||
notifications: true,
|
||||
is_dark_mode: true,
|
||||
display_language: true,
|
||||
|
|
@ -30,6 +31,7 @@ export class PreferencesService {
|
|||
if (!user_preferences) return { success: false, error: 'PREFERENCES_NOT_FOUND' };
|
||||
|
||||
const preferences: PreferencesDto = {
|
||||
id: user_preferences.id,
|
||||
is_dark_mode: user_preferences.is_dark_mode,
|
||||
display_language: user_preferences.display_language ?? DisplayLanguage.FR ,
|
||||
is_lefty_mode: user_preferences.is_lefty_mode,
|
||||
|
|
@ -54,14 +56,7 @@ export class PreferencesService {
|
|||
is_employee_list_grid: dto.is_employee_list_grid,
|
||||
is_timesheet_approval_grid: dto.is_timesheet_approval_grid,
|
||||
},
|
||||
select: {
|
||||
notifications: true,
|
||||
is_dark_mode: true,
|
||||
display_language: true,
|
||||
is_employee_list_grid: true,
|
||||
is_timesheet_approval_grid: true,
|
||||
is_lefty_mode: true,
|
||||
},
|
||||
omit: { user_id: true },
|
||||
});
|
||||
return { success: true, data: updated_preferences};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user