Skip to content

Commit

Permalink
Requested changes for libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyichen committed Nov 2, 2023
1 parent 1f096a3 commit 12b57ce
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/components/Libraries/LibraryEntityPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Libraries/LibrarySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const LibrarySelector = ({
icon={<CloseIcon />}
aria-label="Remove"
colorScheme="gray"
variant="ghosted"
variant="ghost"
size="xs"
onClick={() => handleRemoveSelect(l.id)}
/>
Expand Down
5 changes: 2 additions & 3 deletions src/components/Libraries/OperationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export const OperationModal = ({
const {
register,
control,
getValues,
setValue,
formState: { errors },
reset,
Expand All @@ -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':
Expand Down
12 changes: 1 addition & 11 deletions src/pages/user/libraries/[[...id]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const LibrariesHome: NextPage<ILibrariesHomeProps> = ({ id, subpage }) => {
return (
<>
<Head>
<title>NASA Science Explorer - Libraries - {!!id ? library?.metadata.name ?? '' : ''}</title>
<title>{`NASA Science Explorer - Libraries - ${!!id ? library?.metadata.name ?? '' : ''}`}</title>
</Head>
{!!id && isLoadingLib && (
<Center>
Expand Down Expand Up @@ -74,16 +74,6 @@ const LibrariesHome: NextPage<ILibrariesHomeProps> = ({ 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();
Expand Down
16 changes: 10 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
};

0 comments on commit 12b57ce

Please sign in to comment.