signin 수정

This commit is contained in:
Park Byung Eun 2022-08-21 00:44:59 +00:00
parent e286b6c316
commit 9d17726f92
2 changed files with 32 additions and 36 deletions

View File

@ -11,11 +11,20 @@
></mat-icon> ></mat-icon>
</button> </button>
</div> </div>
<fuse-alert
class="mt-8 -mb-4"
*ngIf="showAlert"
[appearance]="'outline'"
[showIcon]="false"
[type]="alert.type"
[@shake]="alert.type === 'error'"
>
{{ alert.message }}
</fuse-alert>
<!-- Compose form --> <!-- Compose form -->
<form <form
class="flex flex-col flex-auto p-6 sm:p-8 overflow-y-auto" class="flex flex-col flex-auto p-6 sm:p-8 overflow-y-auto"
[formGroup]="composeForm" [formGroup]="signInComposeForm"
> >
<!-- 아이디 --> <!-- 아이디 -->
<mat-form-field> <mat-form-field>

View File

@ -1,6 +1,7 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog'; import { MatDialogRef } from '@angular/material/dialog';
import { FuseAlertType } from '@fuse/components/alert';
import { AuthService } from 'app/core/auth/auth.service'; import { AuthService } from 'app/core/auth/auth.service';
@Component({ @Component({
@ -9,19 +10,15 @@ import { AuthService } from 'app/core/auth/auth.service';
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
}) })
export class SignInComposeComponent implements OnInit { export class SignInComposeComponent implements OnInit {
composeForm!: FormGroup; signInComposeForm!: FormGroup;
copyFields: { cc: boolean; bcc: boolean } = {
cc: false, alert: { type: FuseAlertType; message: string } = {
bcc: false, type: 'success',
}; message: '로그인이 성공하였습니다.',
quillModules: any = {
toolbar: [
['bold', 'italic', 'underline'],
[{ align: [] }, { list: 'ordered' }, { list: 'bullet' }],
['clean'],
],
}; };
showAlert: boolean = false;
/** /**
* Constructor * Constructor
*/ */
@ -40,9 +37,9 @@ export class SignInComposeComponent implements OnInit {
*/ */
ngOnInit(): void { ngOnInit(): void {
// Create the form // Create the form
this.composeForm = this._formBuilder.group({ this.signInComposeForm = this._formBuilder.group({
username: ['', [Validators.required, Validators.email]], username: ['', [Validators.required]],
password: ['', [Validators.email]], password: ['', [Validators.required]],
}); });
} }
@ -50,21 +47,6 @@ export class SignInComposeComponent implements OnInit {
// @ Public methods // @ Public methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
/**
* Show the copy field with the given field name
*
* @param name
*/
showCopyField(name: string): void {
// Return if the name is not one of the available names
if (name !== 'cc' && name !== 'bcc') {
return;
}
// Show the field
this.copyFields[name] = true;
}
/** /**
* Save and close * Save and close
*/ */
@ -91,20 +73,25 @@ export class SignInComposeComponent implements OnInit {
*/ */
send(): void { send(): void {
// Return if the form is invalid // Return if the form is invalid
if (this.composeForm?.invalid) { if (this.signInComposeForm?.invalid) {
return; return;
} }
// Disable the form // Disable the form
this.composeForm?.disable(); this.signInComposeForm?.disable();
// Sign in // Sign in
this._authService this._authService
.signIn(this.composeForm?.value) .signIn(this.signInComposeForm?.value)
.then(() => {}) .then(() => {
console.log();
this.showAlert = true;
})
.catch((e) => { .catch((e) => {
this.showAlert = true;
this.alert = { type: 'error', message: '등록에 실패하였습니다.' };
// Re-enable the form // Re-enable the form
this.composeForm?.enable(); this.signInComposeForm?.enable();
// Reset the form // Reset the form
}); });