Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { Controller, Get, Body, Put, Post, Delete } from '@nestjs/common';
import { AdminSettingsService } from '../application/admin-settings.service';
import { AdminSettings } from '../domain/admin-settings.entity';
import { UpdateAdminSettingsDto } from './dto/update-admin-settings.dto';
import { CreateAdminSettingsDto } from './dto/create-admin-settings.dto';

@ApiTags('Admin Settings')
@Controller('admin-settings')
export class AdminSettingsController {
constructor(private readonly adminSettingsService: AdminSettingsService) {}

@ApiOperation({ summary: 'Get all' }) @ApiResponse({ status: 200 })
@Get()
async getSettings(): Promise<AdminSettings | null> {
return this.adminSettingsService.getSettings();
}

@ApiOperation({ summary: 'Create' }) @ApiResponse({ status: 201 })
@Post()
async createSettings(
@Body() createAdminSettingsDto: CreateAdminSettingsDto,
Expand All @@ -24,6 +28,7 @@ export class AdminSettingsController {
);
}

@ApiOperation({ summary: 'Update' }) @ApiResponse({ status: 200 })
@Put()
async updateSettings(
@Body() updateAdminSettingsDto: UpdateAdminSettingsDto,
Expand All @@ -37,6 +42,7 @@ export class AdminSettingsController {
return this.adminSettingsService.updateSettings(settings);
}

@ApiOperation({ summary: 'Delete' }) @ApiResponse({ status: 200 })
@Delete()
async deleteSettings(): Promise<boolean> {
return this.adminSettingsService.deleteSettings();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IsString,
IsNotEmpty,
Expand All @@ -14,80 +15,80 @@ import {
} from '../../domain/interfaces/admin-settings.interface';

class LocationDto implements IAdminLocation {
@IsString()
@IsString() @ApiProperty()
@IsNotEmpty()
address: string;

@IsNumber()
@IsNumber() @ApiProperty()
latitude: number;

@IsNumber()
@IsNumber() @ApiProperty()
longitude: number;
}

class OwnerInfoDto implements IOwnerInfo {
@IsString()
@IsString() @ApiProperty()
@IsNotEmpty()
name: string;

@IsString()
@IsString() @ApiProperty()
@IsNotEmpty()
phoneNumber: string;
}

export class CreateAdminSettingsDto {
@ValidateNested()
@ValidateNested() @ApiProperty()
@Type(() => LocationDto)
@IsNotEmpty()
location: LocationDto;

@IsObject()
@IsObject() @ApiPropertyOptional()
@IsOptional()
socialLinks: Record<string, string>;

@IsObject()
@IsObject() @ApiPropertyOptional()
@IsOptional()
workHours: Record<string, string>;

@ValidateNested()
@ValidateNested() @ApiProperty()
@Type(() => OwnerInfoDto)
@IsNotEmpty()
ownerInfo: OwnerInfoDto;

@IsString()
@IsString() @ApiProperty()
@IsOptional()
biography: string;

@IsString()
@IsString() @ApiProperty()
@IsOptional()
philosophy: string;

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
galleryCategories: string[];

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
treatmentCategories: string[];

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
veilSilhouettes: string[];

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
veilFabrics: string[];

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
veilTrainLengths: string[];

@IsArray()
@IsArray() @ApiPropertyOptional()
@IsString({ each: true })
@IsOptional()
veilNecklines: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { PartialType } from '@nestjs/swagger';
import { CreateAdminSettingsDto } from './create-admin-settings.dto';

export class UpdateAdminSettingsDto extends PartialType(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import {
Controller,
Get,
Expand All @@ -17,20 +18,24 @@ import { Gallery } from '../domain/gallery.entity';
import { CreateGalleryDto } from './dto/create-gallery.dto';
import { UpdateGalleryDto } from './dto/update-gallery.dto';

@ApiTags('Gallery')
@Controller('gallery')
export class GalleryController {
constructor(private readonly galleryService: GalleryService) {}

@ApiOperation({ summary: 'Get all' }) @ApiResponse({ status: 200 })
@Get()
async findAll(): Promise<Gallery[]> {
return this.galleryService.findAll();
}

@ApiOperation({ summary: 'Get one' }) @ApiResponse({ status: 200 })
@Get(':id')
async findOne(@Param('id') id: string): Promise<Gallery> {
return this.galleryService.findOne(id);
}

@ApiOperation({ summary: 'Create' }) @ApiResponse({ status: 201 })
@Post()
@UseInterceptors(
FilesInterceptor('files', 10, {
Expand Down Expand Up @@ -64,6 +69,7 @@ export class GalleryController {
return this.galleryService.create(gallery);
}

@ApiOperation({ summary: 'Update' }) @ApiResponse({ status: 200 })
@Put(':id')
@UseInterceptors(
FilesInterceptor('files', 10, {
Expand Down Expand Up @@ -98,6 +104,7 @@ export class GalleryController {
);
}

@ApiOperation({ summary: 'Delete' }) @ApiResponse({ status: 200 })
@Delete(':id')
async remove(@Param('id') id: string): Promise<void> {
return this.galleryService.remove(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IsBoolean,
IsNotEmpty,
Expand All @@ -21,35 +22,35 @@ export enum TreatmentCategory {

export class CreateServiceDto {
@IsNotEmpty()
@IsString()
@IsString() @ApiProperty()
name: string;

@IsNotEmpty()
@IsString()
@IsString() @ApiProperty()
description: string;

@IsNotEmpty()
@Type(() => Number)
@IsNumber()
@IsNumber() @ApiProperty()
@Min(1)
price: number;

@IsOptional()
@Type(() => Boolean)
@IsBoolean()
@IsBoolean() @ApiPropertyOptional()
active: boolean;

@IsNotEmpty()
@Type(() => Number)
@IsNumber()
@IsNumber() @ApiProperty()
@Min(1)
duration: number;

@IsNotEmpty()
@IsString()
@IsString() @ApiProperty()
category: string;

@IsOptional()
@IsString()
@IsString() @ApiProperty()
imageUrl: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { PartialType } from '@nestjs/swagger';
import { CreateServiceDto } from './create-treatments.dto';

export class UpdateServiceDto extends PartialType(CreateServiceDto) {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import {
CreateServiceDto as CreateTreatmentDto,
Treatments,
Expand All @@ -19,20 +20,24 @@ import { FilesInterceptor } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { extname } from 'path';

@ApiTags('Treatments')
@Controller('treatments')
export class TreatmentsController {
constructor(private readonly treatmentsService: TreatmentsService) {}

@ApiOperation({ summary: 'Get all' }) @ApiResponse({ status: 200 })
@Get()
async findAll(): Promise<Treatments[]> {
return this.treatmentsService.findAll();
}

@ApiOperation({ summary: 'Get one' }) @ApiResponse({ status: 200 })
@Get(':id')
async findOne(@Param('id') id: string): Promise<Treatments> {
return this.treatmentsService.findOne(id);
}

@ApiOperation({ summary: 'Create' }) @ApiResponse({ status: 201 })
@Post()
@UseInterceptors(
FilesInterceptor('image', 10, {
Expand Down Expand Up @@ -63,6 +68,7 @@ export class TreatmentsController {
);
}

@ApiOperation({ summary: 'Update' }) @ApiResponse({ status: 200 })
@Put(':id')
@UseInterceptors(
FilesInterceptor('image', 10, {
Expand Down Expand Up @@ -97,6 +103,7 @@ export class TreatmentsController {
);
}

@ApiOperation({ summary: 'Delete' }) @ApiResponse({ status: 200 })
@Delete(':id')
async remove(@Param('id') id: string): Promise<void> {
return this.treatmentsService.remove(id);
Expand Down
13 changes: 13 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"predev": "node scripts/setenv.cjs",
"dev": "ng serve --configuration=development",
"prebuild": "node scripts/setenv.cjs",
"build": "ng build",
"preview": "ng serve --configuration=production",
"test": "vitest"
Expand Down
17 changes: 17 additions & 0 deletions frontend/scripts/setenv.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });

const envConfigFile = `export const environment = {
production: ${process.env.NODE_ENV === 'production'},
apiUrl: "${process.env.FRONTEND_URL || 'http://localhost:3000'}",
telegramBotName: "${process.env.TELEGRAM_BOT_NAME || 'test_bot'}",
};
`;

const targetPath = path.resolve(__dirname, '../src/environments/environment.ts');
const targetProdPath = path.resolve(__dirname, '../src/environments/environment.prod.ts');

fs.writeFileSync(targetPath, envConfigFile);
fs.writeFileSync(targetProdPath, envConfigFile);
console.log(`Environment files generated at ${targetPath}`);
12 changes: 6 additions & 6 deletions frontend/src/core/constants/api-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ export const API_ENDPOINTS = {
URL_BY_ID: (id: string) => linkServerConvert(API_ENDPOINTS.GALLERY.URL, id),
},
AUTH: {
LOGIN: "/auth/login",
REGISTER: "/auth/register",
LOGIN: linkServerConvert("auth", "login"),
REGISTER: linkServerConvert("auth", "register"),
},

USER: {
PROFILE: "/user/profile",
UPDATE: "/user/update",
PROFILE: linkServerConvert("user", "profile"),
UPDATE: linkServerConvert("user", "update"),
},
ADMIN: {
SETTINGS: "/admin-settings",
ANALYTICS: "/admin/analytics",
SETTINGS: linkServerConvert("admin-settings"),
ANALYTICS: linkServerConvert("admin", "analytics"),
},
} as const;
Loading
Loading