feat: onboarding after registration
This commit is contained in:
parent
95a3105038
commit
54f846ccec
|
|
@ -50,7 +50,7 @@ export class AuthController {
|
|||
});
|
||||
}
|
||||
|
||||
response.header('reload', 'true');
|
||||
response.header('onboarding', 'true');
|
||||
response.status(200).json({
|
||||
register: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ async function bootstrap() {
|
|||
rawBody: true,
|
||||
cors: {
|
||||
credentials: true,
|
||||
exposedHeaders: ['reload'],
|
||||
exposedHeaders: ['reload', 'onboarding'],
|
||||
origin: [process.env.FRONTEND_URL],
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export class PermissionsService {
|
|||
subscription,
|
||||
options: {
|
||||
...all,
|
||||
...{ channel: tier === 'FREE' ? { channel } : {} },
|
||||
...{ channel: tier === 'FREE' ? channel : -10 },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -77,7 +77,6 @@ export class PermissionsService {
|
|||
).length;
|
||||
|
||||
if (
|
||||
// @ts-ignore
|
||||
(options.channel && options.channel > totalChannels) ||
|
||||
(subscription?.totalChannels || 0) > totalChannels
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,40 +1,54 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import {ReactNode, useCallback} from "react";
|
||||
import {FetchWrapperComponent} from "@gitroom/helpers/utils/custom.fetch";
|
||||
import {deleteDialog} from "@gitroom/react/helpers/delete.dialog";
|
||||
import { ReactNode, useCallback } from 'react';
|
||||
import { FetchWrapperComponent } from '@gitroom/helpers/utils/custom.fetch';
|
||||
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
|
||||
|
||||
export default async function LayoutContext(params: {children: ReactNode}) {
|
||||
if (params?.children) {
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
return <LayoutContextInner children={params.children} />
|
||||
}
|
||||
export default function LayoutContext(params: { children: ReactNode }) {
|
||||
if (params?.children) {
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
return <LayoutContextInner children={params.children} />;
|
||||
}
|
||||
|
||||
return <></>
|
||||
return <></>;
|
||||
}
|
||||
function LayoutContextInner(params: {children: ReactNode}) {
|
||||
const afterRequest = useCallback(async (url: string, options: RequestInit, response: Response) => {
|
||||
if (response?.headers?.get('reload')) {
|
||||
window.location.reload();
|
||||
function LayoutContextInner(params: { children: ReactNode }) {
|
||||
const afterRequest = useCallback(
|
||||
async (url: string, options: RequestInit, response: Response) => {
|
||||
if (response?.headers?.get('onboarding')) {
|
||||
window.location.href = '/analytics?onboarding=true';
|
||||
}
|
||||
|
||||
if (response?.headers?.get('reload')) {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
if (response.status === 402) {
|
||||
if (
|
||||
await deleteDialog(
|
||||
(
|
||||
await response.json()
|
||||
).message,
|
||||
'Move to billing',
|
||||
'Payment Required'
|
||||
)
|
||||
) {
|
||||
window.open('/billing', '_blank');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (response.status === 402) {
|
||||
if (await deleteDialog((await response.json()).message, 'Move to billing', 'Payment Required')) {
|
||||
window.open('/billing', '_blank');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<FetchWrapperComponent
|
||||
baseUrl={process.env.NEXT_PUBLIC_BACKEND_URL!}
|
||||
afterRequest={afterRequest}
|
||||
>
|
||||
|
||||
{params?.children || <></>}
|
||||
</FetchWrapperComponent>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<FetchWrapperComponent
|
||||
baseUrl={process.env.NEXT_PUBLIC_BACKEND_URL!}
|
||||
afterRequest={afterRequest}
|
||||
>
|
||||
{params?.children || <></>}
|
||||
</FetchWrapperComponent>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue