-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bda0282
commit 1599e48
Showing
2 changed files
with
113 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 16 additions & 22 deletions
38
src/views/components/common/ConflictsWithWarning/ConflictsWithWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
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[]; | ||
} | ||
|
||
/** | ||
* 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 | ||
* | ||
* @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> | ||
); | ||
} |