From fa491c94a7872acef91c38d47be6434bb370443b Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Sat, 20 Aug 2022 09:50:06 +0000 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EC=B2=9C=EC=9D=B8=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/member_referrer.service.ts | 30 +++++++++++++++++++ .../compose/sign-up-compose.component.html | 9 ++++++ .../main/compose/sign-up-compose.component.ts | 12 +++++--- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts b/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts index 34bfc4b..057f21f 100644 --- a/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts +++ b/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts @@ -15,6 +15,8 @@ import { DeleteMemberReferrerResponse, GetMemberReferrerResponse, GetMemberReferrerRequest, + GetMemberReferrerByCodeResponse, + GetMemberReferrerByCodeRequest, } from 'app/modules/proto/c2se/member_referrer_pb'; import { SUBJECT_LIST_MEMBER_REFERRERS, @@ -22,6 +24,7 @@ import { SUBJECT_UPDATE_MEMBER_REFERRER, SUBJECT_DELETE_MEMBER_REFERRER, SUBJECT_GET_MEMBER_REFERRER, + SUBJECT_GET_MEMBER_REFERRER_BY_CODE, } from 'app/modules/proto/c2se/backend/member_referrer_pb'; @Injectable({ @@ -113,6 +116,33 @@ export class MemberReferrerService { }); } + getMemberReferrerByCode( + code: string + ): Promise { + return new Promise( + (resolve, reject) => { + let req = new GetMemberReferrerByCodeRequest(); + + req.setCode(code); + + this.__natsService + .request( + SUBJECT_GET_MEMBER_REFERRER_BY_CODE, + req.serializeBinary(), + GetMemberReferrerByCodeResponse.deserializeBinary + ) + .then((result) => { + console.log('success', result, result.getMemberReferrer()); + return resolve(result); + }) + .catch((e: Error) => { + console.log('failed', e); + return reject(e); + }); + } + ); + } + updateMemberReferrer(): Promise { return new Promise( (resolve, reject) => { diff --git a/src/app/modules/user/main/compose/sign-up-compose.component.html b/src/app/modules/user/main/compose/sign-up-compose.component.html index a4f5f0f..3277942 100644 --- a/src/app/modules/user/main/compose/sign-up-compose.component.html +++ b/src/app/modules/user/main/compose/sign-up-compose.component.html @@ -47,6 +47,15 @@ > 추천인 코드는 필수 입력입니다. + + 추천인 코드는 필수 입력입니다. + diff --git a/src/app/modules/user/main/compose/sign-up-compose.component.ts b/src/app/modules/user/main/compose/sign-up-compose.component.ts index e5c26bc..0df472c 100644 --- a/src/app/modules/user/main/compose/sign-up-compose.component.ts +++ b/src/app/modules/user/main/compose/sign-up-compose.component.ts @@ -163,10 +163,14 @@ export class SignUpComposeComponent implements OnInit { } __checkReferrerCode(event: FocusEvent): void { - // const code = this.signupComposeForm.get('referalCode')?.value; - // this._memberReferrerService.getMemberReferrer( - // '6df060ad-3b30-4c6c-8e9f-9d3e30974157' - // ); + const code = this.signupComposeForm.get('referalCode')?.value; + this._memberReferrerService.getMemberReferrerByCode(code).then((result) => { + if (!result) { + this.signupComposeForm + ?.get('referalCode') + ?.setErrors({ notExistReferalCode: true }); + } + }); } __checkUsernameDuplicate(event: FocusEvent): void {