-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Mark button with on Lesson details page #3198
base: develop
Are you sure you want to change the base?
Conversation
|
if (!cooperation?.sections) return | ||
|
||
cooperation?.sections?.some((section) => { | ||
const resource = section.resources?.find( | ||
(resource) => resource.resource._id === lessonId | ||
) | ||
|
||
if (resource) { | ||
setCompletionStatus(resource.completionStatus) | ||
return true | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should refactor this.
Why did you use some
if you don't use return value of that function?
return true
in if
statement is a very bad practice
Also, you could have an array of resourceId
values, with flatMap
usage and use that to check if there is id that you need
const { data: cooperation } = useQuery({ | ||
queryFn: getCooperation, | ||
queryKey: ['cooperation', id] | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add staleTime: Infinity
to this useQuery
. So you can use the cached value of cooperation since you can go to the Lesson page from the Cooperation page.
And also add caching to useQuery
inside this component
const handleResponse = () => { | ||
setCompletionStatus(CompletionStatusEnum.Completed) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should mutate some keys to invalidate this lesson and trigger auto-refetch instead of setting local state
}) | ||
|
||
useEffect(() => { | ||
if (!cooperation?.sections) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add braces here, please
useEffect(() => { | ||
if (!cooperation?.sections) return | ||
|
||
cooperation?.sections?.some((section) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already checked that in 102 line
cooperation?.sections?.some((section) => { | |
cooperation.sections?.some((section) => { |
|
||
const noteData = { | ||
isPrivate: false, | ||
text: 'This is Note' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text: 'This is Note' | |
text: 'This is Note' |
}) | ||
|
||
it('should create new cooperation', async () => { | ||
mockAxiosClient.onPost(new RegExp(URLs.cooperations.create)).reply(200) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check if it works without RegExp
mockAxiosClient.onPost(new RegExp(URLs.cooperations.create)).reply(200) | |
mockAxiosClient.onPost(URLs.cooperations.create).reply(200) |
new RegExp( | ||
URLs.cooperations.updateStatusById | ||
.replace(':id', id) | ||
.replace(':resourceId', lessonId) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new RegExp( | |
URLs.cooperations.updateStatusById | |
.replace(':id', id) | |
.replace(':resourceId', lessonId) | |
) | |
URLs.cooperations.updateStatusById | |
.replace(':id', id) | |
.replace(':resourceId', lessonId) |
import { createUrlPath } from '~/utils/helper-functions' | ||
import { useAppSelector } from '~/hooks/use-redux' | ||
import { useModalContext } from '~/context/modal-context' | ||
import ChangeResourceConfirmModal from '~/containers/change-resource-confirm-modal/ChangeResourceConfirmModal' | ||
|
||
const LessonDetails = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add React.FC
please
CompletionStatusEnum, | ||
TypographyVariantEnum, | ||
UserRoleEnum | ||
} from '~/types' | ||
import { createUrlPath } from '~/utils/helper-functions' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, try to replace createUrlPath
with getFullUrl
function. We are trying to get rid of old one, so since you are working in this component, try to replace that
2025-02-14.20-12-20.mp4