({ data, lock, bgColor }: Props)
| 21 | } |
| 22 | |
| 23 | const LessonBox = ({ data, lock, bgColor }: Props) => { |
| 24 | const [isVisit, setIsVisit] = useState(false); |
| 25 | const { formatMessage } = useIntl(); |
| 26 | |
| 27 | let DynamicWrapper; |
| 28 | |
| 29 | if (lock) { |
| 30 | DynamicWrapper = Fragment; |
| 31 | } else { |
| 32 | const WrapperLessonBox = ({ children }) => ( |
| 33 | <IntlLink href={`/[lang]/learn/[lesson]`} query={{ lesson: data.slug }}> |
| 34 | {children} |
| 35 | </IntlLink> |
| 36 | ); |
| 37 | DynamicWrapper = WrapperLessonBox; |
| 38 | } |
| 39 | |
| 40 | useEffect(() => { |
| 41 | const lessonData = lookie.get(`lesson.${data.key}`); |
| 42 | |
| 43 | if (lessonData && lessonData.lastStep > 0) { |
| 44 | setIsVisit(true); |
| 45 | } |
| 46 | }, [data.key]); |
| 47 | |
| 48 | const startText = formatMessage({ id: isVisit ? 'general.continue' : 'general.start' }); |
| 49 | |
| 50 | const direction = useLanguageDirection(); |
| 51 | const arrowDirectionName = direction === 'rtl' ? 'arrow-left' : 'arrow-right'; |
| 52 | |
| 53 | return ( |
| 54 | <DynamicWrapper className="hover:outline-8"> |
| 55 | <div |
| 56 | className={cx( |
| 57 | 'bg-[url(/images/noise.png)] relative bg-repeat bg-contain transition-all duration-300 w-full h-44 bg-center rounded-xl py-3 px-4 flex flex-col shadow-xl hover:shadow-2xl flex-1 select-none', |
| 58 | bgColor || 'bg-[#324A34]/80 hover:bg-[#324A34]', |
| 59 | !lock ? '' : 'cursor-not-allowed text-center grayscale', |
| 60 | )} |
| 61 | > |
| 62 | <h2 className="mb-1 text-lg font-bold"> |
| 63 | <FormattedMessage id={data.title} /> |
| 64 | </h2> |
| 65 | <p className="text-sm text-neutral-300 max-w-[70%] mt-2"> |
| 66 | <FormattedMessage id={data.description} /> |
| 67 | </p> |
| 68 | {!lock && ( |
| 69 | <div className="flex items-end text-sm flex-1 justify-between"> |
| 70 | <div className="inline-flex items-center text-sm text-neutral-300 absolute top-5 ltr:right-4 rtl:left-4 space-x-2"> |
| 71 | {data.videoCount && ( |
| 72 | <span className="inline-flex items-center rtl:right-0 "> |
| 73 | <Icon icon="video-camera" size={16} className="mx-1" /> |
| 74 | {data.videoCount} |
| 75 | </span> |
| 76 | )} |
| 77 | <span className="inline-flex items-center "> |
| 78 | <Icon icon="document-duplicate" size={16} className="mx-1"/> |
| 79 | {data.stepCount} |
| 80 | </span> |
nothing calls this directly
no test coverage detected