mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 14:49:07 +00:00
add reseller hide phone number on sign up
This commit is contained in:
parent
911424c505
commit
fc0f6d8e6b
27
Accounts/package-lock.json
generated
27
Accounts/package-lock.json
generated
@ -20,7 +20,8 @@
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"the-new-css-reset": "^1.7.3",
|
||||
"typescript": "^4.6.4"
|
||||
"typescript": "^4.6.4",
|
||||
"use-async-effect": "^2.2.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
@ -61,7 +62,7 @@
|
||||
"moment-timezone": "^0.5.40",
|
||||
"nanoid": "^3.3.2",
|
||||
"nanoid-dictionary": "^4.3.0",
|
||||
"posthog-js": "^1.37.0",
|
||||
"posthog-js": "^1.77.0",
|
||||
"process": "^0.11.10",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"slugify": "^1.6.5",
|
||||
@ -69,7 +70,7 @@
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@faker-js/faker": "^6.3.1",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^17.0.22",
|
||||
"jest": "^27.5.1",
|
||||
@ -81,6 +82,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clickhouse/client": "^0.2.1",
|
||||
"@elastic/elasticsearch": "^8.1.0",
|
||||
"@opentelemetry/api": "^1.1.0",
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.31.0",
|
||||
@ -15015,6 +15017,14 @@
|
||||
"requires-port": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-async-effect": {
|
||||
"version": "2.2.7",
|
||||
"resolved": "https://registry.npmjs.org/use-async-effect/-/use-async-effect-2.2.7.tgz",
|
||||
"integrity": "sha512-Vq94tKPyo/9Nok4LOapV0GoGgZPhbeDW/bP6bulLPV4+lIoftaBRBBbGjTbM+j5W1Bm2EkUHJgapeu5YnQvKEA==",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
@ -19843,7 +19853,7 @@
|
||||
"Common": {
|
||||
"version": "file:../Common",
|
||||
"requires": {
|
||||
"@faker-js/faker": "^6.3.1",
|
||||
"@faker-js/faker": "^8.0.2",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/nanoid-dictionary": "^4.2.0",
|
||||
@ -19857,7 +19867,7 @@
|
||||
"moment-timezone": "^0.5.40",
|
||||
"nanoid": "^3.3.2",
|
||||
"nanoid-dictionary": "^4.3.0",
|
||||
"posthog-js": "^1.37.0",
|
||||
"posthog-js": "^1.77.0",
|
||||
"process": "^0.11.10",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"slugify": "^1.6.5",
|
||||
@ -19884,6 +19894,7 @@
|
||||
"CommonServer": {
|
||||
"version": "file:../CommonServer",
|
||||
"requires": {
|
||||
"@clickhouse/client": "^0.2.1",
|
||||
"@elastic/elasticsearch": "^8.1.0",
|
||||
"@faker-js/faker": "^6.3.1",
|
||||
"@opentelemetry/api": "^1.1.0",
|
||||
@ -26759,6 +26770,12 @@
|
||||
"requires-port": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"use-async-effect": {
|
||||
"version": "2.2.7",
|
||||
"resolved": "https://registry.npmjs.org/use-async-effect/-/use-async-effect-2.2.7.tgz",
|
||||
"integrity": "sha512-Vq94tKPyo/9Nok4LOapV0GoGgZPhbeDW/bP6bulLPV4+lIoftaBRBBbGjTbM+j5W1Bm2EkUHJgapeu5YnQvKEA==",
|
||||
"requires": {}
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
@ -15,7 +15,8 @@
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"the-new-css-reset": "^1.7.3",
|
||||
"typescript": "^4.6.4"
|
||||
"typescript": "^4.6.4",
|
||||
"use-async-effect": "^2.2.7"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "npx nodemon",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, 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';
|
||||
@ -16,17 +16,62 @@ import Fields from 'CommonUI/src/Components/Forms/Types/Fields';
|
||||
import Dictionary from 'Common/Types/Dictionary';
|
||||
import UiAnalytics from 'CommonUI/src/Utils/Analytics';
|
||||
import LocalStorage from 'CommonUI/src/Utils/LocalStorage';
|
||||
import Reseller from 'Model/Models/Reseller';
|
||||
import ModelAPI, { ListResult } from 'CommonUI/src/Utils/ModelAPI/ModelAPI';
|
||||
import BaseAPI from 'CommonUI/src/Utils/API/API';
|
||||
import ErrorMessage from 'CommonUI/src/Components/ErrorMessage/ErrorMessage';
|
||||
import PageLoader from 'CommonUI/src/Components/Loader/PageLoader';
|
||||
import useAsyncEffect from 'use-async-effect';
|
||||
|
||||
const RegisterPage: () => JSX.Element = () => {
|
||||
const apiUrl: URL = SIGNUP_API_URL;
|
||||
|
||||
const [initialValues, setInitialValues] = React.useState<JSONObject>({});
|
||||
|
||||
const [error, setError] = useState<string>('');
|
||||
|
||||
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
||||
|
||||
|
||||
const [reseller, setResller] = React.useState<Reseller | undefined>(undefined);
|
||||
|
||||
if (UserUtil.isLoggedIn()) {
|
||||
Navigation.navigate(DASHBOARD_URL);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const fetchReseller = async (resellerId: string) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const reseller: ListResult<Reseller> = await ModelAPI.getList<Reseller>(
|
||||
Reseller,
|
||||
{
|
||||
resellerId: resellerId
|
||||
},
|
||||
1,
|
||||
0,
|
||||
{
|
||||
hidePhoneNumberOnSignup: true,
|
||||
},
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
if (reseller.data.length > 0) {
|
||||
setResller(reseller.data[0]);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(BaseAPI.getFriendlyMessage(err));
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
useAsyncEffect(async () => {
|
||||
// if promo code is found, please save it in localstorage.
|
||||
if (Navigation.getQueryStringByName('promoCode')) {
|
||||
LocalStorage.setItem(
|
||||
@ -35,11 +80,17 @@ const RegisterPage: () => JSX.Element = () => {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (Navigation.getQueryStringByName('email')) {
|
||||
setInitialValues({
|
||||
email: Navigation.getQueryStringByName('email'),
|
||||
});
|
||||
}
|
||||
|
||||
// if promo code is found, please save it in localstorage.
|
||||
if (Navigation.getQueryStringByName('partnerId')) {
|
||||
await fetchReseller(Navigation.getQueryStringByName('partnerId')!)
|
||||
}
|
||||
}, []);
|
||||
|
||||
let formFields: Fields<User> = [
|
||||
@ -74,8 +125,12 @@ 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.
|
||||
if (!reseller || !reseller.hidePhoneNumberOnSignup) {
|
||||
formFields.push({
|
||||
field: {
|
||||
companyPhoneNumber: true,
|
||||
},
|
||||
@ -83,8 +138,8 @@ const RegisterPage: () => JSX.Element = () => {
|
||||
required: true,
|
||||
placeholder: '+11234567890',
|
||||
title: 'Phone Number',
|
||||
},
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
formFields = formFields.concat([
|
||||
@ -117,6 +172,14 @@ const RegisterPage: () => JSX.Element = () => {
|
||||
},
|
||||
]);
|
||||
|
||||
if (error) {
|
||||
return <ErrorMessage error={error} />
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <PageLoader isVisible={true} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-full flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
|
@ -17,7 +17,7 @@ import URL from 'Common/Types/API/URL';
|
||||
|
||||
@TableAccessControl({
|
||||
create: [],
|
||||
read: [Permission.ProjectOwner],
|
||||
read: [Permission.ProjectOwner, Permission.Public],
|
||||
delete: [],
|
||||
update: [],
|
||||
})
|
||||
@ -36,7 +36,7 @@ import URL from 'Common/Types/API/URL';
|
||||
export default class Reseller extends BaseModel {
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
read: [Permission.Public],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
@ -238,4 +238,27 @@ export default class Reseller extends BaseModel {
|
||||
transformer: URL.getDatabaseTransformer(),
|
||||
})
|
||||
public changePlanLink?: URL = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [Permission.Public],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
required: false,
|
||||
type: TableColumnType.ShortURL,
|
||||
canReadOnRelationQuery: true,
|
||||
title: 'Change Plan Link',
|
||||
description: 'Reseller Change plan Link',
|
||||
})
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: ColumnType.ShortURL,
|
||||
length: ColumnLength.ShortURL,
|
||||
transformer: URL.getDatabaseTransformer(),
|
||||
})
|
||||
public hidePhoneNumberOnSignup?: boolean = undefined;
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user