diff --git a/src/app/app.component.html b/src/app/app.component.html index 5cd71fa..e190b06 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -10,8 +10,16 @@ -@if (sharedService.isEditDialogOpen) { +@if (sharedService.isEditContactDialogOpen) { +} @if (sharedService.isDeleteContactDialogOpen) { + } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9d936e4..7b78671 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,6 +8,7 @@ import { ContactEditComponent } from './components/contacts/contact-edit/contact import { CommonModule } from '@angular/common'; import { SharedService } from './services/shared.service'; import { Observable } from 'rxjs'; +import { ContactDeleteComponent } from './components/contacts/contact-delete/contact-delete.component'; @Component({ selector: 'app-root', @@ -18,6 +19,7 @@ import { Observable } from 'rxjs'; SidebarComponent, SidebarMobileComponent, ContactEditComponent, + ContactDeleteComponent, CommonModule, ], templateUrl: './app.component.html', diff --git a/src/app/components/contacts/contact-delete/contact-delete.component.html b/src/app/components/contacts/contact-delete/contact-delete.component.html new file mode 100644 index 0000000..b2af2c4 --- /dev/null +++ b/src/app/components/contacts/contact-delete/contact-delete.component.html @@ -0,0 +1,17 @@ + + + Do you really want to delete the contact? + + + + {{ "contact-delete-dialog.btn-cancle" | translate }} + + + + + {{ "contact-delete-dialog.btn-delete" | translate }} + + + + + diff --git a/src/app/components/contacts/contact-delete/contact-delete.component.scss b/src/app/components/contacts/contact-delete/contact-delete.component.scss new file mode 100644 index 0000000..1619b6e --- /dev/null +++ b/src/app/components/contacts/contact-delete/contact-delete.component.scss @@ -0,0 +1,82 @@ +section { + width: 100vw; + height: 100vh; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: center; +} + +.dialog { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: var(--white); + width: 600px; + height: 170px; + border-radius: 26px; + border: 2px solid rgba($color: #000000, $alpha: 0.1); + p { + font-size: 27px; + font-weight: 500; + margin-bottom: 12px; + } +} + +.btns { + display: flex; + justify-content: center; + align-items: center; +} + +.btn { + display: flex; + flex-direction: column; + align-items: center; + width: 111px; + height: 57px; + margin: 0 24px; + font-size: 21px; + font-weight: 400; +} + +.btn-cancle { + padding: 12px; + margin: 12px 12px; + border-radius: 10px; + border-color: var(--black); + background-color: var(--dark-blue); + color: var(--white); + font-size: 23px; + font-weight: 400; + transition: 125ms ease-in-out; + cursor: pointer; + &:hover { + background-color: var(--light-blue); + box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3); + } +} + +.btn-delete { + padding: 12px; + margin: 12px 12px; + border-radius: 10px; + color: var(--red); + background-color: var(--white); + border: 1px solid var(--red); + font-size: 23px; + font-weight: 400; + transition: 125ms ease-in-out; + cursor: pointer; + &:hover { + color: var(--white); + background-color: var(--red); + border-color: var(--black); + box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3); + } +} diff --git a/src/app/components/contacts/contact-delete/contact-delete.component.spec.ts b/src/app/components/contacts/contact-delete/contact-delete.component.spec.ts new file mode 100644 index 0000000..3516c68 --- /dev/null +++ b/src/app/components/contacts/contact-delete/contact-delete.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ContactDeleteComponent } from './contact-delete.component'; + +describe('ContactDeleteComponent', () => { + let component: ContactDeleteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ContactDeleteComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ContactDeleteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/contacts/contact-delete/contact-delete.component.ts b/src/app/components/contacts/contact-delete/contact-delete.component.ts new file mode 100644 index 0000000..70dfdb5 --- /dev/null +++ b/src/app/components/contacts/contact-delete/contact-delete.component.ts @@ -0,0 +1,29 @@ +import { Component, Input } from '@angular/core'; +import { SharedService } from '../../../services/shared.service'; +import { TranslateModule } from '@ngx-translate/core'; + +@Component({ + selector: 'app-contact-delete', + standalone: true, + imports: [TranslateModule], + templateUrl: './contact-delete.component.html', + styleUrl: './contact-delete.component.scss', +}) +export class ContactDeleteComponent { + @Input() currentUserId!: string; + + constructor(private sharedService: SharedService) {} + + deleteContact() { + console.log('Contact deleted'); + this.sharedService.isDeleteContactDialogOpen = false; + this.sharedService.isAnyDialogOpen = false; + } + + deleteCancle() { + this.sharedService.isDeleteContactDialogOpen = false; + if (!this.sharedService.isEditContactDialogOpen) { + this.sharedService.isAnyDialogOpen = false; + } + } +} diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.html b/src/app/components/contacts/contact-detail/contact-detail.component.html index 4a34049..53fa22b 100644 --- a/src/app/components/contacts/contact-detail/contact-detail.component.html +++ b/src/app/components/contacts/contact-detail/contact-detail.component.html @@ -38,9 +38,9 @@ edit - + - delete + delete diff --git a/src/app/components/contacts/contact-detail/contact-detail.component.ts b/src/app/components/contacts/contact-detail/contact-detail.component.ts index 0001a5a..585ecc6 100644 --- a/src/app/components/contacts/contact-detail/contact-detail.component.ts +++ b/src/app/components/contacts/contact-detail/contact-detail.component.ts @@ -27,7 +27,13 @@ export class ContactDetailComponent { } openEditDialog() { - this.sharedService.isEditDialogOpen = !this.sharedService.isEditDialogOpen; + this.sharedService.isAnyDialogOpen = true; + this.sharedService.isEditContactDialogOpen = true; + } + + deleteContact() { + this.sharedService.isAnyDialogOpen = true; + this.sharedService.isDeleteContactDialogOpen = true; } @HostListener('document:click', ['$event']) @@ -35,10 +41,14 @@ export class ContactDetailComponent { const targetElement = event.target as HTMLElement; if (targetElement.closest('.btn-edit')) { this.sharedService.isAnyDialogOpen = true; - this.sharedService.isEditDialogOpen = true; + this.sharedService.isEditContactDialogOpen = true; + } else if (targetElement.closest('.btn-delete')) { + this.sharedService.isAnyDialogOpen = true; + this.sharedService.isDeleteContactDialogOpen = true; } else if (!targetElement.closest('.dialog')) { this.sharedService.isAnyDialogOpen = false; - this.sharedService.isEditDialogOpen = false; + this.sharedService.isEditContactDialogOpen = false; + this.sharedService.isDeleteContactDialogOpen = false; } } } diff --git a/src/app/components/contacts/contact-form/contact-form.component.html b/src/app/components/contacts/contact-form/contact-form.component.html index 952e5c5..c0a4ac1 100644 --- a/src/app/components/contacts/contact-form/contact-form.component.html +++ b/src/app/components/contacts/contact-form/contact-form.component.html @@ -62,8 +62,9 @@ {{ "form.invalid-msg" | translate }} } - +
Do you really want to delete the contact?
edit
delete