From 8bda3948d7b394495f800c713b5b18dca5f0b545 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 7 Sep 2023 21:08:36 +0530 Subject: [PATCH] add hide phne number field on sign up --- Accounts/src/Pages/Register.tsx | 49 ++++++++++++++++----------------- Model/Models/Reseller.ts | 13 +++------ 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/Accounts/src/Pages/Register.tsx b/Accounts/src/Pages/Register.tsx index 0e911dcae3..d92ca36761 100644 --- a/Accounts/src/Pages/Register.tsx +++ b/Accounts/src/Pages/Register.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useState } from 'react'; import ModelForm, { FormType } from 'CommonUI/src/Components/Forms/ModelForm'; import User from 'Model/Models/User'; import Link from 'CommonUI/src/Components/Link/Link'; @@ -32,30 +32,32 @@ const RegisterPage: () => JSX.Element = () => { const [isLoading, setIsLoading] = React.useState(false); - - const [reseller, setResller] = React.useState(undefined); + const [reseller, setResller] = React.useState( + undefined + ); if (UserUtil.isLoggedIn()) { Navigation.navigate(DASHBOARD_URL); } - const fetchReseller = async (resellerId: string) => { + const fetchReseller: Function = async (resellerId: string): Promise => { setIsLoading(true); try { - const reseller: ListResult = await ModelAPI.getList( - Reseller, - { - resellerId: resellerId - }, - 1, - 0, - { - hidePhoneNumberOnSignup: true, - }, - {}, - {} - ); + const reseller: ListResult = + await ModelAPI.getList( + Reseller, + { + resellerId: resellerId, + }, + 1, + 0, + { + hidePhoneNumberOnSignup: true, + }, + {}, + {} + ); if (reseller.data.length > 0) { setResller(reseller.data[0]); @@ -65,12 +67,8 @@ const RegisterPage: () => JSX.Element = () => { } setIsLoading(false); - }; - - - useAsyncEffect(async () => { // if promo code is found, please save it in localstorage. if (Navigation.getQueryStringByName('promoCode')) { @@ -80,7 +78,6 @@ const RegisterPage: () => JSX.Element = () => { ); } - if (Navigation.getQueryStringByName('email')) { setInitialValues({ email: Navigation.getQueryStringByName('email'), @@ -89,7 +86,7 @@ const RegisterPage: () => JSX.Element = () => { // if promo code is found, please save it in localstorage. if (Navigation.getQueryStringByName('partnerId')) { - await fetchReseller(Navigation.getQueryStringByName('partnerId')!) + await fetchReseller(Navigation.getQueryStringByName('partnerId')!.toLowerCase()); } }, []); @@ -125,7 +122,7 @@ const RegisterPage: () => JSX.Element = () => { placeholder: 'Acme, Inc.', required: true, title: 'Company Name', - } + }, ]); // If reseller wants to hide phone number on sign up, we hide it. @@ -173,11 +170,11 @@ const RegisterPage: () => JSX.Element = () => { ]); if (error) { - return + return ; } if (isLoading) { - return + return ; } return ( diff --git a/Model/Models/Reseller.ts b/Model/Models/Reseller.ts index 07fc0ef882..5d41e199c2 100644 --- a/Model/Models/Reseller.ts +++ b/Model/Models/Reseller.ts @@ -239,7 +239,6 @@ export default class Reseller extends BaseModel { }) public changePlanLink?: URL = undefined; - @ColumnAccessControl({ create: [], read: [Permission.Public], @@ -247,18 +246,14 @@ export default class Reseller extends BaseModel { }) @TableColumn({ required: false, - type: TableColumnType.ShortURL, + type: TableColumnType.Boolean, canReadOnRelationQuery: true, - title: 'Change Plan Link', - description: 'Reseller Change plan Link', + title: 'Hide Phone Number on Signup', + description: 'Should we hide the phone number on sign up form based on reseller request?', }) @Column({ nullable: true, - type: ColumnType.ShortURL, - length: ColumnLength.ShortURL, - transformer: URL.getDatabaseTransformer(), + type: ColumnType.Boolean }) public hidePhoneNumberOnSignup?: boolean = undefined; - - }