77import { CommonModule } from "@angular/common" ;
88import { 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} )
2727export 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