Skip to content

Commit f4592b4

Browse files
feat: Implement initial backend and frontend infrastructure for Veil and Treatments entities, including repositories, services, components, and API integration.
1 parent 098eeec commit f4592b4

5 files changed

Lines changed: 627 additions & 249 deletions

File tree

frontend/src/app.routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const routes: Routes = [
2424
import("@pages/veil").then((m) => m.VeilPageComponent),
2525
},
2626
{
27-
path: "services",
27+
path: "treatments",
2828
loadComponent: () =>
2929
import("@pages/treatments").then((m) => m.ServicesPageComponent),
3030
},
@@ -63,7 +63,7 @@ export const routes: Routes = [
6363
import("@pages/veils-catalog").then((m) => m.VeilsCatalogComponent),
6464
},
6565
{
66-
path: "services",
66+
path: "treatments",
6767
loadComponent: () =>
6868
import("@pages/services-catalog").then(
6969
(m) => m.ServicesCatalogComponent,

frontend/src/features/treatments/model/treatments.data.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { required } from "@angular/forms/signals";
2+
13
export interface Treatment {
24
id: string;
35
name: string;
@@ -7,4 +9,38 @@ export interface Treatment {
79
image: string;
810
createdAt: string;
911
updatedAt: string;
12+
active: boolean;
13+
}
14+
15+
export const resetTreatmentData = {
16+
id: "",
17+
name: "",
18+
description: "",
19+
price: 0,
20+
duration: 0,
21+
image: "",
22+
createdAt: "",
23+
updatedAt: "",
24+
active: true,
25+
};
26+
27+
export function treatmentsValidationSchema(schemaPath) {
28+
required(schemaPath.name, {
29+
message: $localize`@@treatmentNameRequiredMessage: Name is required`,
30+
});
31+
required(schemaPath.description, {
32+
message: $localize`@@treatmentDescriptionRequiredMessage: Description is required`,
33+
});
34+
required(schemaPath.price, {
35+
message: $localize`@@treatmentPriceRequiredMessage: Price is required`,
36+
});
37+
required(schemaPath.duration, {
38+
message: $localize`@@treatmentDurationRequiredMessage: Duration is required`,
39+
});
40+
required(schemaPath.image, {
41+
message: $localize`@@treatmentImageRequiredMessage: Image is required`,
42+
});
43+
required(schemaPath.active, {
44+
message: $localize`@@treatmentActiveRequiredMessage: Active is required`,
45+
});
1046
}

frontend/src/pages/treatments/treatments.component.ts

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { CommonModule } from "@angular/common";
88
import { FormsModule } from "@angular/forms";
99

10-
interface ServiceItem {
10+
interface TreatmentItem {
1111
id: number;
1212
name: string;
1313
category: string;
@@ -17,56 +17,15 @@ interface ServiceItem {
1717
}
1818

1919
@Component({
20-
selector: "app-services-page",
20+
selector: "app-treatments-page",
2121
standalone: true,
2222
imports: [CommonModule, FormsModule],
2323
changeDetection: ChangeDetectionStrategy.OnPush,
2424
templateUrl: "./treatments.component.html",
2525
styleUrls: ["./treatments.component.scss"],
2626
})
2727
export class ServicesPageComponent {
28-
services = signal<ServiceItem[]>([
29-
{
30-
id: 1,
31-
name: $localize`:@@serviceBotox:Botox Treatment`,
32-
category: $localize`:@@catInjectables:Injectables`,
33-
price: 350,
34-
duration: $localize`:@@duration30:30 min`,
35-
active: true,
36-
},
37-
{
38-
id: 2,
39-
name: $localize`:@@serviceGoldFacial:Luxury Gold Facial`,
40-
category: $localize`:@@catFacials:Facials`,
41-
price: 180,
42-
duration: $localize`:@@duration60:60 min`,
43-
active: true,
44-
},
45-
{
46-
id: 3,
47-
name: $localize`:@@serviceLaserBody:Laser Hair Removal (Full Body)`,
48-
category: $localize`:@@catLaser:Laser`,
49-
price: 400,
50-
duration: $localize`:@@duration90:90 min`,
51-
active: true,
52-
},
53-
{
54-
id: 4,
55-
name: $localize`:@@serviceLipFillers:Lip Fillers (Juvederm)`,
56-
category: $localize`:@@catInjectables:Injectables`,
57-
price: 600,
58-
duration: $localize`:@@duration45:45 min`,
59-
active: true,
60-
},
61-
{
62-
id: 5,
63-
name: $localize`:@@serviceChemicalPeel:Chemical Peel`,
64-
category: $localize`:@@catFacials:Facials`,
65-
price: 120,
66-
duration: $localize`:@@duration30:30 min`,
67-
active: false,
68-
},
69-
]);
28+
treatments = signal<TreatmentItem[]>([]);
7029

7130
filters = [
7231
$localize`:@@filterAll:All`,
@@ -79,13 +38,13 @@ export class ServicesPageComponent {
7938

8039
filteredServices = computed(() => {
8140
const filter = this.activeFilter();
82-
const all = this.services();
41+
const all = this.treatments();
8342
if (filter === "All") return all;
8443
return all.filter((s) => s.category === filter);
8544
});
8645

8746
isEditModalOpen = signal(false);
88-
tempService: ServiceItem = {
47+
tempService: TreatmentItem = {
8948
id: 0,
9049
name: "",
9150
category: "Injectables",
@@ -110,7 +69,7 @@ export class ServicesPageComponent {
11069
this.isEditModalOpen.set(true);
11170
}
11271

113-
openEditModal(service: ServiceItem) {
72+
openEditModal(service: TreatmentItem) {
11473
this.tempService = { ...service };
11574
this.isEditModalOpen.set(true);
11675
}
@@ -122,23 +81,23 @@ export class ServicesPageComponent {
12281
deleteService(id: number) {
12382
if (
12483
confirm(
125-
$localize`:@@servicesConfirmDelete:Are you sure you want to delete this service?`,
84+
$localize`:@@treatmentsConfirmDelete:Are you sure you want to delete this service?`,
12685
)
12786
) {
128-
this.services.update((items) => items.filter((item) => item.id !== id));
87+
this.treatments.update((items) => items.filter((item) => item.id !== id));
12988
}
13089
}
13190

13291
saveEdit() {
13392
if (this.tempService.id === 0) {
13493
const newId =
135-
this.services().length > 0
136-
? Math.max(...this.services().map((s) => s.id)) + 1
94+
this.treatments().length > 0
95+
? Math.max(...this.treatments().map((s) => s.id)) + 1
13796
: 1;
13897
const newService = { ...this.tempService, id: newId };
139-
this.services.update((items) => [...items, newService]);
98+
this.treatments.update((items) => [...items, newService]);
14099
} else {
141-
this.services.update((items) =>
100+
this.treatments.update((items) =>
142101
items.map((item) =>
143102
item.id === this.tempService.id ? { ...this.tempService } : item,
144103
),

0 commit comments

Comments
 (0)