diff --git a/src/components/Libraries/LibraryEntityPane.tsx b/src/components/Libraries/LibraryEntityPane.tsx index 7581e086d..d9585cae1 100644 --- a/src/components/Libraries/LibraryEntityPane.tsx +++ b/src/components/Libraries/LibraryEntityPane.tsx @@ -33,7 +33,7 @@ import { AppState, useStore } from '@store'; import { NumPerPageType } from '@types'; import { noop, parseAPIError } from '@utils'; import { uniq } from 'ramda'; -import { memo, useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { DocumentList } from './DocumentList/DocumentList'; export interface ILibraryEntityPaneProps { diff --git a/src/components/Libraries/LibrarySelector.tsx b/src/components/Libraries/LibrarySelector.tsx index 82b7aca90..fe483aae8 100644 --- a/src/components/Libraries/LibrarySelector.tsx +++ b/src/components/Libraries/LibrarySelector.tsx @@ -91,7 +91,7 @@ export const LibrarySelector = ({ icon={} aria-label="Remove" colorScheme="gray" - variant="ghosted" + variant="ghost" size="xs" onClick={() => handleRemoveSelect(l.id)} /> diff --git a/src/components/Libraries/OperationModal.tsx b/src/components/Libraries/OperationModal.tsx index ab668f688..2d2c94f8d 100644 --- a/src/components/Libraries/OperationModal.tsx +++ b/src/components/Libraries/OperationModal.tsx @@ -119,7 +119,6 @@ export const OperationModal = ({ const { register, control, - getValues, setValue, formState: { errors }, reset, @@ -144,8 +143,8 @@ export const OperationModal = ({ remove(libs.findIndex((l) => l.value === id)); }; - const handleOperate = () => { - const { action, libs, source, target, name, desc, isPublic } = getValues(); + const handleOperate = (data: FormValues) => { + const { action, libs, source, target, name, desc, isPublic } = data; switch (action) { case 'union': diff --git a/src/pages/user/libraries/[[...id]].tsx b/src/pages/user/libraries/[[...id]].tsx index 06d3c9c66..c0b9ba5d1 100644 --- a/src/pages/user/libraries/[[...id]].tsx +++ b/src/pages/user/libraries/[[...id]].tsx @@ -34,7 +34,7 @@ const LibrariesHome: NextPage = ({ id, subpage }) => { return ( <> - NASA Science Explorer - Libraries - {!!id ? library?.metadata.name ?? '' : ''} + {`NASA Science Explorer - Libraries - ${!!id ? library?.metadata.name ?? '' : ''}`} {!!id && isLoadingLib && (
@@ -74,16 +74,6 @@ const LibrariesHome: NextPage = ({ id, subpage }) => { export default LibrariesHome; export const getServerSideProps: GetServerSideProps = composeNextGSSP(async (ctx) => { - if (!ctx.req.session.isAuthenticated) { - return Promise.resolve({ - redirect: { - destination: `/user/account/login?redirectUri=${encodeURIComponent(ctx.req.url)}`, - permanent: false, - }, - props: {}, - }); - } - const { id = null } = ctx.params; const queryClient = new QueryClient(); diff --git a/src/utils.ts b/src/utils.ts index c63c80960..3b9193657 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -30,6 +30,7 @@ import { without, } from 'ramda'; import { isArray, isNilOrEmpty, isNonEmptyString, isNotString, isPlainObject } from 'ramda-adjunct'; +import z from 'zod'; type ParsedQueryParams = ParsedUrlQuery | qs.ParsedQs; @@ -497,9 +498,12 @@ export const pluralize = (str: string, count: number) => { return count === 1 ? str : `${str}s`; }; -export const isValidEmail = (email: string) => - email - .toLowerCase() - .match( - /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, - ); +export const isValidEmail = (email: string) => { + const emailSchema = z.string().email(); + try { + emailSchema.parse(email); + return true; + } catch { + return false; + } +};