Skip to content

Commit

Permalink
feat: Create icon helper (#77)
Browse files Browse the repository at this point in the history
* create icon helper

* change getStatusIcon to StatusIcon react component

---------

Co-authored-by: Razboy20 <razboy20@gmail.com>
  • Loading branch information
2 people authored and doprz committed Mar 6, 2024
1 parent 00e0019 commit ccea0f4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/shared/util/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { SVGProps } from 'react';
import ClosedIcon from '~icons/material-symbols/lock';
import WaitlistIcon from '~icons/material-symbols/timelapse';
import CancelledIcon from '~icons/material-symbols/warning';
import { Status } from '../types/Course';

/**
* Get Icon component based on status
* @param props.status status
* @returns React.ReactElement - the icon component
*/
export function StatusIcon(props: SVGProps<SVGSVGElement> & { status: Status }): React.ReactElement {
const { status, ...rest } = props;

switch (props.status) {
case Status.WAITLISTED:
return <WaitlistIcon {...rest} />;
case Status.CLOSED:
return <ClosedIcon {...rest} />;
case Status.CANCELLED:
return <CancelledIcon {...rest} />;
default:
}
}

0 comments on commit ccea0f4

Please sign in to comment.