Skip to content

Commit

Permalink
Fixed feedback from Sean
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaitya2108 committed Jan 8, 2025
1 parent ab5d2ef commit 5977c0a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
23 changes: 5 additions & 18 deletions src/components/common/VerticalFormItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { HTMLInputTypeAttribute, ReactNode, useState } from 'react';
import { UseFormRegisterReturn, useForm } from 'react-hook-form';
import styles from './style.module.scss';

import { AiOutlineSearch } from 'react-icons/ai';
interface InputTypeProps {
element: 'input';
type: HTMLInputTypeAttribute;
Expand Down Expand Up @@ -97,13 +97,13 @@ const VerticalFormItem = (props: VerticalFormProps) => {
return (
<div className={styles.formItem}>
<div className={styles.formInput}>
<div className={styles.iconContainer}>{icon}</div>
<div className={styles.iconContainer}>{<AiOutlineSearch />}</div>
<div>
<h1>Selected: {selectedOptions.join(', ')}</h1>
<div>
<input
type="text"
placeholder="Search..."
placeholder="Click to search"
value={searchTerm}
onChange={e => setSearchTerm(e.target.value)}
className={styles.inputField}
Expand All @@ -119,9 +119,9 @@ const VerticalFormItem = (props: VerticalFormProps) => {
onChange={handleSelectionChange}
// {...formRegister}
>
<option value="" disabled>
{/* <option value="" disabled>
{placeholder}
</option>
</option> */}
{filteredOptions.map(value => (
<option key={value}>{value}</option>
))}
Expand All @@ -133,20 +133,7 @@ const VerticalFormItem = (props: VerticalFormProps) => {
</div>
);
}
// if (element === 'select-multiple') {
// const { options } = props;
// const [searchTerm, setSearchTerm] = useState('');
// const [filteredOptions, setFilteredOptions] = useState(options);

// useEffect(() => {
// setFilteredOptions(options.filter(option => option.toLowerCase().includes(searchTerm.toLowerCase())));
// }, [searchTerm, options]);

// const handleSelectionChange = (event, field) => {
// const selectedValues = Array.from(event.target.selectedOptions, option => option.value);
// setValue()
// }
// }
return null;
};

Expand Down
7 changes: 3 additions & 4 deletions src/pages/admin/attendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import withAccessType, { GetServerSidePropsWithAuth } from '@/lib/hoc/withAccess
import type { NextPage } from 'next';
import { AdminAPI, EventAPI } from '@/lib/api';
import { SubmitHandler, useForm } from 'react-hook-form';
import { AiOutlineArrowDown } from 'react-icons/ai';
import {} from 'react-icons/vsc';
import { AiOutlineArrowDown, AiOutlineCalendar } from 'react-icons/ai';
import { PublicEvent } from '@/lib/types/apiResponses';

interface FormValues {
Expand Down Expand Up @@ -47,7 +46,7 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({
} catch (error) {
showToast('An error occurred');
}
// TODO

};

return (
Expand All @@ -68,7 +67,7 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({
error={errors.email}
/>
<VerticalFormItem
icon={<AiOutlineArrowDown />}
icon={<AiOutlineCalendar />}
element="select"
name="event"
options={allEvents.map(event => event.title)}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/admin/milestone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import withAccessType, { GetServerSidePropsWithAuth } from '@/lib/hoc/withAccess
import { PermissionService } from '@/lib/services';
import type { NextPage } from 'next';
import { SubmitHandler, useForm } from 'react-hook-form';
import { AiOutlineMail } from 'react-icons/ai';
import { AiOutlineStar } from 'react-icons/ai';
import { VscLock } from 'react-icons/vsc';

interface FormValues {
Expand All @@ -29,7 +29,7 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({ authToken }) => {
} = useForm<FormValues>();

const onSubmit: SubmitHandler<FormValues> = async ({ name, points }) => {
// TODO

try {
await AdminAPI.createMilestone(authToken, name, Number(points));
showToast('Successfully awarded attendance!');
Expand All @@ -45,7 +45,7 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({ authToken }) => {
description="Award points to all active users (e.g. for ACM's 8 year anniversary)"
/>
<VerticalFormItem
icon={<AiOutlineMail />}
icon={<AiOutlineStar />}
element="input"
name="name"
type="text"
Expand Down
8 changes: 4 additions & 4 deletions src/pages/admin/points.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AdminAPI, EventAPI } from '@/lib/api';

import type { NextPage } from 'next';
import { SubmitHandler, useForm } from 'react-hook-form';
import { AiOutlineMail, AiOutlineArrowDown } from 'react-icons/ai';
import { AiOutlineMail, AiOutlineCalendar } from 'react-icons/ai';
import { VscLock } from 'react-icons/vsc';

interface FormValues {
Expand Down Expand Up @@ -62,7 +62,7 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({
/>

<VerticalFormItem
icon={<AiOutlineArrowDown />}
icon={<AiOutlineCalendar />}
element="select"
name="event"
options={properEvents}
Expand All @@ -73,11 +73,11 @@ const AwardPointsPage: NextPage<AwardPointsPageProps> = ({
error={errors.event}
/>
<VerticalFormItem
icon={<AiOutlineArrowDown />}
icon={<AiOutlineMail />}
element="select-multiple"
name="email"
options={sortedEmails}
placeholder="Select a User"
placeholder=""
formRegister={register('email', {
required: 'Required',
})}
Expand Down

0 comments on commit 5977c0a

Please sign in to comment.