fix ConflictsWithWarning
This commit is contained in:
@@ -1,5 +1,96 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import ConflictsWithWarning from '@views/components/common/ConflictsWithWarning/ConflictsWithWarning';
|
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 = {
|
const meta = {
|
||||||
title: 'Components/Common/ConflictsWithWarning',
|
title: 'Components/Common/ConflictsWithWarning',
|
||||||
@@ -9,8 +100,10 @@ const meta = {
|
|||||||
},
|
},
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
argTypes: {
|
argTypes: {
|
||||||
ConflictingCourse: { control: 'string' },
|
conflicts: { control: 'object' },
|
||||||
SectionNumber: { control: 'string' },
|
},
|
||||||
|
args: {
|
||||||
|
conflicts: [ExampleCourse, ExampleCourse2],
|
||||||
},
|
},
|
||||||
} satisfies Meta<typeof ConflictsWithWarning>;
|
} satisfies Meta<typeof ConflictsWithWarning>;
|
||||||
export default meta;
|
export default meta;
|
||||||
@@ -19,7 +112,6 @@ type Story = StoryObj<typeof meta>;
|
|||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
args: {
|
args: {
|
||||||
ConflictingCourse: 'BVO 311C',
|
conflicts: [ExampleCourse, ExampleCourse2],
|
||||||
SectionNumber: '47280',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,43 +1,37 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Course } from 'src/shared/types/Course';
|
||||||
|
import clsx from 'clsx';
|
||||||
import Text from '../Text/Text';
|
import Text from '../Text/Text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Props for ConflictWithWarningProps
|
* Props for ConflictWithWarningProps
|
||||||
*/
|
*/
|
||||||
export interface ConflictsWithWarningProps {
|
export interface ConflictsWithWarningProps {
|
||||||
ConflictingCourse: string;
|
className?: string;
|
||||||
SectionNumber: string;
|
conflicts: Course[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ConflictsWithWarning component is used to display a warning message when a course conflicts
|
* The ConflictsWithWarning component is used to display a warning message when a course conflicts
|
||||||
* with another course as part of the labels and details section
|
* with another course as part of the labels and details section
|
||||||
*
|
*
|
||||||
* @param props ConflictsWithWarningProps
|
* @param props ConflictsWithWarningProps
|
||||||
*/
|
*/
|
||||||
export default function ConflictsWithWarning( { ConflictingCourse, SectionNumber }: ConflictsWithWarningProps): JSX.Element {
|
export default function ConflictsWithWarning({ className, conflicts }: 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} ) {
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
variant='mini'
|
variant='mini'
|
||||||
as='span'
|
className={clsx(
|
||||||
className='text-white'
|
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>
|
</Text>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user