chore: handled build errors in web

This commit is contained in:
guru_sainath 2024-05-08 16:23:45 +05:30
parent e377697aa1
commit 78926890b2
6 changed files with 35 additions and 14 deletions

View File

@ -2,11 +2,11 @@ import { ReactNode } from "react";
import Link from "next/link";
export enum EPageTypes {
"INIT" = "INIT",
"PUBLIC" = "PUBLIC",
"NON_AUTHENTICATED" = "NON_AUTHENTICATED",
"ONBOARDING" = "ONBOARDING",
"AUTHENTICATED" = "AUTHENTICATED",
INIT = "INIT",
PUBLIC = "PUBLIC",
NON_AUTHENTICATED = "NON_AUTHENTICATED",
ONBOARDING = "ONBOARDING",
AUTHENTICATED = "AUTHENTICATED",
}
export enum EAuthModes {

View File

@ -39,6 +39,7 @@
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.38.0",
"react-popper": "^2.3.0",
"swr": "^2.2.2",
"tailwind-merge": "^2.0.0",
"typescript": "4.9.5",

View File

@ -8,7 +8,7 @@ import { PageLoader } from "@/components/pages";
// constants
import { EmptyStateType } from "@/constants/empty-state";
// hooks
import { useApplication, useProjectPages } from "@/hooks/store";
import { useCommandPalette, useProjectPages } from "@/hooks/store";
// assets
import AllFiltersImage from "public/empty-state/pages/all-filters.svg";
import NameFilterImage from "public/empty-state/pages/name-filter.svg";
@ -23,7 +23,7 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
const { children, pageType, projectId } = props;
// store hooks
const { loader, getCurrentProjectFilteredPageIds, getCurrentProjectPageIds, filters } = useProjectPages(projectId);
const { commandPalette: commandPaletteStore } = useApplication();
const { toggleCreatePageModal } = useCommandPalette();
// derived values
const pageIds = getCurrentProjectPageIds(pageType);
const filteredPageIds = getCurrentProjectFilteredPageIds(pageType);
@ -36,7 +36,7 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
<EmptyState
type={EmptyStateType.PROJECT_PAGE_PUBLIC}
primaryButtonOnClick={() => {
commandPaletteStore.toggleCreatePageModal(true);
toggleCreatePageModal(true);
}}
/>
);
@ -45,7 +45,7 @@ export const PagesListMainContent: React.FC<Props> = observer((props) => {
<EmptyState
type={EmptyStateType.PROJECT_PAGE_PRIVATE}
primaryButtonOnClick={() => {
commandPaletteStore.toggleCreatePageModal(true);
toggleCreatePageModal(true);
}}
/>
);

View File

@ -2,10 +2,11 @@ import { ReactNode } from "react";
import Link from "next/link";
export enum EPageTypes {
"PUBLIC" = "PUBLIC",
"NON_AUTHENTICATED" = "NON_AUTHENTICATED",
"ONBOARDING" = "ONBOARDING",
"AUTHENTICATED" = "AUTHENTICATED",
PUBLIC = "PUBLIC",
NON_AUTHENTICATED = "NON_AUTHENTICATED",
SET_PASSWORD = "SET_PASSWORD",
ONBOARDING = "ONBOARDING",
AUTHENTICATED = "AUTHENTICATED",
}
export enum EAuthModes {

View File

@ -95,6 +95,24 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = observer((props
}
}
if (pageType === EPageTypes.SET_PASSWORD) {
if (!currentUser?.id) {
router.push("/accounts/sign-in");
return <></>;
} else {
if (
currentUser &&
currentUser?.is_password_autoset &&
currentUserProfile?.id &&
currentUserProfile?.is_onboarded
) {
const currentRedirectRoute = getWorkspaceRedirectionUrl();
router.push(currentRedirectRoute);
return <></>;
} else return <>{children}</>;
}
}
if (pageType === EPageTypes.AUTHENTICATED) {
if (currentUser?.id) {
if (currentUserProfile && currentUserProfile?.id && currentUserProfile?.is_onboarded) return <>{children}</>;

View File

@ -11,6 +11,7 @@ import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui";
import { PasswordStrengthMeter } from "@/components/account";
import { PageHead } from "@/components/core";
// helpers
import { EPageTypes } from "@/helpers/authentication.helper";
import { getPasswordStrength } from "@/helpers/password.helper";
// hooks
import { useUser } from "@/hooks/store";
@ -212,7 +213,7 @@ const SetPasswordPage: NextPageWithLayout = observer(() => {
SetPasswordPage.getLayout = function getLayout(page: ReactElement) {
return (
<AuthenticationWrapper>
<AuthenticationWrapper pageType={EPageTypes.SET_PASSWORD}>
<DefaultLayout>{page}</DefaultLayout>
</AuthenticationWrapper>
);