Skip to content

Commit

Permalink
Merge pull request #1852 from holium/fix-byop-double-request-issue
Browse files Browse the repository at this point in the history
Add logging to BE & make `product_type` query param
  • Loading branch information
gdbroman authored Jul 1, 2023
2 parents 4658547 + 557a3a1 commit 0b7284e
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 114 deletions.
5 changes: 0 additions & 5 deletions hosting-holium-com/src/pages/account/custom-domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useMemo, useState } from 'react';
import { useToggle } from '@holium/design-system/util';
import {
AccountCustomDomainDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand Down Expand Up @@ -71,16 +70,12 @@ const CustomDomainPresenter = () => {
};

const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/upload-id-disclaimer', {
back_url: '/account/custom-domain',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/custom-domain',
});
Expand Down
5 changes: 0 additions & 5 deletions hosting-holium-com/src/pages/account/download-realm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
AccountDownloadRealmDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand Down Expand Up @@ -28,16 +27,12 @@ const DownloadRealmPresenter = () => {
};

const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/upload-id-disclaimer', {
back_url: '/account/download-realm',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/download-realm',
});
Expand Down
10 changes: 1 addition & 9 deletions hosting-holium-com/src/pages/account/get-realm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
AccountGetRealmDialog,
OnboardingStorage,
UserContextProvider,
} from '@holium/shared';
import { AccountGetRealmDialog, UserContextProvider } from '@holium/shared';

import { thirdEarthApi } from 'util/thirdEarthApi';

Expand Down Expand Up @@ -32,16 +28,12 @@ const GetRealmPresenter = () => {
const { goToPage, logout } = useNavigation();

const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/upload-id-disclaimer', {
back_url: '/account/get-realm',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/get-realm',
});
Expand Down
9 changes: 1 addition & 8 deletions hosting-holium-com/src/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,19 @@ const HostingPresenter = () => {
};

const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/upload-id-disclaimer', {
back_url: '/account',
});
};

const onClickReuploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
provisionalShipId: selectedShipId?.toString(),
});
goToPage('/upload-id', {
product_type: 'byop-p',
back_url: '/account',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account',
});
Expand Down
5 changes: 0 additions & 5 deletions hosting-holium-com/src/pages/account/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';

import {
AccountStorageDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand Down Expand Up @@ -35,16 +34,12 @@ const S3StoragePresenter = () => {
};

const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/upload-id-disclaimer', {
back_url: '/account/storage',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage(accountPageUrl['Get Hosting'], {
back_url: '/account/storage',
});
Expand Down
31 changes: 26 additions & 5 deletions hosting-holium-com/src/pages/booting.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import type { GetServerSideProps } from 'next/types';

import { useToggle } from '@holium/design-system/util';
import { BootingDialog, OnboardingStorage } from '@holium/shared';
import {
BootingDialog,
OnboardingStorage,
ThirdEarthProductType,
} from '@holium/shared';

import { Page } from '../components/Page';
import { thirdEarthApi } from '../util/thirdEarthApi';
import { useNavigation } from '../util/useNavigation';

export default function Booting() {
type ServerSideProps = {
// We use underscore to highlight that this is a query param.
product_type: ThirdEarthProductType;
};

export const getServerSideProps: GetServerSideProps = async ({ query }) => {
const product_type = (query.product_type ??
'planet') as ThirdEarthProductType;

return {
props: {
product_type,
} as ServerSideProps,
};
};

export default function Booting({ product_type }: ServerSideProps) {
const { goToPage } = useNavigation();

const intervalRef = useRef<NodeJS.Timer>();
Expand All @@ -18,7 +39,7 @@ export default function Booting() {
const isBYOP = useToggle(false);

const pollShipStatus = useCallback(async () => {
const { serverId, token, productType } = OnboardingStorage.get();
const { serverId, token } = OnboardingStorage.get();

if (!token) return;

Expand All @@ -30,7 +51,7 @@ export default function Booting() {
error.toggleOn();
}

if (productType === 'byop-p') {
if (product_type === 'byop-p') {
isBYOP.toggleOn();
ship = Object.values(ships)
.filter((s) => s.product_type === 'byop-p' && s.is_migration)
Expand All @@ -44,7 +65,7 @@ export default function Booting() {
if (!ship) return;

if (logs.length === 1) {
if (productType === 'byop-p') {
if (product_type === 'byop-p') {
setLogs((logs) => [
...logs,
`Your uploaded identity will be ready in 5-10 minutes.`,
Expand Down
26 changes: 19 additions & 7 deletions hosting-holium-com/src/pages/create-account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,38 @@ import { useEffect, useState } from 'react';
import { FormikValues } from 'formik';
import type { GetServerSideProps } from 'next/types';

import { CreateAccountDialog, OnboardingStorage } from '@holium/shared';
import {
CreateAccountDialog,
OnboardingStorage,
ThirdEarthProductType,
} from '@holium/shared';

import { Page } from '../components/Page';
import { thirdEarthApi } from '../util/thirdEarthApi';
import { useNavigation } from '../util/useNavigation';

type ServerSideProps = {
hideAlreadyHaveAccount: string;
// We use underscore to highlight that this is a query param.
product_type: ThirdEarthProductType;
hide_already_have_account: string;
};

export const getServerSideProps: GetServerSideProps = async ({ query }) => {
const hideAlreadyHaveAccount = (query.haha ?? '') as string;
const hide_already_have_account = (query.haha ?? '') as string;
const product_type = (query.product_type ??
'planet') as ThirdEarthProductType;

return {
props: {
hideAlreadyHaveAccount: hideAlreadyHaveAccount === 'true',
product_type,
hide_already_have_account: hide_already_have_account === 'true',
},
};
};

export default function CreateAccount({
hideAlreadyHaveAccount,
product_type,
hide_already_have_account,
}: ServerSideProps) {
const { goToPage } = useNavigation();

Expand All @@ -40,7 +50,9 @@ export default function CreateAccount({
try {
const result = await thirdEarthApi.register(email, password);
if (result) {
return goToPage('/verify-email');
return goToPage('/verify-email', {
product_type,
});
} else {
return false;
}
Expand All @@ -62,7 +74,7 @@ export default function CreateAccount({
onBack={onBack}
onNext={onNext}
onAlreadyHaveAccount={
hideAlreadyHaveAccount ? undefined : onAlreadyHaveAccount
hide_already_have_account ? undefined : onAlreadyHaveAccount
}
/>
</Page>
Expand Down
5 changes: 1 addition & 4 deletions hosting-holium-com/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ export default function GetOnRealm({ email }: Props) {
};

const onUploadId = () => {
OnboardingStorage.set({ productType: 'byop-p' });

return goToPage('/create-account', {
haha: 'true',
product_type: 'byop-p',
});
};

const onPurchaseId = async () => {
OnboardingStorage.remove('productType');

return goToPage('/create-account', {
haha: 'true',
});
Expand Down
Loading

1 comment on commit 0b7284e

@vercel
Copy link

@vercel vercel bot commented on 0b7284e Jul 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hosting-holium-com – ./hosting-holium-com

realm-onboarding.vercel.app
hosting-holium-com-git-master-holium.vercel.app
hosting.holium.com
hosting-holium-com-holium.vercel.app

Please sign in to comment.