Skip to content

Commit 68b4c1e

Browse files
feat: Initialize new Angular frontend application with core structure, pages, and components.
1 parent c1ae32c commit 68b4c1e

64 files changed

Lines changed: 979 additions & 656 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/src/app.component.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
2-
import { Component, ChangeDetectionStrategy, inject, OnInit } from '@angular/core';
3-
import { RouterOutlet } from '@angular/router';
4-
import { AuthService } from './shared/services/auth.service';
5-
import { TelegramService } from './shared/services/telegram.service';
6-
import { CommonModule } from '@angular/common';
7-
import { GlobalErrorComponent } from './shared/ui/global-error/global-error.component';
1+
import {
2+
Component,
3+
ChangeDetectionStrategy,
4+
inject,
5+
OnInit,
6+
} from "@angular/core";
7+
import { RouterOutlet } from "@angular/router";
8+
import { CommonModule } from "@angular/common";
9+
import { AuthService } from "@shared/services";
10+
import { TelegramService } from "@shared/services";
11+
import { GlobalErrorComponent } from "@shared/ui";
812

913
@Component({
10-
selector: 'app-root',
14+
selector: "app-root",
1115
imports: [CommonModule, RouterOutlet, GlobalErrorComponent],
1216
changeDetection: ChangeDetectionStrategy.OnPush,
13-
templateUrl: './app.component.html',
14-
styleUrls: ['./app.component.scss']
17+
templateUrl: "./app.component.html",
18+
styleUrls: ["./app.component.scss"],
1519
})
1620
export class AppComponent implements OnInit {
1721
public authService = inject(AuthService);
@@ -20,7 +24,7 @@ export class AppComponent implements OnInit {
2024
ngOnInit() {
2125
this.telegramService.ready();
2226
this.telegramService.expand();
23-
27+
2428
// Delegate auth logic to the comprehensive AuthService
2529
this.authService.checkTelegramAuth();
2630
}

frontend/src/app.routes.ts

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,86 @@
1-
2-
import { Routes } from '@angular/router';
3-
import { AboutComponent } from './pages/about/about.component';
4-
import { AuthComponent } from './pages/auth/auth.component';
5-
import { DashboardComponent } from './pages/dashboard/dashboard.component';
6-
import { GalleryComponent } from './pages/gallery/gallery.component';
7-
import { PortfolioPageComponent } from './pages/portfolio/portfolio.component';
8-
import { ServicesCatalogComponent } from './pages/services-catalog/services-catalog.component';
9-
import { ServicesPageComponent } from './pages/services/services.component';
10-
import { SettingsComponent } from './pages/settings/settings.component';
11-
import { UserHomeComponent } from './pages/user-home/user-home.component';
12-
import { UserProfileComponent } from './pages/user-profile/user-profile.component';
13-
import { VeilPageComponent } from './pages/veil/veil.component';
14-
import { VeilsCatalogComponent } from './pages/veils-catalog/veils-catalog.component';
15-
import { AdminLayoutComponent } from './widgets/layouts/admin-layout.component';
16-
import { UserLayoutComponent } from './widgets/layouts/user-layout.component';
17-
import { adminGuard } from './app/core/guards/admin.guard';
1+
import { Routes } from "@angular/router";
2+
import { AboutComponent } from "@pages/about";
3+
import { AuthComponent } from "@pages/auth";
4+
import { DashboardComponent } from "@pages/dashboard";
5+
import { GalleryComponent } from "@pages/gallery";
6+
import { PortfolioPageComponent } from "@pages/portfolio";
7+
import { ServicesCatalogComponent } from "@pages/services-catalog";
8+
import { ServicesPageComponent } from "@pages/services";
9+
import { SettingsComponent } from "@pages/settings";
10+
import { UserHomeComponent } from "@pages/user-home";
11+
import { UserProfileComponent } from "@pages/user-profile";
12+
import { VeilPageComponent } from "@pages/veil";
13+
import { VeilsCatalogComponent } from "@pages/veils-catalog";
14+
import { AdminLayoutComponent } from "@widgets/layouts";
15+
import { UserLayoutComponent } from "@widgets/layouts";
16+
import { adminGuard } from "@core/guards";
1817

1918
export const routes: Routes = [
20-
{ path: '', redirectTo: 'user/home', pathMatch: 'full' },
21-
{ path: 'auth', component: AuthComponent },
22-
19+
{ path: "", redirectTo: "user/home", pathMatch: "full" },
20+
{ path: "auth", component: AuthComponent },
21+
2322
// Admin Routes
24-
{
25-
path: 'admin',
23+
{
24+
path: "admin",
2625
component: AdminLayoutComponent,
2726
// canActivate: [adminGuard],
2827
children: [
29-
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
30-
{ path: 'dashboard', loadComponent: () => import('./pages/dashboard/dashboard.component').then(m => m.DashboardComponent) },
31-
{ path: 'veil', component: VeilPageComponent },
32-
{ path: 'services', component: ServicesPageComponent },
33-
{ path: 'clients', component: DashboardComponent },
34-
{ path: 'gallery', component: GalleryComponent },
35-
{ path: 'settings', component: SettingsComponent },
36-
]
28+
{ path: "", redirectTo: "dashboard", pathMatch: "full" },
29+
{
30+
path: "dashboard",
31+
loadComponent: () =>
32+
import("./pages/dashboard/dashboard.component").then(
33+
(m) => m.DashboardComponent,
34+
),
35+
},
36+
{ path: "veil", component: VeilPageComponent },
37+
{ path: "services", component: ServicesPageComponent },
38+
{ path: "clients", component: DashboardComponent },
39+
{ path: "gallery", component: GalleryComponent },
40+
{ path: "settings", component: SettingsComponent },
41+
],
3742
},
3843

3944
// User Routes
4045
{
41-
path: 'user',
46+
path: "user",
4247
component: UserLayoutComponent,
4348
children: [
44-
{ path: '', redirectTo: 'home', pathMatch: 'full' },
45-
{ path: 'home', loadComponent: () => import('./pages/user-home/user-home.component').then(m => m.UserHomeComponent) },
46-
{ path: 'collection', loadComponent: () => import('./pages/veils-catalog/veils-catalog.component').then(m => m.VeilsCatalogComponent) },
47-
{ path: 'services', loadComponent: () => import('./pages/services-catalog/services-catalog.component').then(m => m.ServicesCatalogComponent) },
48-
{ path: 'portfolio', loadComponent: () => import('./pages/portfolio/portfolio.component').then(m => m.PortfolioPageComponent) },
49-
{ path: 'about', loadComponent: () => import('./pages/about/about.component').then(m => m.AboutComponent) },
50-
{ path: 'profile', loadComponent: () => import('./pages/user-profile/user-profile.component').then(m => m.UserProfileComponent) }
51-
]
49+
{ path: "", redirectTo: "home", pathMatch: "full" },
50+
{
51+
path: "home",
52+
loadComponent: () =>
53+
import("@pages/user-home").then((m) => m.UserHomeComponent),
54+
},
55+
{
56+
path: "collection",
57+
loadComponent: () =>
58+
import("@pages/veils-catalog").then((m) => m.VeilsCatalogComponent),
59+
},
60+
{
61+
path: "services",
62+
loadComponent: () =>
63+
import("@pages/services-catalog").then(
64+
(m) => m.ServicesCatalogComponent,
65+
),
66+
},
67+
{
68+
path: "portfolio",
69+
loadComponent: () =>
70+
import("@pages/portfolio").then((m) => m.PortfolioPageComponent),
71+
},
72+
{
73+
path: "about",
74+
loadComponent: () =>
75+
import("@pages/about").then((m) => m.AboutComponent),
76+
},
77+
{
78+
path: "profile",
79+
loadComponent: () =>
80+
import("@pages/user-profile").then((m) => m.UserProfileComponent),
81+
},
82+
],
5283
},
5384

54-
{ path: '**', redirectTo: 'user/home' }
85+
{ path: "**", redirectTo: "user/home" },
5586
];

frontend/src/app/app.config.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
import { ApplicationConfig, provideZonelessChangeDetection } from '@angular/core';
2-
import { provideAnimations } from '@angular/platform-browser/animations';
3-
import { provideRouter, withHashLocation } from '@angular/router';
4-
import { routes } from '@src/app.routes';
5-
import { provideHttpClient, withFetch, withInterceptors } from '@angular/common/http';
6-
import { apiInterceptor } from './core/interceptors/api.interceptor';
7-
import { errorInterceptor } from './core/interceptors/error.interceptor';
1+
import {
2+
ApplicationConfig,
3+
provideZonelessChangeDetection,
4+
} from "@angular/core";
5+
import { provideAnimations } from "@angular/platform-browser/animations";
6+
import { provideRouter, withHashLocation } from "@angular/router";
7+
import { routes } from "@src/app.routes";
8+
import {
9+
provideHttpClient,
10+
withFetch,
11+
withInterceptors,
12+
} from "@angular/common/http";
13+
import { apiInterceptor, errorInterceptor } from "@core/interceptors";
814

915
export const appConfig: ApplicationConfig = {
1016
providers: [
1117
provideZonelessChangeDetection(),
1218
provideAnimations(),
1319
provideRouter(routes, withHashLocation()),
14-
provideHttpClient(withFetch(), withInterceptors([apiInterceptor, errorInterceptor])),
20+
provideHttpClient(
21+
withFetch(),
22+
withInterceptors([apiInterceptor, errorInterceptor]),
23+
),
1524
],
1625
};

frontend/src/app/core/guards/auth.guard.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

frontend/src/app/core/interceptors/error.interceptor.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

frontend/src/backend/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./telegram-auth.guard";
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { inject } from '@angular/core';
2-
import { CanActivateFn, Router } from '@angular/router';
3-
import { AuthService } from '@entities/user/auth.service';
1+
import { inject } from "@angular/core";
2+
import { CanActivateFn, Router } from "@angular/router";
3+
import { AuthService } from "@entities/user";
44

55
export const adminGuard: CanActivateFn = (route, state) => {
66
const authService = inject(AuthService);
@@ -9,11 +9,11 @@ export const adminGuard: CanActivateFn = (route, state) => {
99
if (authService.isLoggedIn() && authService.isAdmin()) {
1010
return true;
1111
}
12-
12+
1313
// If logged in but not admin, redirect to home or forbidden
1414
if (authService.isLoggedIn()) {
15-
return router.createUrlTree(['/']);
15+
return router.createUrlTree(["/"]);
1616
}
1717

18-
return router.createUrlTree(['/auth/login']);
18+
return router.createUrlTree(["/auth/login"]);
1919
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { inject } from "@angular/core";
2+
import { CanActivateFn, Router } from "@angular/router";
3+
import { AuthService } from "@entities/user";
4+
5+
export const authGuard: CanActivateFn = (route, state) => {
6+
const authService = inject(AuthService);
7+
const router = inject(Router);
8+
9+
if (authService.isLoggedIn()) {
10+
return true;
11+
}
12+
13+
return router.createUrlTree(["/auth/login"]);
14+
};

frontend/src/core/guards/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./admin.guard";
2+
export * from "./auth.guard";
File renamed without changes.

0 commit comments

Comments
 (0)