Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reworked back to portal button logic #2375

Merged
merged 3 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const Navigation = () => {
const { stateApi } = useStateManagerContext();
const { currentPage } = usePageResolverContext();
const { customer } = useCustomer();
const exitFromApp = useAppExit();
const { exit, isExitAvailable } = useAppExit();

const isFirstStep = currentPage?.number === 1;
const isDisabled = state.isLoading;
Expand All @@ -26,9 +26,11 @@ export const Navigation = () => {
return;
}

exitFromApp();
exit();
return;
}, [stateApi, exitFromApp]);
}, [stateApi, exit]);

if (isFirstStep && !isExitAvailable) return null;

return (
<button
Expand Down
6 changes: 5 additions & 1 deletion apps/kyb-app/src/hooks/useAppExit/useAppExit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ export const useAppExit = () => {
}
}, [trackExit, customer]);

return exit;
return {
exit,
isExitAvailable:
uiSchema?.config?.kybOnExitAction === 'send-event' ? true : !!customer?.websiteUrl,
};
alonp99 marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Button, Card } from '@ballerine/ui';
export const Approved = withSessionProtected(() => {
const { t } = useTranslation();
const { customer } = useCustomer();
const exitFromApp = useAppExit();
const { exit, isExitAvailable } = useAppExit();

return (
<div className="flex h-full items-center justify-center">
Expand All @@ -29,9 +29,9 @@ export const Approved = withSessionProtected(() => {
{t('approved.content', { companyName: customer?.displayName })}
</p>
</div>
{customer && (
{customer && isExitAvailable && (
<div className="flex justify-center">
<Button variant="secondary" onClick={exitFromApp}>
<Button variant="secondary" onClick={exit}>
{t('backToPortal', { companyName: customer.displayName })}
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Success = withSessionProtected(() => {
const { t } = useTranslation();
const { customer } = useCustomer();

const exitFromApp = useAppExit();
const { exit, isExitAvailable } = useAppExit();

return (
<div className="flex h-full items-center justify-center">
Expand All @@ -29,9 +29,9 @@ export const Success = withSessionProtected(() => {
{t('success.content')}
</h2>
</div>
{customer?.displayName && (
{customer?.displayName && isExitAvailable && (
<div className="flex justify-center">
<Button variant="secondary" onClick={exitFromApp}>
<Button variant="secondary" onClick={exit}>
{t('backToPortal', { companyName: customer.displayName })}
</Button>
</div>
Expand Down
Loading