Merge branch 'feat-conflict-row' into hackathon
This commit is contained in:
@@ -1,5 +1,96 @@
|
||||
import { Meta, StoryObj } from '@storybook/react';
|
||||
import ConflictsWithWarning from '@views/components/common/ConflictsWithWarning/ConflictsWithWarning';
|
||||
import { Course, Status } from 'src/shared/types/Course';
|
||||
import { CourseMeeting } from 'src/shared/types/CourseMeeting';
|
||||
import Instructor from 'src/shared/types/Instructor';
|
||||
|
||||
export const ExampleCourse: Course = new Course({
|
||||
courseName: 'ELEMS OF COMPTRS/PROGRAMMNG-WB',
|
||||
creditHours: 3,
|
||||
department: 'C S',
|
||||
description: [
|
||||
'Problem solving and fundamental algorithms for various applications in science, business, and on the World Wide Web, and introductory programming in a modern object-oriented programming language.',
|
||||
'Only one of the following may be counted: Computer Science 303E, 312, 312H. Credit for Computer Science 303E may not be earned after a student has received credit for Computer Science 314, or 314H. May not be counted toward a degree in computer science.',
|
||||
'May be counted toward the Quantitative Reasoning flag requirement.',
|
||||
'Designed to accommodate 100 or more students.',
|
||||
'Taught as a Web-based course.',
|
||||
],
|
||||
flags: ['Quantitative Reasoning'],
|
||||
fullName: 'C S 303E ELEMS OF COMPTRS/PROGRAMMNG-WB',
|
||||
instructionMode: 'Online',
|
||||
instructors: [
|
||||
new Instructor({
|
||||
firstName: 'Bevo',
|
||||
lastName: 'Bevo',
|
||||
fullName: 'Bevo Bevo',
|
||||
}),
|
||||
],
|
||||
isReserved: false,
|
||||
number: '303E',
|
||||
schedule: {
|
||||
meetings: [
|
||||
new CourseMeeting({
|
||||
days: ['Tuesday', 'Thursday'],
|
||||
endTime: 660,
|
||||
startTime: 570,
|
||||
}),
|
||||
],
|
||||
},
|
||||
semester: {
|
||||
code: '12345',
|
||||
season: 'Spring',
|
||||
year: 2024,
|
||||
},
|
||||
status: Status.WAITLISTED,
|
||||
uniqueId: 12345,
|
||||
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
|
||||
});
|
||||
export const ExampleCourse2: Course = new Course({
|
||||
courseName: 'PRINCIPLES OF COMPUTER SYSTEMS',
|
||||
creditHours: 3,
|
||||
department: 'C S',
|
||||
description: [
|
||||
'Restricted to computer science majors.',
|
||||
'An introduction to computer systems software abstractions with an emphasis on the connection of these abstractions to underlying computer hardware. Key abstractions include threads, virtual memory, protection, and I/O. Requires writing of synchronized multithreaded programs and pieces of an operating system.',
|
||||
'Computer Science 439 and 439H may not both be counted.',
|
||||
'Prerequisite: Computer Science 429, or 429H with a grade of at least C-.',
|
||||
'May be counted toward the Independent Inquiry flag requirement.',
|
||||
],
|
||||
flags: ['Independent Inquiry'],
|
||||
fullName: 'C S 439 PRINCIPLES OF COMPUTER SYSTEMS',
|
||||
instructionMode: 'In Person',
|
||||
instructors: [
|
||||
new Instructor({
|
||||
firstName: 'Allison',
|
||||
lastName: 'Norman',
|
||||
fullName: 'Allison Norman',
|
||||
}),
|
||||
],
|
||||
isReserved: false,
|
||||
number: '439',
|
||||
schedule: {
|
||||
meetings: [
|
||||
new CourseMeeting({
|
||||
days: ['Tuesday', 'Thursday'],
|
||||
startTime: 930,
|
||||
endTime: 1050,
|
||||
}),
|
||||
new CourseMeeting({
|
||||
days: ['Friday'],
|
||||
startTime: 600,
|
||||
endTime: 720,
|
||||
}),
|
||||
],
|
||||
},
|
||||
semester: {
|
||||
code: '12345',
|
||||
season: 'Spring',
|
||||
year: 2024,
|
||||
},
|
||||
status: Status.WAITLISTED,
|
||||
uniqueId: 67890,
|
||||
url: 'https://utdirect.utexas.edu/apps/registrar/course_schedule/20242/12345/',
|
||||
});
|
||||
|
||||
const meta = {
|
||||
title: 'Components/Common/ConflictsWithWarning',
|
||||
@@ -9,8 +100,10 @@ const meta = {
|
||||
},
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
ConflictingCourse: { control: 'string' },
|
||||
SectionNumber: { control: 'string' },
|
||||
conflicts: { control: 'object' },
|
||||
},
|
||||
args: {
|
||||
conflicts: [ExampleCourse, ExampleCourse2],
|
||||
},
|
||||
} satisfies Meta<typeof ConflictsWithWarning>;
|
||||
export default meta;
|
||||
@@ -19,7 +112,6 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
ConflictingCourse: 'BVO 311C',
|
||||
SectionNumber: '47280',
|
||||
conflicts: [ExampleCourse, ExampleCourse2],
|
||||
},
|
||||
};
|
||||
@@ -1,12 +1,14 @@
|
||||
import React from 'react';
|
||||
import { Course } from 'src/shared/types/Course';
|
||||
import clsx from 'clsx';
|
||||
import Text from '../Text/Text';
|
||||
|
||||
/**
|
||||
* Props for ConflictWithWarningProps
|
||||
*/
|
||||
export interface ConflictsWithWarningProps {
|
||||
ConflictingCourse: string;
|
||||
SectionNumber: string;
|
||||
className?: string;
|
||||
conflicts: Course[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15,29 +17,21 @@ export interface ConflictsWithWarningProps {
|
||||
*
|
||||
* @param props ConflictsWithWarningProps
|
||||
*/
|
||||
export default function ConflictsWithWarning( { ConflictingCourse, SectionNumber }: ConflictsWithWarningProps): JSX.Element {
|
||||
const UniqueCourseConflictText = `${ConflictingCourse} (${SectionNumber})`;
|
||||
|
||||
return (
|
||||
<div className="min-w-21 w-21 flex flex-col items-start gap-2.5 rounded bg-[#AF2E2D] p-2.5">
|
||||
<ConflictsWithoutWarningText>
|
||||
Conflicts With:
|
||||
</ConflictsWithoutWarningText>
|
||||
<ConflictsWithoutWarningText>
|
||||
{UniqueCourseConflictText}
|
||||
</ConflictsWithoutWarningText>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ConflictsWithoutWarningText( {children}: {children: string} ) {
|
||||
export default function ConflictsWithWarning({ className, conflicts }: ConflictsWithWarningProps): JSX.Element {
|
||||
return (
|
||||
<Text
|
||||
variant='mini'
|
||||
as='span'
|
||||
className='text-white'
|
||||
className={clsx(
|
||||
className,
|
||||
'min-w-21 w-21 flex flex-col items-start gap-2.5 rounded bg-[#AF2E2D] p-2.5 text-white'
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
<div>Conflicts With:</div>
|
||||
{conflicts.map(course => (
|
||||
<div>
|
||||
{`${course.department} ${course.number} (${course.uniqueId})`}
|
||||
</div>
|
||||
))}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ import { UserSchedule } from '@shared/types/UserSchedule';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Button } from '../../common/Button/Button';
|
||||
import Icon from '../../common/Icon/Icon';
|
||||
import Text from '../../common/Text/Text';
|
||||
import styles from './TableRow.module.scss';
|
||||
import ConflictsWithWarning from '../../common/ConflictsWithWarning/ConflictsWithWarning';
|
||||
import AddIcon from '~icons/material-symbols/add-circle';
|
||||
|
||||
interface Props {
|
||||
isSelected: boolean;
|
||||
@@ -54,7 +54,7 @@ export default function TableRow({ row, isSelected, activeSchedule, onClick }: P
|
||||
return () => {
|
||||
element.classList.remove(styles.inActiveSchedule);
|
||||
};
|
||||
}, [activeSchedule, element.classList]);
|
||||
}, [activeSchedule, course, element.classList]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeSchedule || !course) {
|
||||
@@ -84,20 +84,14 @@ export default function TableRow({ row, isSelected, activeSchedule, onClick }: P
|
||||
|
||||
return ReactDOM.createPortal(
|
||||
<>
|
||||
<Button className={styles.rowButton} onClick={onClick} variant='secondary'>
|
||||
<Icon name='bar_chart' color='white' size='medium' />
|
||||
</Button>
|
||||
{conflicts.length > 0 && (
|
||||
<div className={styles.conflictTooltip}>
|
||||
<div className={styles.body}>
|
||||
{conflicts.map(c => (
|
||||
<Text /* size='small' */ key={c.uniqueId}>
|
||||
{c.department} {c.number} ({c.uniqueId})
|
||||
</Text>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
icon={AddIcon}
|
||||
className={styles.rowButton}
|
||||
color='ut-burntorange'
|
||||
onClick={onClick}
|
||||
variant='single'
|
||||
/>
|
||||
{conflicts.length > 0 && <ConflictsWithWarning className={styles.conflictTooltip} conflicts={conflicts} />}
|
||||
</>,
|
||||
container
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user