Skip to content

Commit

Permalink
ID search support
Browse files Browse the repository at this point in the history
  • Loading branch information
P-man2976 committed Jan 10, 2024
1 parent c60ea6f commit 68fa3d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/timetable/editor/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ import { useClassList, useCourseList, useGradeList } from '@/services/info';

const Card = React.memo(
({
defaultIsOpen,
_id,
title,
description,
schedules,
owner,
meta,
...rest
}: UserSchedule) => {
const { isOpen, onToggle } = useDisclosure();
}: UserSchedule & { defaultIsOpen?: boolean }) => {
const { isOpen, onToggle } = useDisclosure({ defaultIsOpen });
const {
isOpen: importModalOpen,
onOpen: importModalOnOpen,
Expand Down
9 changes: 7 additions & 2 deletions src/components/timetable/editor/UserScheduleSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function UserScheduleSearch() {

const [isFilterEnabled, { toggle }] = useBoolean(false);

const [inputVal, setInputVal] = useState('');
const [inputVal, setInputVal] = useState(searchParams.get('q') ?? '');
const [grade, setGrade] = useState<GradeInfo>();
const [classInfo, setClass] = useState<ClassInfo>();
const [course, setCourse] = useState<CourseInfo>();
Expand Down Expand Up @@ -138,7 +138,12 @@ export function UserScheduleSearch() {
{data
?.filter(({ owner }) => owner !== user._id)
.map((schedule) => (
<UserScheduleCard key={schedule._id} {...schedule} />
<UserScheduleCard
// expand by default when search by ID
defaultIsOpen={schedule._id === inputVal}
key={schedule._id}
{...schedule}
/>
))}
</VStack>
)}
Expand Down

0 comments on commit 68fa3d6

Please sign in to comment.