아이디 중복 체크 완료

This commit is contained in:
Park Byung Eun 2022-08-10 05:10:20 +00:00
parent 06d8d250e0
commit 71876494d5
4 changed files with 82 additions and 16 deletions

View File

@ -202,7 +202,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
} }
__onClickRegist(event: MouseEvent): void { __onClickRegist(event: MouseEvent): void {
const dialogRef = this._matDialog.open(RegistComposeComponent); const dialogRef = this._matDialog.open(RegistComposeComponent, {
data: { title: '대본', parentId: 'kgon2' },
});
dialogRef.afterClosed().subscribe((result) => { dialogRef.afterClosed().subscribe((result) => {
console.log('Compose dialog was closed!'); console.log('Compose dialog was closed!');

View File

@ -3,7 +3,7 @@
<div <div
class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary" class="flex flex-0 items-center justify-between h-16 pr-3 sm:pr-5 pl-6 sm:pl-8 bg-primary text-on-primary"
> >
<div class="text-lg font-medium">대본사 생성</div> <div class="text-lg font-medium">{{ data.title }} 등록</div>
<button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1"> <button mat-icon-button (click)="saveAndClose()" [tabIndex]="-1">
<mat-icon <mat-icon
class="text-current" class="text-current"
@ -27,6 +27,9 @@
<mat-form-field> <mat-form-field>
<mat-label>사이트명</mat-label> <mat-label>사이트명</mat-label>
<input matInput [formControlName]="'siteName'" /> <input matInput [formControlName]="'siteName'" />
<mat-error *ngIf="composeForm.get('siteName')?.hasError('required')">
사이트명은 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<!-- Bcc --> <!-- Bcc -->
@ -37,47 +40,79 @@
[formControlName]="'signinId'" [formControlName]="'signinId'"
(focusout)="__checkSigninId($event)" (focusout)="__checkSigninId($event)"
/> />
<mat-error *ngIf="composeForm.get('signinId')?.hasError('required')">
아이디는 필수 입력입니다.
</mat-error>
<mat-error
*ngIf="composeForm.get('signinId')?.hasError('signinIdDuplicate')"
>
아이디가 중복됩니다.
</mat-error>
</mat-form-field> </mat-form-field>
<!-- Subject --> <!-- Subject -->
<mat-form-field> <mat-form-field>
<mat-label>비밀번호</mat-label> <mat-label>비밀번호</mat-label>
<input matInput [formControlName]="'password'" /> <input matInput [formControlName]="'password'" />
<mat-error *ngIf="composeForm.get('password')?.hasError('required')">
비밀번호는 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>환전 비밀번호</mat-label> <mat-label>환전 비밀번호</mat-label>
<input matInput [formControlName]="'exchangePw'" /> <input matInput [formControlName]="'exchangePw'" />
<mat-error *ngIf="composeForm.get('exchangePw')?.hasError('required')">
환전 비밀번호 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>닉네임</mat-label> <mat-label>닉네임</mat-label>
<input matInput [formControlName]="'nickname'" /> <input matInput [formControlName]="'nickname'" />
<mat-error *ngIf="composeForm.get('nickname')?.hasError('required')">
닉네임은 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>정산종류</mat-label> <mat-label>정산종류</mat-label>
<input matInput [formControlName]="'calculateType'" /> <input matInput [formControlName]="'calculateType'" />
<mat-error *ngIf="composeForm.get('calculateType')?.hasError('required')">
정산종류는 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>휴대폰번호</mat-label> <mat-label>휴대폰번호</mat-label>
<input matInput [formControlName]="'phoneNumber'" /> <input matInput [formControlName]="'phoneNumber'" />
<mat-error *ngIf="composeForm.get('phoneNumber')?.hasError('required')">
휴대폰번호는 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>은행명</mat-label> <mat-label>은행명</mat-label>
<input matInput [formControlName]="'bankName'" /> <input matInput [formControlName]="'bankName'" />
<mat-error *ngIf="composeForm.get('bankName')?.hasError('required')">
은행명은 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>계좌번호</mat-label> <mat-label>계좌번호</mat-label>
<input matInput [formControlName]="'accountNumber'" /> <input matInput [formControlName]="'accountNumber'" />
<mat-error *ngIf="composeForm.get('accountNumber')?.hasError('required')">
계좌번호는 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<mat-label>예금주</mat-label> <mat-label>예금주</mat-label>
<input matInput [formControlName]="'accountHolder'" /> <input matInput [formControlName]="'accountHolder'" />
<mat-error *ngIf="composeForm.get('accountHolder')?.hasError('required')">
예금주는 필수 입력입니다.
</mat-error>
</mat-form-field> </mat-form-field>
<!-- Body --> <!-- Body -->

View File

@ -1,4 +1,10 @@
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core'; import {
ChangeDetectorRef,
Component,
Inject,
OnInit,
ViewEncapsulation,
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service'; import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
@ -47,7 +53,8 @@ export class RegistComposeComponent implements OnInit {
public matDialogRef: MatDialogRef<RegistComposeComponent>, public matDialogRef: MatDialogRef<RegistComposeComponent>,
@Inject(MAT_DIALOG_DATA) public data: RegistComposeData, @Inject(MAT_DIALOG_DATA) public data: RegistComposeData,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _identityService: IdentityService private _identityService: IdentityService,
private _changeDetectorRef: ChangeDetectorRef
) {} ) {}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -60,17 +67,17 @@ export class RegistComposeComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
// Create the form // Create the form
this.composeForm = this._formBuilder.group({ this.composeForm = this._formBuilder.group({
partnerId: [{ value: 'kgon4', disabled: true }], partnerId: [{ value: this.data.parentId, disabled: true }],
siteName: [''], siteName: ['', [Validators.required]],
signinId: [''], signinId: ['', [Validators.required]],
password: [''], password: ['', [Validators.required]],
exchangePw: [''], exchangePw: ['', [Validators.required]],
nickname: [''], nickname: ['', [Validators.required]],
calculateType: [''], calculateType: ['', [Validators.required]],
phoneNumber: [''], phoneNumber: ['', [Validators.required]],
bankName: [''], bankName: ['', [Validators.required]],
accountNumber: [''], accountNumber: ['', [Validators.required]],
accountHolder: [''], accountHolder: ['', [Validators.required]],
}); });
} }
@ -125,7 +132,28 @@ export class RegistComposeComponent implements OnInit {
this._identityService this._identityService
.checkUsernameForDuplication(signinId) .checkUsernameForDuplication(signinId)
.then((isUse: boolean) => { .then((isUse: boolean) => {
console.log('check username: ', isUse); if (!!isUse) {
this.composeForm
.get('signinId')
?.setErrors({ signinIdDuplicate: true });
}
this._changeDetectorRef.markForCheck();
}); });
} }
// checkSameName(): ValidatorFn {
// return (control: AbstractControl): { [key: string]: any } | null => {
// if (
// !control ||
// !control.value ||
// !this.groupList ||
// 0 === this.groupList.length
// ) {
// return null;
// }
// const v = (control.value as string).trim();
// const ban = -1 < this.groupList.findIndex((g) => g.name === v);
// return ban ? { groupNameSamed: { value: control.value } } : null;
// };
// }
} }

View File

@ -48,6 +48,7 @@ export class IdentityService {
) )
.then((result) => { .then((result) => {
console.log('success', result, result.getDuplicated()); console.log('success', result, result.getDuplicated());
resolve(result.getDuplicated());
}) })
.catch((e: Error) => { .catch((e: Error) => {
console.log('failed', e); console.log('failed', e);