diff --git a/src/components/TopicDetail/TopicDetail.tsx b/src/components/TopicDetail/TopicDetail.tsx index f78bccef2..6156a191a 100644 --- a/src/components/TopicDetail/TopicDetail.tsx +++ b/src/components/TopicDetail/TopicDetail.tsx @@ -10,9 +10,10 @@ import { httpGet } from '../../lib/http'; import { isLoggedIn } from '../../lib/jwt'; import { isTopicDone, + renderTopicProgress, ResourceType, - toggleMarkTopicDone, -} from '../../lib/user-resource-progress'; + toggleMarkTopicDone as toggleMarkTopicDoneApi, +} from '../../lib/resource-progress'; import { useKeydown } from '../../hooks/use-keydown'; export function TopicDetail() { @@ -32,22 +33,21 @@ export function TopicDetail() { const [resourceId, setResourceId] = useState(''); const [resourceType, setResourceType] = useState('roadmap'); - const toggleResourceProgress = (isDone: boolean) => { + const toggleMarkTopicDone = (isDone: boolean) => { setIsUpdatingProgress(true); - toggleMarkTopicDone({ topicId, resourceId, resourceType }, isDone) + toggleMarkTopicDoneApi({ topicId, resourceId, resourceType }, isDone) .then(() => { setIsDone(isDone); setIsActive(false); + renderTopicProgress(topicId, isDone); }) - .catch(err => { + .catch((err) => { alert(err.message); console.error(err); }) .finally(() => { setIsUpdatingProgress(false); }); - - console.log('toggle', isDone); }; // Load the topic status when the topic detail is active @@ -168,7 +168,7 @@ export function TopicDetail() { {!isUpdatingProgress && !isDone && (