anhledger12 commited on
Commit
fa2fb3b
2 Parent(s): c721f3d d279573

Merge branch 'main' into feature/login

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitignore +2 -1
  2. backend/.env.example +2 -1
  3. backend/package-lock.json +7 -0
  4. backend/package.json +1 -0
  5. backend/src/app.controller.ts +2 -0
  6. backend/src/app.module.ts +3 -4
  7. backend/src/config/config.ts +1 -0
  8. backend/src/config/database.ts +6 -3
  9. backend/src/config/typeorm.ts +7 -3
  10. backend/src/entities/branch-menu.entity.ts +35 -0
  11. backend/src/entities/branch.entity.ts +5 -0
  12. backend/src/entities/menu-item.entity.ts +37 -0
  13. backend/src/main.ts +2 -0
  14. backend/src/migrations/1729703705445-AddBranchMenus.ts +20 -0
  15. backend/src/modules/authentication/authentication.controller.spec.ts +0 -20
  16. backend/src/modules/authentication/authentication.controller.ts +1 -2
  17. backend/src/modules/authentication/authentication.guard.ts +47 -45
  18. backend/src/modules/authentication/authentication.module.ts +6 -7
  19. backend/src/modules/authentication/authentication.service.spec.ts +0 -18
  20. backend/src/modules/authentication/authentication.service.ts +7 -7
  21. backend/src/modules/menu-item/dto/create-menu-item.dto.ts +23 -0
  22. backend/src/modules/menu-item/dto/update-menu-item.dto.ts +23 -0
  23. backend/src/modules/menu-item/menu-item.controller.ts +47 -0
  24. backend/src/modules/menu-item/menu-item.module.ts +9 -0
  25. backend/src/modules/menu-item/menu-item.service.ts +44 -0
  26. backend/src/modules/user/user.controller.ts +5 -3
  27. backend/src/modules/user/user.module.ts +1 -1
  28. backend/src/modules/user/user.service.ts +4 -7
  29. frontend/.gitignore +23 -0
  30. frontend/README.md +104 -0
  31. frontend/package-lock.json +0 -0
  32. frontend/package.json +41 -0
  33. frontend/public/cats-logo.png +0 -0
  34. frontend/public/favicon.ico +0 -0
  35. frontend/public/index.html +43 -0
  36. frontend/public/logo.svg +1 -0
  37. frontend/public/logo192.png +0 -0
  38. frontend/public/logo512.png +0 -0
  39. frontend/public/manifest.json +25 -0
  40. frontend/public/placeholder1.jpg +0 -0
  41. frontend/public/placeholder2.jpg +0 -0
  42. frontend/public/placeholder3.jpg +0 -0
  43. frontend/public/placeholder4.jpg +0 -0
  44. frontend/public/robots.txt +3 -0
  45. frontend/src/App.js +22 -0
  46. frontend/src/App.test.js +8 -0
  47. frontend/src/atoms/ButtonWrapper.js +12 -0
  48. frontend/src/atoms/CardWrapper.js +19 -0
  49. frontend/src/index.js +17 -0
  50. frontend/src/molecules/AboutUsSection.js +21 -0
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  .cache
3
  *.exe
4
  .project
5
- .classpath
 
 
2
  .cache
3
  *.exe
4
  .project
5
+ .classpath
6
+ frontend/node_modules
backend/.env.example CHANGED
@@ -3,4 +3,5 @@ DB_PORT=5432
3
  DB_USER='pbl6_jw8s_user'
4
  DB_PASSWORD=''
5
  DB_NAME='pbl6_jw8s'
6
- JWT_KEY = ''
 
 
3
  DB_USER='pbl6_jw8s_user'
4
  DB_PASSWORD=''
5
  DB_NAME='pbl6_jw8s'
6
+ JWT_KEY= ''
7
+ DB_SSL_ENABLED=true # default is true to connect with remote database
backend/package-lock.json CHANGED
@@ -17,6 +17,7 @@
17
  "@nestjs/platform-express": "^10.0.0",
18
  "@nestjs/typeorm": "^10.0.2",
19
  "bcrypt": "^5.1.1",
 
20
  "class-validator": "^0.14.1",
21
  "dotenv": "^16.4.5",
22
  "mysql2": "^3.11.3",
@@ -3394,6 +3395,12 @@
3394
  "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==",
3395
  "dev": true
3396
  },
 
 
 
 
 
 
3397
  "node_modules/class-validator": {
3398
  "version": "0.14.1",
3399
  "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.1.tgz",
 
17
  "@nestjs/platform-express": "^10.0.0",
18
  "@nestjs/typeorm": "^10.0.2",
19
  "bcrypt": "^5.1.1",
20
+ "class-transformer": "^0.5.1",
21
  "class-validator": "^0.14.1",
22
  "dotenv": "^16.4.5",
23
  "mysql2": "^3.11.3",
 
3395
  "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==",
3396
  "dev": true
3397
  },
