feat: Create icon helper (#77)
* create icon helper * change getStatusIcon to StatusIcon react component --------- Co-authored-by: Razboy20 <razboy20@gmail.com>
This commit is contained in:
24
src/shared/util/icons.tsx
Normal file
24
src/shared/util/icons.tsx
Normal file
@@ -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:
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user