mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 18:29:15 +03:00
feat: likes state
This commit is contained in:
parent
9d67c14fee
commit
b82c2203bf
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import moment from 'moment';
|
||||
import * as helpers from '@educt/helpers';
|
||||
import { Link as ReactRouterLink } from 'react-router-dom';
|
||||
@ -76,9 +76,11 @@ interface ICourseInfoProps extends BoxProps {
|
||||
}
|
||||
export const CourseInfo: React.FC<ICourseInfoProps> = props => {
|
||||
const { id, lessonsCount, studentsCount, likesCount, ...boxProps } = props;
|
||||
const [likes, setLikes] = useState<number>(Number.parseInt(likesCount, 10));
|
||||
|
||||
const handleLikeCourse = (id: string) => () => {
|
||||
// TODO set like request
|
||||
setLikes(likes => likes + 1);
|
||||
console.log(`like course: ${id}`);
|
||||
};
|
||||
|
||||
@ -96,7 +98,7 @@ export const CourseInfo: React.FC<ICourseInfoProps> = props => {
|
||||
</Text>
|
||||
|
||||
<Button onClick={handleLikeCourse(id)} leftIcon={<MdThumbUpOffAlt />} variant='ghost'>
|
||||
{likesCount}
|
||||
{likes}
|
||||
</Button>
|
||||
</Flex>
|
||||
</Box>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user