3398
+ "node_modules/class-transformer": {
3399
+ "version": "0.5.1",
3400
+ "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz",
3401
+ "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==",
3402
+ "license": "MIT"
3403
+ },
3404
  "node_modules/class-validator": {
3405
  "version": "0.14.1",
3406
  "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.1.tgz",
backend/package.json CHANGED
@@ -33,6 +33,7 @@
33
  "@nestjs/platform-express": "^10.0.0",
34
  "@nestjs/typeorm": "^10.0.2",
35
  "bcrypt": "^5.1.1",
 
36
  "class-validator": "^0.14.1",
37
  "dotenv": "^16.4.5",
38
  "mysql2": "^3.11.3",
 
33
  "@nestjs/platform-express": "^10.0.0",
34
  "@nestjs/typeorm": "^10.0.2",
35
  "bcrypt": "^5.1.1",
36
+ "class-transformer": "^0.5.1",
37
  "class-validator": "^0.14.1",
38
  "dotenv": "^16.4.5",
39
  "mysql2": "^3.11.3",
backend/src/app.controller.ts CHANGED
@@ -1,10 +1,12 @@
1
  import { Controller, Get } from '@nestjs/common';
2
  import { AppService } from './app.service.js';
 
3
 
4
  @Controller()
5
  export class AppController {
6
  constructor(private readonly appService: AppService) {}
7
 
 
8
  @Get()
9
  getHello(): string {
10
  return this.appService.getHello();
 
1
  import { Controller, Get } from '@nestjs/common';
2
  import { AppService } from './app.service.js';
3
+ import { Public } from './modules/authentication/authentication.decorator.js';
4
 
5
  @Controller()
6
  export class AppController {
7
  constructor(private readonly appService: AppService) {}
8
 
9
+ @Public()
10
  @Get()
11
  getHello(): string {
12
  return this.appService.getHello();
backend/src/app.module.ts CHANGED
@@ -9,10 +9,8 @@ import { AppLoggerMiddleware } from './common/middlewares/app-logger.middleware.
9
  import { DeviceInfoMiddleware } from './common/middlewares/device-info.middleware.js';
10
  import { UserModule } from './modules/user/user.module.js';
11
  import { BranchModule } from './modules/branch/branch.module.js';
12
- import { AuthenticationModule } from './modules/authentication/authentication.module';
13
- import {AccessControlModule, ACGuard} from 'nest-access-control'
14
- import { APP_GUARD } from '@nestjs/core';
15
-
16
  @Module({
17
  imports: [
18
  ConfigModule.forRoot({
@@ -26,6 +24,7 @@ import { APP_GUARD } from '@nestjs/core';
26
  UserModule,
27
  BranchModule,
28
  AuthenticationModule,
 
29
  ],
30
  controllers: [AppController],
31
  providers: [AppService],
 
9
  import { DeviceInfoMiddleware } from './common/middlewares/device-info.middleware.js';
10
  import { UserModule } from './modules/user/user.module.js';
11
  import { BranchModule } from './modules/branch/branch.module.js';
12
+ import { AuthenticationModule } from './modules/authentication/authentication.module.js';
13
+ import { MenuItemModule } from './modules/menu-item/menu-item.module.js';
 
 
14
  @Module({
15
  imports: [
16
  ConfigModule.forRoot({
 
24
  UserModule,
25
  BranchModule,
26
  AuthenticationModule,
27
+ MenuItemModule,
28
  ],
29
  controllers: [AppController],
30
  providers: [AppService],
backend/src/config/config.ts CHANGED
@@ -7,5 +7,6 @@ export const configuration = () => {
7
  'db.password': process.env.DB_PASSWORD,
8
  'db.name': process.env.DB_NAME,
9
  'db.slow_limit': Number(process.env.DB_SLOW_LIMIT) || 500, // ms
 
10
  };
11
  };
 
7
  'db.password': process.env.DB_PASSWORD,
8
  'db.name': process.env.DB_NAME,
9
  'db.slow_limit': Number(process.env.DB_SLOW_LIMIT) || 500, // ms
10
+ 'db.ssl_enabled': process.env.DB_SSL_ENABLED,
11
  };
12
  };
backend/src/config/database.ts CHANGED
@@ -13,6 +13,7 @@ export class DatabaseConfigService implements TypeOrmOptionsFactory {
13
  constructor(private readonly configService: ConfigService) {}
14
 
15
  createTypeOrmOptions(): TypeOrmModuleOptions {
 
16
  return {
17
  type: 'postgres',
18
  host: this.configService.get('db.host'),
@@ -21,9 +22,11 @@ export class DatabaseConfigService implements TypeOrmOptionsFactory {
21
  database: this.configService.get('db.name'),
22
  password: this.configService.get('db.password'),
23
  entities: [path.join(__dirname, '../**/*.entity{.ts,.js}')],
24
- ssl: {
25
- rejectUnauthorized: false,
26
- },
 
 
27
  maxQueryExecutionTime: this.configService.get('db.slow_limit'),
28
  };
29
  }
 
13
  constructor(private readonly configService: ConfigService) {}
14
 
15
  createTypeOrmOptions(): TypeOrmModuleOptions {
16
+ const isSslEnabled = this.configService.get('db.ssl_enabled') !== 'false';
17
  return {
18
  type: 'postgres',
19
  host: this.configService.get('db.host'),
 
22
  database: this.configService.get('db.name'),
23
  password: this.configService.get('db.password'),
24
  entities: [path.join(__dirname, '../**/*.entity{.ts,.js}')],
25
+ ssl: isSslEnabled
26
+ ? {
27
+ rejectUnauthorized: false,
28
+ }
29
+ : false,
30
  maxQueryExecutionTime: this.configService.get('db.slow_limit'),
31
  };
32
  }
backend/src/config/typeorm.ts CHANGED
@@ -9,6 +9,8 @@ const __dirname = path.dirname(__filename);
9
 
10
  const migrationsPath = 'src/migrations/*.ts';
11
 
 
 
12
  export default new DataSource({
13
  type: 'postgres',
14
  host: process.env.DB_HOST,
@@ -17,8 +19,10 @@ export default new DataSource({
17
  username: process.env.DB_USER,
18
  password: process.env.DB_PASSWORD,
19
  entities: [path.join(__dirname, '../**/*.entity{.ts,.js}')],
20
- ssl: {
21
- rejectUnauthorized: false,
22
- },
 
 
23
  migrations: [migrationsPath],
24
  });
 
9
 
10
  const migrationsPath = 'src/migrations/*.ts';
11
 
12
+ const isSslEnabled = process.env.DB_SSL_ENABLED !== 'false';
13
+
14
  export default new DataSource({
15
  type: 'postgres',
16
  host: process.env.DB_HOST,
 
19
  username: process.env.DB_USER,
20
  password: process.env.DB_PASSWORD,
21
  entities: [path.join(__dirname, '../**/*.entity{.ts,.js}')],
22
+ ssl: isSslEnabled
23
+ ? {
24
+ rejectUnauthorized: false,
25
+ }
26
+ : false,
27
  migrations: [migrationsPath],
28
  });
backend/src/entities/branch-menu.entity.ts ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ BaseEntity,
3
+ Column,
4
+ Entity,
5
+ ManyToOne,
6
+ OneToMany,
7
+ PrimaryGeneratedColumn,
8
+ Relation,
9
+ } from 'typeorm';
10
+ import { BranchEntity } from './branch.entity.js';
11
+ import { MenuItemEntity } from './menu-item.entity.js';
12
+
13
+ @Entity('branch_menu')
14
+ export class BranchMenuEntity extends BaseEntity {
15
+ @PrimaryGeneratedColumn('uuid')
16
+ id: string;
17
+
18
+ @Column()
19
+ branch_id: string;
20
+
21
+ @Column()
22
+ menu_id: string;
23
+
24
+ @Column()
25
+ description: string;
26
+
27
+ @Column()
28
+ is_open: boolean;
29
+
30
+ @ManyToOne(() => BranchEntity, (a) => a.menu_items)
31
+ branch: Relation<BranchEntity>;
32
+
33
+ @ManyToOne(() => MenuItemEntity, (a) => a.branch_menus)
34
+ menu_item: Relation<MenuItemEntity>;
35
+ }
backend/src/entities/branch.entity.ts CHANGED
@@ -3,10 +3,12 @@ import {
3
  Column,
4
  Entity,
5
  ManyToOne,
 
6
  PrimaryGeneratedColumn,
7
  Relation,
8
  } from 'typeorm';
9
  import { UserEntity } from './user.entity.js';
 
10
 
11
  @Entity('branches')
12
  export class BranchEntity extends BaseEntity {
@@ -25,6 +27,9 @@ export class BranchEntity extends BaseEntity {
25
  @ManyToOne(() => UserEntity, (user) => user.branches)
26
  owner: Relation<UserEntity>;
27
 
 
 
 
28
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
29
  create_at: Date;
30
  }
 
3
  Column,
4
  Entity,
5
  ManyToOne,
6
+ OneToMany,
7
  PrimaryGeneratedColumn,
8
  Relation,
9
  } from 'typeorm';
10
  import { UserEntity } from './user.entity.js';
11
+ import { BranchMenuEntity } from './branch-menu.entity.js';
12
 
13
  @Entity('branches')
14
  export class BranchEntity extends BaseEntity {
 
27
  @ManyToOne(() => UserEntity, (user) => user.branches)
28
  owner: Relation<UserEntity>;
29
 
30
+ @OneToMany(() => BranchMenuEntity, (a) => a.branch)
31
+ menu_items: Relation<BranchMenuEntity>[];
32
+
33
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
34
  create_at: Date;
35
  }
backend/src/entities/menu-item.entity.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ BaseEntity,
3
+ Column,
4
+ Entity,
5
+ ManyToOne,
6
+ OneToMany,
7
+ PrimaryColumn,
8
+ Relation,
9
+ } from 'typeorm';
10
+ import { BranchMenuEntity } from './branch-menu.entity.js';
11
+
12
+ @Entity('menu_items')
13
+ export class MenuItemEntity extends BaseEntity {
14
+ @PrimaryColumn()
15
+ id: string;
16
+
17
+ @Column()
18
+ item_name: string;
19
+
20
+ @Column({ nullable: true })
21
+ image_url: string;
22
+
23
+ @Column({ nullable: true })
24
+ item_group_id: string;
25
+
26
+ @Column()
27
+ description: string;
28
+
29
+ @Column()
30
+ price: number;
31
+
32
+ @OneToMany(() => BranchMenuEntity, (a) => a.menu_item)
33
+ branch_menus: Relation<BranchMenuEntity>[];
34
+
35
+ @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
36
+ create_at: Date;
37
+ }
backend/src/main.ts CHANGED
@@ -1,8 +1,10 @@
1
  import { NestFactory } from '@nestjs/core';
2
  import { AppModule } from './app.module.js';
 
3
 
4
  async function bootstrap() {
5
  const app = await NestFactory.create(AppModule, { cors: true });
 
6
  await app.listen(3000);
7
  }
8
  bootstrap();
 
1
  import { NestFactory } from '@nestjs/core';
2
  import { AppModule } from './app.module.js';
3
+ import { ValidationPipe } from '@nestjs/common';
4
 
5
  async function bootstrap() {
6
  const app = await NestFactory.create(AppModule, { cors: true });
7
+ app.useGlobalPipes(new ValidationPipe());
8
  await app.listen(3000);
9
  }
10
  bootstrap();
backend/src/migrations/1729703705445-AddBranchMenus.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class AddBranchMenus1729703705445 implements MigrationInterface {
4
+ name = 'AddBranchMenus1729703705445'
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`CREATE TABLE "menu_items" ("id" character varying NOT NULL, "item_name" character varying NOT NULL, "image_url" character varying, "item_group_id" character varying, "description" character varying NOT NULL, "price" integer NOT NULL, "create_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_57e6188f929e5dc6919168620c8" PRIMARY KEY ("id"))`);
8
+ await queryRunner.query(`CREATE TABLE "branch_menu" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "branch_id" character varying NOT NULL, "menu_id" character varying NOT NULL, "description" character varying NOT NULL, "is_open" boolean NOT NULL, "branchId" uuid, "menuItemId" character varying, CONSTRAINT "PK_977becffe98bbc626a56031b9e7" PRIMARY KEY ("id"))`);
9
+ await queryRunner.query(`ALTER TABLE "branch_menu" ADD CONSTRAINT "FK_e0c721a124fa03ea4cef6f28f42" FOREIGN KEY ("branchId") REFERENCES "branches"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
10
+ await queryRunner.query(`ALTER TABLE "branch_menu" ADD CONSTRAINT "FK_cbfb42df5887653593974e3e285" FOREIGN KEY ("menuItemId") REFERENCES "menu_items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
11
+ }
12
+
13
+ public async down(queryRunner: QueryRunner): Promise<void> {
14
+ await queryRunner.query(`ALTER TABLE "branch_menu" DROP CONSTRAINT "FK_cbfb42df5887653593974e3e285"`);
15
+ await queryRunner.query(`ALTER TABLE "branch_menu" DROP CONSTRAINT "FK_e0c721a124fa03ea4cef6f28f42"`);
16
+ await queryRunner.query(`DROP TABLE "branch_menu"`);
17
+ await queryRunner.query(`DROP TABLE "menu_items"`);
18
+ }
19
+
20
+ }
backend/src/modules/authentication/authentication.controller.spec.ts DELETED
@@ -1,20 +0,0 @@
1
- import { Test, TestingModule } from '@nestjs/testing';
2
- import { AuthenticationController } from './authentication.controller';
3
- import { AuthenticationService } from './authentication.service';
4
-
5
- describe('AuthenticationController', () => {
6
- let controller: AuthenticationController;
7
-
8
- beforeEach(async () => {
9
- const module: TestingModule = await Test.createTestingModule({
10
- controllers: [AuthenticationController],
11
- providers: [AuthenticationService],
12
- }).compile();
13
-
14
- controller = module.get<AuthenticationController>(AuthenticationController);
15
- });
16
-
17
- it('should be defined', () => {
18
- expect(controller).toBeDefined();
19
- });
20
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/src/modules/authentication/authentication.controller.ts CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import {
3
  Body,
4
  Controller,
@@ -7,12 +6,12 @@ import {
7
  HttpStatus,
8
  Post,
9
  Request,
10
- UseGuards
11
  } from '@nestjs/common';
12
  import { AuthenticationGuard } from './authentication.guard';
13
  import { AuthenticationService } from './authentication.service';
14
  import { Public } from './authentication.decorator';
15
  import { SignInDto } from './dto/sign-in.dto';
 
16
  @Controller('authentication')
17
  export class AuthenticationController {
18
  constructor(private AuthenticationService: AuthenticationService) {}
 
 
1
  import {
2
  Body,
3
  Controller,
 
6
  HttpStatus,
7
  Post,
8
  Request,
 
9
  } from '@nestjs/common';
10
  import { AuthenticationGuard } from './authentication.guard';
11
  import { AuthenticationService } from './authentication.service';
12
  import { Public } from './authentication.decorator';
13
  import { SignInDto } from './dto/sign-in.dto';
14
+
15
  @Controller('authentication')
16
  export class AuthenticationController {
17
  constructor(private AuthenticationService: AuthenticationService) {}
backend/src/modules/authentication/authentication.guard.ts CHANGED
@@ -1,49 +1,51 @@
1
-
2
  import {
3
- CanActivate,
4
- ExecutionContext,
5
- Injectable,
6
- UnauthorizedException,
7
- } from '@nestjs/common';
8
- import { JwtService } from '@nestjs/jwt';
9
- import { jwtConstants } from './constants';
10
- import { Request } from 'express';
11
- import { Reflector } from '@nestjs/core';
12
- import { IS_PUBLIC_KEY } from './authentication.decorator';
13
- @Injectable()
14
- export class AuthenticationGuard implements CanActivate {
15
- constructor(private jwtService: JwtService, private reflector: Reflector) {}
16
-
17
- async canActivate(context: ExecutionContext): Promise<boolean> {
18
- const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
19
- context.getHandler(),
20
- context.getClass(),
21
- ]);
22
- if (isPublic) {
23
- // 💡 See this condition
24
- return true;
25
- }
26
-
27
- const request = context.switchToHttp().getRequest();
28
- const token = this.extractTokenFromHeader(request);
29
- if (!token) {
30
- throw new UnauthorizedException();
31
- }
32
- try {
33
- const payload = await this.jwtService.verifyAsync(token, {
34
- secret: jwtConstants.secret,
35
- });
36
- // 💡 We're assigning the payload to the request object here
37
- // so that we can access it in our route handlers
38
- request['user'] = payload;
39
- } catch {
40
- throw new UnauthorizedException();
41
- }
42
  return true;
43
  }
44
-
45
- private extractTokenFromHeader(request: Request): string | undefined {
46
- const [type, token] = request.headers.authorization?.split(' ') ?? [];
47
- return type === 'Bearer' ? token : undefined;
 
48
  }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import {
2
+ CanActivate,
3
+ ExecutionContext,
4
+ Injectable,
5
+ UnauthorizedException,
6
+ } from '@nestjs/common';
7
+ import { JwtService } from '@nestjs/jwt';
8
+ import { jwtConstants } from './constants.js';
9
+ import { Request } from 'express';
10
+ import { Reflector } from '@nestjs/core';
11
+ import { IS_PUBLIC_KEY } from './authentication.decorator.js';
12
+ @Injectable()
13
+ export class AuthenticationGuard implements CanActivate {
14
+ constructor(
15
+ private jwtService: JwtService,
16
+ private reflector: Reflector,
17
+ ) {}
18
+
19
+ async canActivate(context: ExecutionContext): Promise<boolean> {
20
+ const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
21
+ context.getHandler(),
22
+ context.getClass(),
23
+ ]);
24
+ if (isPublic) {
25
+ // 💡 See this condition
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  return true;
27
  }
28
+
29
+ const request = context.switchToHttp().getRequest();
30
+ const token = this.extractTokenFromHeader(request);
31
+ if (!token) {
32
+ throw new UnauthorizedException();
33
  }
34
+ try {
35
+ const payload = await this.jwtService.verifyAsync(token, {
36
+ secret: jwtConstants.secret,
37
+ });
38
+ // 💡 We're assigning the payload to the request object here
39
+ // so that we can access it in our route handlers
40
+ request['user'] = payload;
41
+ } catch {
42
+ throw new UnauthorizedException();
43
+ }
44
+ return true;
45
+ }
46
+
47
+ private extractTokenFromHeader(request: Request): string | undefined {
48
+ const [type, token] = request.headers.authorization?.split(' ') ?? [];
49
+ return type === 'Bearer' ? token : undefined;
50
+ }
51
+ }
backend/src/modules/authentication/authentication.module.ts CHANGED
@@ -1,11 +1,10 @@
1
-
2
  import { Module } from '@nestjs/common';
3
- import { AuthenticationService } from './authentication.service';
4
- import { UserModule } from '../user/user.module';
5
  import { JwtModule } from '@nestjs/jwt';
6
- import { AuthenticationController } from './authentication.controller';
7
- import { jwtConstants } from './constants';
8
- import { AuthenticationGuard } from './authentication.guard';
9
  import { APP_GUARD } from '@nestjs/core';
10
  @Module({
11
  imports: [
@@ -21,7 +20,7 @@ import { APP_GUARD } from '@nestjs/core';
21
  {
22
  provide: APP_GUARD,
23
  useClass: AuthenticationGuard,
24
- }
25
  ],
26
  controllers: [AuthenticationController],
27
  exports: [AuthenticationService],
 
 
1
  import { Module } from '@nestjs/common';
2
+ import { AuthenticationService } from './authentication.service.js';
3
+ import { UserModule } from '../user/user.module.js';
4
  import { JwtModule } from '@nestjs/jwt';
5
+ import { AuthenticationController } from './authentication.controller.js';
6
+ import { jwtConstants } from './constants.js';
7
+ import { AuthenticationGuard } from './authentication.guard.js';
8
  import { APP_GUARD } from '@nestjs/core';
9
  @Module({
10
  imports: [
 
20
  {
21
  provide: APP_GUARD,
22
  useClass: AuthenticationGuard,
23
+ },
24
  ],
25
  controllers: [AuthenticationController],
26
  exports: [AuthenticationService],
backend/src/modules/authentication/authentication.service.spec.ts DELETED
@@ -1,18 +0,0 @@
1
- import { Test, TestingModule } from '@nestjs/testing';
2
- import { AuthenticationService } from './authentication.service';
3
-
4
- describe('AuthenticationService', () => {
5
- let service: AuthenticationService;
6
-
7
- beforeEach(async () => {
8
- const module: TestingModule = await Test.createTestingModule({
9
- providers: [AuthenticationService],
10
- }).compile();
11
-
12
- service = module.get<AuthenticationService>(AuthenticationService);
13
- });
14
-
15
- it('should be defined', () => {
16
- expect(service).toBeDefined();
17
- });
18
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/src/modules/authentication/authentication.service.ts CHANGED
@@ -1,23 +1,23 @@
1
-
2
  import { Injectable, UnauthorizedException } from '@nestjs/common';
3
- import { UserService } from '../user/user.service';
4
  import * as bcrypt from 'bcrypt';
5
  import { JwtService } from '@nestjs/jwt';
6
  @Injectable()
7
  export class AuthenticationService {
8
  constructor(
9
  private usersService: UserService,
10
- private jwtService: JwtService
11
  ) {}
12
 
13
- async signIn(username: string, pass: string): Promise<{access_token: string}> {
 
 
 
14
  const user = await this.usersService.findOne(username);
15
- if (!user || await !bcrypt.compare(pass, user.hash_password)) {
16
  throw new UnauthorizedException();
17
  }
18
  const payload = { sub: user.id, username: user.id };
19
- // TODO: Generate a JWT and return it here
20
- // instead of the user object
21
  return {
22
  access_token: await this.jwtService.signAsync(payload),
23
  };
 
 
1
  import { Injectable, UnauthorizedException } from '@nestjs/common';
2
+ import { UserService } from '../user/user.service.js';
3
  import * as bcrypt from 'bcrypt';
4
  import { JwtService } from '@nestjs/jwt';
5
  @Injectable()
6
  export class AuthenticationService {
7
  constructor(
8
  private usersService: UserService,
9
+ private jwtService: JwtService,
10
  ) {}
11
 
12
+ async signIn(
13
+ username: string,
14
+ pass: string,
15
+ ): Promise<{ access_token: string }> {
16
  const user = await this.usersService.findOne(username);
17
+ if (!user || (await !bcrypt.compare(pass, user.hash_password))) {
18
  throw new UnauthorizedException();
19
  }
20
  const payload = { sub: user.id, username: user.id };
 
 
21
  return {
22
  access_token: await this.jwtService.signAsync(payload),
23
  };
backend/src/modules/menu-item/dto/create-menu-item.dto.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IsNumber, IsOptional, IsString, IsUrl } from 'class-validator';
2
+
3
+ export class CreateMenuItemDto {
4
+ @IsString()
5
+ id: string;
6
+
7
+ @IsString()
8
+ item_name: string;
9
+
10
+ @IsUrl()
11
+ image_url: string;
12
+
13
+ @IsString()
14
+ @IsOptional()
15
+ item_group_id?: string;
16
+
17
+ @IsString()
18
+ @IsOptional()
19
+ description?: string;
20
+
21
+ @IsNumber()
22
+ price: number;
23
+ }
backend/src/modules/menu-item/dto/update-menu-item.dto.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { IsNumber, IsOptional, IsString, IsUrl } from 'class-validator';
2
+
3
+ export class UpdateMenuItemDto {
4
+ @IsString()
5
+ @IsOptional()
6
+ item_name: string;
7
+
8
+ @IsUrl()
9
+ @IsOptional()
10
+ image_url: string;
11
+
12
+ @IsString()
13
+ @IsOptional()
14
+ item_group_id?: string;
15
+
16
+ @IsString()
17
+ @IsOptional()
18
+ description?: string;
19
+
20
+ @IsNumber()
21
+ @IsOptional()
22
+ price: number;
23
+ }
backend/src/modules/menu-item/menu-item.controller.ts ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ Controller,
3
+ Get,
4
+ Post,
5
+ Body,
6
+ Patch,
7
+ Param,
8
+ Delete,
9
+ } from '@nestjs/common';
10
+ import { MenuItemService } from './menu-item.service.js';
11
+ import { CreateMenuItemDto } from './dto/create-menu-item.dto.js';
12
+ import { UpdateMenuItemDto } from './dto/update-menu-item.dto.js';
13
+ import { Public } from '../authentication/authentication.decorator.js';
14
+
15
+ @Public()
16
+ @Controller('menu-items')
17
+ export class MenuItemController {
18
+ constructor(private readonly menuItemService: MenuItemService) {}
19
+
20
+ @Post()
21
+ async create(@Body() createMenuItemDto: CreateMenuItemDto) {
22
+ return this.menuItemService.create(createMenuItemDto);
23
+ }
24
+
25
+ @Get()
26
+ async findAll() {
27
+ return this.menuItemService.findAll();
28
+ }
29
+
30
+ @Get(':id')
31
+ async findOne(@Param('id') id: string) {
32
+ return this.menuItemService.findOne(id);
33
+ }
34
+
35
+ @Patch(':id')
36
+ async update(
37
+ @Param('id') id: string,
38
+ @Body() updateMenuItemDto: UpdateMenuItemDto,
39
+ ) {
40
+ return this.menuItemService.update(id, updateMenuItemDto);
41
+ }
42
+
43
+ @Delete(':id')
44
+ remove(@Param('id') id: string) {
45
+ return this.menuItemService.remove(id);
46
+ }
47
+ }
backend/src/modules/menu-item/menu-item.module.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import { Module } from '@nestjs/common';
2
+ import { MenuItemService } from './menu-item.service.js';
3
+ import { MenuItemController } from './menu-item.controller.js';
4
+
5
+ @Module({
6
+ controllers: [MenuItemController],
7
+ providers: [MenuItemService],
8
+ })
9
+ export class MenuItemModule {}
backend/src/modules/menu-item/menu-item.service.ts ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Injectable, NotFoundException } from '@nestjs/common';
2
+ import { CreateMenuItemDto } from './dto/create-menu-item.dto.js';
3
+ import { UpdateMenuItemDto } from './dto/update-menu-item.dto.js';
4
+ import { MenuItemEntity } from '../../entities/menu-item.entity.js';
5
+ import { Public } from '../authentication/authentication.decorator.js';
6
+ import { plainToClass } from 'class-transformer';
7
+
8
+ @Public()
9
+ @Injectable()
10
+ export class MenuItemService {
11
+ async create(createMenuItemDto: CreateMenuItemDto) {
12
+ return await MenuItemEntity.create({ ...createMenuItemDto }).save();
13
+ }
14
+
15
+ async findAll() {
16
+ return await MenuItemEntity.find();
17
+ }
18
+
19
+ async findOne(id: string) {
20
+ return await MenuItemEntity.findOneBy({ id: id });
21
+ }
22
+
23
+ async getMenuItemOrError(id: string) {
24
+ let menuItem = await MenuItemEntity.findOneBy({ id });
25
+ if (!menuItem) {
26
+ throw new NotFoundException('Menu item not found');
27
+ }
28
+ return menuItem;
29
+ }
30
+
31
+ async update(id: string, updateMenuItemDto: UpdateMenuItemDto) {
32
+ let menuItem = await this.getMenuItemOrError(id);
33
+ menuItem = plainToClass(MenuItemEntity, {
34
+ ...menuItem,
35
+ ...updateMenuItemDto,
36
+ });
37
+ return await menuItem.save();
38
+ }
39
+
40
+ async remove(id: string) {
41
+ let menuItem = await this.getMenuItemOrError(id);
42
+ return await menuItem.remove();
43
+ }
44
+ }
backend/src/modules/user/user.controller.ts CHANGED
@@ -1,13 +1,15 @@
1
  import { Controller, Get, Param } from '@nestjs/common';
2
- import { UserService } from './user.service';
3
- import { UserEntity } from 'src/entities/user.entity';
4
 
5
  @Controller('users')
6
  export class UsersController {
7
  constructor(private readonly usersService: UserService) {}
8
 
9
  @Get(':username')
10
- async getUser(@Param('username') username: string): Promise<UserEntity | undefined> {
 
 
11
  return this.usersService.findOne(username);
12
  }
13
  }
 
1
  import { Controller, Get, Param } from '@nestjs/common';
2
+ import { UserService } from './user.service.js';
3
+ import { UserEntity } from 'src/entities/user.entity.js';
4
 
5
  @Controller('users')
6
  export class UsersController {
7
  constructor(private readonly usersService: UserService) {}
8
 
9
  @Get(':username')
10
+ async getUser(
11
+ @Param('username') username: string,
12
+ ): Promise<UserEntity | undefined> {
13
  return this.usersService.findOne(username);
14
  }
15
  }
backend/src/modules/user/user.module.ts CHANGED
@@ -1,5 +1,5 @@
1
  import { Module } from '@nestjs/common';
2
- import { UserService } from './user.service';
3
 
4
  @Module({
5
  providers: [UserService],
 
1
  import { Module } from '@nestjs/common';
2
+ import { UserService } from './user.service.js';
3
 
4
  @Module({
5
  providers: [UserService],
backend/src/modules/user/user.service.ts CHANGED
@@ -1,18 +1,15 @@
1
  import { Injectable } from '@nestjs/common';
2
  import { InjectRepository } from '@nestjs/typeorm';
3
  import { Repository } from 'typeorm';
4
- import { UserEntity } from 'src/entities/user.entity'
5
- // This should be a real class/interface representing a user entity
6
  export type User = any;
7
 
8
  @Injectable()
9
  export class UserService {
10
- constructor(
11
- @InjectRepository(UserEntity)
12
- private usersRepository: Repository<UserEntity>,
13
- ) {}
14
 
15
  async findOne(username: string): Promise<UserEntity | undefined> {
16
- return this.usersRepository.findOne({ where: { id: username } });
17
  }
18
  }
 
1
  import { Injectable } from '@nestjs/common';
2
  import { InjectRepository } from '@nestjs/typeorm';
3
  import { Repository } from 'typeorm';
4
+ import { UserEntity } from '../../entities/user.entity.js';
5
+
6
  export type User = any;
7
 
8
  @Injectable()
9
  export class UserService {
10
+ constructor() {}
 
 
 
11
 
12
  async findOne(username: string): Promise<UserEntity | undefined> {
13
+ return UserEntity.findOne({ where: { id: username } });
14
  }
15
  }
frontend/.gitignore ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # production
12
+ /build
13
+
14
+ # misc
15
+ .DS_Store
16
+ .env.local
17
+ .env.development.local
18
+ .env.test.local
19
+ .env.production.local
20
+
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
frontend/README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+ ### Advanced Configuration
61
+
62
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71
+
72
+ # Development rules
73
+
74
+ ## Paradigm
75
+ This project follow atomic design paradigm, which includes 5 level of components: atoms, molecules, organisms, templates and pages. Each level is stored in a specific folder.
76
+
77
+ The components maybe developed using React-Bootstrap atoms, or wrapper of React-Bootstrap
78
+
79
+ Current components including (will be update gradually):
80
+
81
+ ### Atoms:
82
+ - ButtonWrapper
83
+ - CardWrapper
84
+
85
+ ### Molecules:
86
+ - Navbar
87
+ - AboutUsSection
88
+ - NewsItem
89
+
90
+ ### Organisms:
91
+ - NewsSection <- NewsItem
92
+ - MenuSection (not yet)
93
+ - StoreSection (not yet)
94
+
95
+ ### Templates:
96
+
97
+ ### Pages:
98
+ - HomePage
99
+
100
+ ## Other folders:
101
+ - Static assets like images, icons, are stored in public folder.
102
+ - Extra styles are located in styles/styles.css
103
+
104
+ *Currently I have no idea how to import from assets folder
frontend/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
frontend/package.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "test-app",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@testing-library/jest-dom": "^5.17.0",
7
+ "@testing-library/react": "^13.4.0",
8
+ "@testing-library/user-event": "^13.5.0",
9
+ "bootstrap": "^5.3.3",
10
+ "react": "^18.3.1",
11
+ "react-bootstrap": "^2.10.5",
12
+ "react-dom": "^18.3.1",
13
+ "react-router-dom": "^6.27.0",
14
+ "react-scripts": "5.0.1",
15
+ "web-vitals": "^2.1.4"
16
+ },
17
+ "scripts": {
18
+ "start": "react-scripts start",
19
+ "build": "react-scripts build",
20
+ "test": "react-scripts test",
21
+ "eject": "react-scripts eject"
22
+ },
23
+ "eslintConfig": {
24
+ "extends": [
25
+ "react-app",
26
+ "react-app/jest"
27
+ ]
28
+ },
29
+ "browserslist": {
30
+ "production": [
31
+ ">0.2%",
32
+ "not dead",
33
+ "not op_mini all"
34
+ ],
35
+ "development": [
36
+ "last 1 chrome version",
37
+ "last 1 firefox version",
38
+ "last 1 safari version"
39
+ ]
40
+ }
41
+ }
frontend/public/cats-logo.png ADDED
frontend/public/favicon.ico ADDED
frontend/public/index.html ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
frontend/public/logo.svg ADDED
frontend/public/logo192.png ADDED
frontend/public/logo512.png ADDED
frontend/public/manifest.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
frontend/public/placeholder1.jpg ADDED
frontend/public/placeholder2.jpg ADDED
frontend/public/placeholder3.jpg ADDED
frontend/public/placeholder4.jpg ADDED
frontend/public/robots.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
frontend/src/App.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
3
+ import HomePage from './pages/HomePage';
4
+ import './styles/App.css';
5
+ // index.js hoặc App.js
6
+ import 'bootstrap/dist/css/bootstrap.min.css';
7
+
8
+
9
+ function App() {
10
+ return (
11
+ <Router>
12
+ <Routes>
13
+ {/* Định tuyến trang chủ */}
14
+ <Route path="/" element={<HomePage />} />
15
+ {/* Có thể thêm các route khác nếu cần */}
16
+ </Routes>
17
+ </Router>
18
+ );
19
+ }
20
+
21
+ export default App;
22
+
frontend/src/App.test.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { render, screen } from '@testing-library/react';
2
+ import App from './App';
3
+
4
+ test('renders learn react link', () => {
5
+ render(<App />);
6
+ const linkElement = screen.getByText(/learn react/i);
7
+ expect(linkElement).toBeInTheDocument();
8
+ });
frontend/src/atoms/ButtonWrapper.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Button from bootstrap;
2
+
3
+ export default function ButtonWrapper ( {variant, text, trigger} ) {
4
+ return (
5
+ <Button
6
+ variant={variant}
7
+ onClick={trigger}
8
+ >
9
+ {text}
10
+ </Button>
11
+ )
12
+ }
frontend/src/atoms/CardWrapper.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Button from 'react-bootstrap/Button';
2
+ import Card from 'react-bootstrap/Card';
3
+
4
+ function CardWrapper( {title = "", text = "", imageSrc = "", btnText = "", btnHref = ""} ) {
5
+ return (
6
+ <Card style={{ width: '18rem' }}>
7
+ <Card.Img variant="top" src={imageSrc} />
8
+ <Card.Body>
9
+ <Card.Title>{title}</Card.Title>
10
+ <Card.Text>
11
+ {text}
12
+ </Card.Text>
13
+ <Button as="a" variant="primary" href={btnHref}>{btnText}</Button>
14
+ </Card.Body>
15
+ </Card>
16
+ );
17
+ }
18
+
19
+ export default CardWrapper;
frontend/src/index.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import './styles/index.css';
4
+ import App from './App';
5
+ import reportWebVitals from './reportWebVitals';
6
+
7
+ const root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(
9
+ <React.StrictMode>
10
+ <App />
11
+ </React.StrictMode>
12
+ );
13
+
14
+ // If you want to start measuring performance in your app, pass a function
15
+ // to log results (for example: reportWebVitals(console.log))
16
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
+ reportWebVitals();
frontend/src/molecules/AboutUsSection.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Container, Row, Col } from "react-bootstrap";
2
+
3
+ export default function AboutUsSection () {
4
+ return (<>
5
+ <Container id="about-us">
6
+ <h1 className="my-4">CATS Shop
7
+ <small> - We code for fun </small>
8
+ </h1>
9
+
10
+ <Row className="align-items-center">
11
+ <Col md={8}>
12
+ <img className="img-fluid" src="/cats-logo.png" alt="" style={{width: "100%", height: "auto"}}></img>
13
+ </Col>
14
+
15
+ <Col md={4} className="d-flex justify-content-center align-items-center">
16
+ Chào mừng mọi người đến với Cats Shop, phương châm của chúng tôi là code at the sink and sleep at the sea.
17
+ </Col>
18
+ </Row>
19
+ </Container>
20
+ </>)
21
+ }