|
|
@ -12,12 +12,12 @@ import { |
|
|
|
type ResourceType, |
|
|
|
type ResourceType, |
|
|
|
updateResourceProgress, |
|
|
|
updateResourceProgress, |
|
|
|
} from '../../lib/resource-progress'; |
|
|
|
} from '../../lib/resource-progress'; |
|
|
|
import CloseIcon from '../../icons/close.svg'; |
|
|
|
|
|
|
|
import { useToast } from '../../hooks/use-toast'; |
|
|
|
import { useToast } from '../../hooks/use-toast'; |
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
import { useAuth } from '../../hooks/use-auth'; |
|
|
|
import { pageProgressMessage } from '../../stores/page'; |
|
|
|
import { pageProgressMessage } from '../../stores/page'; |
|
|
|
import { MemberProgressModalHeader } from './MemberProgressModalHeader'; |
|
|
|
import { MemberProgressModalHeader } from './MemberProgressModalHeader'; |
|
|
|
import {replaceChildren} from "../../lib/dom.ts"; |
|
|
|
import { replaceChildren } from '../../lib/dom.ts'; |
|
|
|
|
|
|
|
import { XIcon } from 'lucide-react'; |
|
|
|
|
|
|
|
|
|
|
|
export type ProgressMapProps = { |
|
|
|
export type ProgressMapProps = { |
|
|
|
member: TeamMember; |
|
|
|
member: TeamMember; |
|
|
@ -68,12 +68,12 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
teamId: string, |
|
|
|
teamId: string, |
|
|
|
memberId: string, |
|
|
|
memberId: string, |
|
|
|
resourceType: string, |
|
|
|
resourceType: string, |
|
|
|
resourceId: string |
|
|
|
resourceId: string, |
|
|
|
) { |
|
|
|
) { |
|
|
|
const { error, response } = await httpGet<MemberProgressResponse>( |
|
|
|
const { error, response } = await httpGet<MemberProgressResponse>( |
|
|
|
`${ |
|
|
|
`${ |
|
|
|
import.meta.env.PUBLIC_API_URL |
|
|
|
import.meta.env.PUBLIC_API_URL |
|
|
|
}/v1-get-member-resource-progress/${teamId}/${memberId}?resourceType=${resourceType}&resourceId=${resourceId}` |
|
|
|
}/v1-get-member-resource-progress/${teamId}/${memberId}?resourceType=${resourceType}&resourceId=${resourceId}`,
|
|
|
|
); |
|
|
|
); |
|
|
|
if (error || !response) { |
|
|
|
if (error || !response) { |
|
|
|
toast.error(error?.message || 'Failed to get member progress'); |
|
|
|
toast.error(error?.message || 'Failed to get member progress'); |
|
|
@ -160,14 +160,14 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
resourceType: resourceType as ResourceType, |
|
|
|
resourceType: resourceType as ResourceType, |
|
|
|
topicId, |
|
|
|
topicId, |
|
|
|
}, |
|
|
|
}, |
|
|
|
newStatus |
|
|
|
newStatus, |
|
|
|
) |
|
|
|
) |
|
|
|
.then(() => { |
|
|
|
.then(() => { |
|
|
|
renderTopicProgress(topicId, newStatus); |
|
|
|
renderTopicProgress(topicId, newStatus); |
|
|
|
getMemberProgress(teamId, member._id, resourceType, resourceId).then( |
|
|
|
getMemberProgress(teamId, member._id, resourceType, resourceId).then( |
|
|
|
(data) => { |
|
|
|
(data) => { |
|
|
|
setMemberProgress(data); |
|
|
|
setMemberProgress(data); |
|
|
|
} |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
.catch((err) => { |
|
|
@ -227,7 +227,7 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
updateTopicStatus( |
|
|
|
updateTopicStatus( |
|
|
|
topicId, |
|
|
|
topicId, |
|
|
|
!isCurrentStatusLearning ? 'learning' : 'pending' |
|
|
|
!isCurrentStatusLearning ? 'learning' : 'pending', |
|
|
|
); |
|
|
|
); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -236,7 +236,7 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
updateTopicStatus( |
|
|
|
updateTopicStatus( |
|
|
|
topicId, |
|
|
|
topicId, |
|
|
|
!isCurrentStatusSkipped ? 'skipped' : 'pending' |
|
|
|
!isCurrentStatusSkipped ? 'skipped' : 'pending', |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
@ -298,7 +298,8 @@ export function MemberProgressModal(props: ProgressMapProps) { |
|
|
|
}`}
|
|
|
|
}`}
|
|
|
|
onClick={onClose} |
|
|
|
onClick={onClose} |
|
|
|
> |
|
|
|
> |
|
|
|
<img alt={'close'} src={CloseIcon.src} className="h-4 w-4" /> |
|
|
|
<XIcon className="h-4 w-4" /> |
|
|
|
|
|
|
|
|
|
|
|
<span className="sr-only">Close modal</span> |
|
|
|
<span className="sr-only">Close modal</span> |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|