diff --git a/components/JobSkillItem/index.tsx b/components/JobSkillItem/index.tsx index 02f2db1f..ba1ce9a0 100644 --- a/components/JobSkillItem/index.tsx +++ b/components/JobSkillItem/index.tsx @@ -3,80 +3,79 @@ import { useRouter } from "next/router" import { useTranslation } from "next-i18next" import classNames from "classnames" - import PlusIcon from "~public/icons/Add.svg" import "./index.scss" // Props -interface Props { +interface Props extends React.ComponentPropsWithoutRef<"div"> { skill?: JobSkill editable: boolean hasJob: boolean } -const JobSkillItem = React.forwardRef((props, ref) => { - const router = useRouter() - const { t } = useTranslation("common") - const locale = - router.locale && ["en", "ja"].includes(router.locale) ? router.locale : "en" +const JobSkillItem = React.forwardRef( + ({ ...props }, forwardedRef) => { + const router = useRouter() + const { t } = useTranslation("common") + const locale = + router.locale && ["en", "ja"].includes(router.locale) + ? router.locale + : "en" - const classes = classNames({ - JobSkill: true, - editable: props.editable, - }) + const classes = classNames({ + JobSkill: true, + editable: props.editable, + }) - const imageClasses = classNames({ - placeholder: !props.skill, - editable: props.editable && props.hasJob, - }) + const imageClasses = classNames({ + placeholder: !props.skill, + editable: props.editable && props.hasJob, + }) - const skillImage = () => { - let jsx: React.ReactNode + const skillImage = () => { + let jsx: React.ReactNode - if (props.skill) { - jsx = ( - {props.skill.name[locale]} - ) - } else { - jsx = ( -
- {props.editable && props.hasJob ? : ""} -
- ) + if (props.skill) { + jsx = ( + {props.skill.name[locale]} + ) + } else { + jsx = ( +
+ {props.editable && props.hasJob ? : ""} +
+ ) + } + + return jsx } - return jsx - } + const label = () => { + let jsx: React.ReactNode - const label = () => { - let jsx: React.ReactNode + if (props.skill) { + jsx =

{props.skill.name[locale]}

+ } else if (props.editable && props.hasJob) { + jsx =

{t("job_skills.state.selectable")}

+ } else { + jsx =

{t("job_skills.state.no_skill")}

+ } - if (props.skill) { - jsx =

{props.skill.name[locale]}

- } else if (props.editable && props.hasJob) { - jsx =

Select a skill

- } else { - jsx =

No skill

+ return jsx } - return jsx - } - - const skillItem = () => { return ( -
+
{skillImage()} {label()}
) } - - return skillItem() -}) +) export default JobSkillItem