Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Savy011/fullstackopen-exercises. My Exercise Submissions for FullStack Open fullstackopen.com/en
Something went wrong. Try again.
1.2 kB · 46 lines
TSX
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { CoursePart } from '../types';
const assertNever = (value: never): never => { throw new Error( `Unhandled discriminated union member: ${JSON.stringify(value)}` )}
const Part = ({ coursePart }: { coursePart: CoursePart }): JSX.Element => { switch(coursePart.kind) { case "base": return ( <div> <p><b>{coursePart.name} ({coursePart.exerciseCount})</b></p> <p><i>{coursePart.description}</i></p> </div> ) case "group": return ( <div> <p><b>{coursePart.name} ({coursePart.exerciseCount})</b></p> <p>Group Execises: <i>{coursePart.groupProjectCount}</i></p> </div> ) case "background": return ( <div> <p><b>{coursePart.name} ({coursePart.exerciseCount})</b></p> <p><i>{coursePart.description}</i></p> <p>Submit To: <i>{coursePart.backgroundMaterial}</i></p> </div> ); case "special": return ( <div> <p><b>{coursePart.name} ({coursePart.exerciseCount})</b></p> <p><i>{coursePart.description}</i></p> <p>Requirements: <i>{coursePart.requirements.join(', ')}</i></p> </div> ); default: return assertNever(coursePart) }};
export default Part