From 5d5c8824647bcc77bd247ee846fa41dc40726172 Mon Sep 17 00:00:00 2001
From: Valentyna Dudchak <48631216+dudchakk@users.noreply.github.com>
Date: Mon, 14 Oct 2024 19:49:24 +0300
Subject: [PATCH 1/4] Redirect to CompleteProfileBlock after creating offer
(#2605)
* test commit
* conditional navigate
---
src/components/profile-item/ProfileItem.tsx | 5 +++--
.../profile-item/complete-profile.constants.tsx | 4 ++--
.../create-or-edit-offer/CreateOrEditOffer.tsx | 17 +++++++++++------
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/components/profile-item/ProfileItem.tsx b/src/components/profile-item/ProfileItem.tsx
index ef01de7b5..fefb2e32e 100644
--- a/src/components/profile-item/ProfileItem.tsx
+++ b/src/components/profile-item/ProfileItem.tsx
@@ -35,10 +35,11 @@ const ProfileItem = ({
const isOffer = item.id === 'offer'
const handleItemClick = () => {
+ if (isClickable || isOffer) {
+ navigate(`${item.path}#${item.id}`)
+ }
if (isOffer) {
handleOpenDrawer()
- } else if (isClickable) {
- navigate(`${item.path}#${item.id}`)
}
}
diff --git a/src/components/profile-item/complete-profile.constants.tsx b/src/components/profile-item/complete-profile.constants.tsx
index ab040cff2..be389a6c6 100644
--- a/src/components/profile-item/complete-profile.constants.tsx
+++ b/src/components/profile-item/complete-profile.constants.tsx
@@ -37,7 +37,7 @@ export const profileItemsTutor: ProfileItemType[] = [
{
id: 'offer',
icon: ,
- path: ''
+ path: authRoutes.myProfile.path
}
]
@@ -60,7 +60,7 @@ export const profileItemsStudent: ProfileItemType[] = [
{
id: 'offer',
icon: ,
- path: ''
+ path: authRoutes.myProfile.path
}
]
diff --git a/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx b/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx
index 6e27af993..345648da3 100644
--- a/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx
+++ b/src/containers/offer-page/create-or-edit-offer/CreateOrEditOffer.tsx
@@ -1,6 +1,6 @@
import { FC, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
-import { useNavigate } from 'react-router-dom'
+import { useNavigate, useLocation } from 'react-router-dom'
import LeakAddSharpIcon from '@mui/icons-material/LeakAddSharp'
import Typography from '@mui/material/Typography'
import Box from '@mui/material/Box'
@@ -53,6 +53,7 @@ const CreateOrEditOffer: FC = ({
const dispatch = useAppDispatch()
const { t } = useTranslation()
const navigate = useNavigate()
+ const { hash } = useLocation()
const offerAction = existingOffer
? OfferActionsEnum.Edit
@@ -74,12 +75,16 @@ const CreateOrEditOffer: FC = ({
})
)
closeDrawer()
- navigate(
- createUrlPath(
- authRoutes.offerDetails.path,
- existingOffer?._id ?? response?._id
+ if (hash == '#offer') {
+ navigate(`${authRoutes.myProfile.path}#complete`)
+ } else {
+ navigate(
+ createUrlPath(
+ authRoutes.offerDetails.path,
+ existingOffer?._id ?? response?._id
+ )
)
- )
+ }
}
const { loading, fetchData } = useAxios<
From 468b855c7f0e45205a99461e99c61cc78a40493d Mon Sep 17 00:00:00 2001
From: new-user888 <146866673+new-user888@users.noreply.github.com>
Date: Tue, 15 Oct 2024 18:40:59 +0300
Subject: [PATCH 2/4] Create dependabot.yml (#2619)
Adding dependabot
---
.github/dependabot.yml | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 .github/dependabot.yml
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..d1056e513
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,8 @@
+# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
+
+version: 2
+updates:
+ - package-ecosystem: "npm" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "weekly"
From d2f1330c698468480666c61a22220117f44b2cfc Mon Sep 17 00:00:00 2001
From: Yaroslav Chuiko <32570823+YaroslavChuiko@users.noreply.github.com>
Date: Thu, 17 Oct 2024 08:50:57 +0300
Subject: [PATCH 3/4] Use couseCooperation service in the
ChangeResourceConfirmModal (#2614)
* created new service
* fixed tests
---
src/constants/request.ts | 3 +
.../ChangeResourceConfirmModal.tsx | 70 +++++++++----------
src/services/course-cooperation-service.ts | 14 ++++
.../common/interfaces/common.interfaces.ts | 9 ++-
.../ChangeResourceConfirmModal.spec.jsx | 4 +-
5 files changed, 60 insertions(+), 40 deletions(-)
create mode 100644 src/services/course-cooperation-service.ts
diff --git a/src/constants/request.ts b/src/constants/request.ts
index 83cea5bfb..720d33d9d 100644
--- a/src/constants/request.ts
+++ b/src/constants/request.ts
@@ -37,6 +37,9 @@ export const URLs = {
create: '/courses',
patch: '/courses'
},
+ coursesAndCooperations: {
+ getByResourceId: '/courses-cooperations/resource/'
+ },
categories: {
get: '/categories',
getNames: '/categories/names',
diff --git a/src/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.tsx b/src/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.tsx
index 76111cc75..98c2a8dfb 100644
--- a/src/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.tsx
+++ b/src/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.tsx
@@ -5,19 +5,12 @@ import { useTranslation } from 'react-i18next'
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'
import AppButton from '~/components/app-button/AppButton'
-
-import {
- ButtonVariantEnum,
- Course,
- GetCoursesParams,
- ItemsWithCount,
- SizeEnum
-} from '~/types'
import { styles } from '~/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.styles'
import { useModalContext } from '~/context/modal-context'
import Loader from '~/components/loader/Loader'
import useAxios from '~/hooks/use-axios'
-import { CourseService } from '~/services/course-service'
+import { CoursesAndCooperationsService } from '~/services/course-cooperation-service'
+import { ButtonVariantEnum, CourseCooperationResponse, SizeEnum } from '~/types'
interface ChangeResourceConfirmModalProps {
resourceId?: string
@@ -26,40 +19,43 @@ interface ChangeResourceConfirmModalProps {
}
const ChangeResourceConfirmModal = ({
- resourceId,
+ resourceId = '',
title,
onConfirm
}: ChangeResourceConfirmModalProps) => {
const { t } = useTranslation()
const { closeModal } = useModalContext()
- //! replace when new endpoint is ready
- const { response: coursesResponse, loading } = useAxios<
- ItemsWithCount,
- GetCoursesParams
- >({
- service: CourseService.getCourses,
- defaultResponse: { items: [], count: 0 },
+ const getCoursesAndCooperationsByResourceId = useCallback(
+ () => CoursesAndCooperationsService.getByResourceId(resourceId),
+ [resourceId]
+ )
+
+ const { response, loading } = useAxios({
+ service: getCoursesAndCooperationsByResourceId,
+ defaultResponse: {
+ courses: [],
+ cooperations: []
+ } as CourseCooperationResponse,
fetchOnMount: true
})
- const courseList = useMemo(
- () =>
- coursesResponse.items
- .filter((item) => item.sections[0].resources?.length)
- .filter((item) =>
- item.sections.some((res) =>
- res.resources.some((val) => val.resource._id == resourceId)
- )
- )
- .map((item) => ({
- id: item._id,
- title: item.title,
- subTitle: 'course'
- })),
- [coursesResponse.items, resourceId]
+ const courses = response.courses.map((course) => ({
+ id: course._id,
+ title: course.title,
+ subTitle: 'course'
+ }))
+
+ const cooperations = response?.cooperations.map((cooperation) => ({
+ id: cooperation._id,
+ title: cooperation.title,
+ subTitle: 'cooperation'
+ }))
+
+ const affectedItems = useMemo(
+ () => [...courses, ...cooperations],
+ [courses, cooperations]
)
- ////////////////////////////////////!
const handleConfirm = useCallback(() => {
closeModal()
@@ -67,10 +63,10 @@ const ChangeResourceConfirmModal = ({
}, [closeModal, onConfirm])
useEffect(() => {
- if (!loading && !courseList?.length) {
+ if (!loading && !affectedItems.length) {
handleConfirm()
}
- }, [courseList, handleConfirm, loading])
+ }, [affectedItems, handleConfirm, loading])
if (loading) {
return (
@@ -80,7 +76,7 @@ const ChangeResourceConfirmModal = ({
)
}
- if (!loading && !courseList?.length) {
+ if (!loading && !affectedItems?.length) {
return null
}
@@ -107,7 +103,7 @@ const ChangeResourceConfirmModal = ({
- {courseList.map((el) => (
+ {affectedItems.map((el) => (
{el.title}
diff --git a/src/services/course-cooperation-service.ts b/src/services/course-cooperation-service.ts
new file mode 100644
index 000000000..e3c437e1c
--- /dev/null
+++ b/src/services/course-cooperation-service.ts
@@ -0,0 +1,14 @@
+import { AxiosResponse } from 'axios'
+import { URLs } from '~/constants/request'
+import { axiosClient } from '~/plugins/axiosClient'
+import { CourseCooperationResponse } from '~/types'
+import { createUrlPath } from '~/utils/helper-functions'
+
+export const CoursesAndCooperationsService = {
+ getByResourceId: async (
+ resourceId: string
+ ): Promise> =>
+ await axiosClient.get(
+ createUrlPath(URLs.coursesAndCooperations.getByResourceId, resourceId)
+ )
+}
diff --git a/src/types/common/interfaces/common.interfaces.ts b/src/types/common/interfaces/common.interfaces.ts
index 4e703172c..447812d18 100644
--- a/src/types/common/interfaces/common.interfaces.ts
+++ b/src/types/common/interfaces/common.interfaces.ts
@@ -3,7 +3,9 @@ import {
UpdateFiltersInQuery,
UserResponse,
UserGeneralInfo,
- UserRoleEnum
+ UserRoleEnum,
+ Course,
+ Cooperation
} from '~/types'
export interface ItemsWithCount {
@@ -26,6 +28,11 @@ export interface DataByRole {
[UserRoleEnum.Tutor]: T
}
+export type CourseCooperationResponse = {
+ courses: Course[]
+ cooperations: Cooperation[]
+}
+
export interface CategoryInterface {
_id: string
name: string
diff --git a/tests/unit/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.spec.jsx b/tests/unit/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.spec.jsx
index 918f755f5..4b253b07d 100644
--- a/tests/unit/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.spec.jsx
+++ b/tests/unit/containers/change-resource-confirm-modal/ChangeResourceConfirmModal.spec.jsx
@@ -25,7 +25,7 @@ const props = {
}
const fakeData = {
- items: [
+ courses: [
{
_id: 'testId1',
title: 'Course 1',
@@ -75,7 +75,7 @@ const fakeData = {
]
}
],
- count: 2
+ cooperations: []
}
describe('ChangeResourceConfirmModal component tests', () => {
From 8f0f4e4959c82a81f97383ab9c299095c9e1c534 Mon Sep 17 00:00:00 2001
From: Mav-Ivan <110425368+Mav-Ivan@users.noreply.github.com>
Date: Thu, 17 Oct 2024 14:56:52 +0300
Subject: [PATCH 4/4] Changed resources icons (#2615)
* implemented icon for attachements
* remove unnecessary test
* fixed test
* added lesson icon
* fixed test
---
.../IconExtensionWithTitle.tsx | 13 ++-----------
.../add-resources/AddAttachments.constants.tsx | 6 +++++-
.../add-resources/AddLessons.constants.tsx | 7 +++++--
.../CourseSectionContainer.constants.tsx | 8 ++++----
.../resource-item/ResourceItem.constants.ts | 3 ++-
.../AttachmentsContainer.constants.tsx | 2 ++
.../LessonsContainer.constants.tsx | 4 ++--
src/pages/my-resources/MyResources.constants.tsx | 5 +++--
.../IconExtentionWithTitle.spec.jsx | 6 ------
.../resource-item/ResourceItem.spec.jsx | 4 ++--
10 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/src/components/icon-extension-with-title/IconExtensionWithTitle.tsx b/src/components/icon-extension-with-title/IconExtensionWithTitle.tsx
index c1d8e42b8..e9104125d 100644
--- a/src/components/icon-extension-with-title/IconExtensionWithTitle.tsx
+++ b/src/components/icon-extension-with-title/IconExtensionWithTitle.tsx
@@ -4,10 +4,7 @@ import Box from '@mui/material/Box'
import TitleWithDescription from '~/components/title-with-description/TitleWithDescription'
-import {
- convertBytesToProperFormat,
- parseFileName
-} from '~/utils/helper-functions'
+import { convertBytesToProperFormat } from '~/utils/helper-functions'
import { styles } from '~/components/icon-extension-with-title/IconExtensionWithTitle.styles'
interface IconExtensionWithTitleProps {
@@ -25,8 +22,6 @@ const IconExtensionWithTitle: FC = ({
}) => {
const { t } = useTranslation()
- const { fileExtension } = parseFileName(title)
-
const convertSize = (incomingSize: number) => {
const { size: properSize, unit } = convertBytesToProperFormat(incomingSize)
return properSize + ' ' + t(`common.${unit}`)
@@ -34,11 +29,7 @@ const IconExtensionWithTitle: FC = ({
return (
- {icon ? (
- {icon}
- ) : (
- {fileExtension}
- )}
+ {icon && {icon}}
(
-
+ }
+ title={attachment.fileName}
+ />
)
},
diff --git a/src/containers/add-resources/AddLessons.constants.tsx b/src/containers/add-resources/AddLessons.constants.tsx
index a24f85451..60f289a32 100644
--- a/src/containers/add-resources/AddLessons.constants.tsx
+++ b/src/containers/add-resources/AddLessons.constants.tsx
@@ -1,5 +1,5 @@
-import ListAltIcon from '@mui/icons-material/ListAlt'
import Typography from '@mui/material/Typography'
+import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import AppChip from '~/components/app-chip/AppChip'
import IconExtensionWithTitle from '~/components/icon-extension-with-title/IconExtensionWithTitle'
@@ -13,7 +13,10 @@ export const columns = [
label: 'myResourcesPage.lessons.title',
field: 'title',
calculatedCellValue: (lesson: Lesson) => (
- } title={lesson.title} />
+ }
+ title={lesson.title}
+ />
)
},
{
diff --git a/src/containers/course-section/CourseSectionContainer.constants.tsx b/src/containers/course-section/CourseSectionContainer.constants.tsx
index 4a929324d..7b61a2486 100644
--- a/src/containers/course-section/CourseSectionContainer.constants.tsx
+++ b/src/containers/course-section/CourseSectionContainer.constants.tsx
@@ -1,6 +1,6 @@
-import ListAltIcon from '@mui/icons-material/ListAlt'
import NoteAltOutlinedIcon from '@mui/icons-material/NoteAltOutlined'
-import AttachFileIcon from '@mui/icons-material/AttachFile'
+import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined'
+import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import { ResourcesTabsEnum, ResourcesTypesEnum as ResourceType } from '~/types'
@@ -12,7 +12,7 @@ export const menuTypes = {
export const resourcesData = {
lessons: {
resourceTab: ResourcesTabsEnum.Lessons,
- icon:
+ icon:
},
quizzes: {
resourceTab: ResourcesTabsEnum.Quizzes,
@@ -20,7 +20,7 @@ export const resourcesData = {
},
attachments: {
resourceTab: ResourcesTabsEnum.Attachments,
- icon:
+ icon:
}
}
diff --git a/src/containers/course-section/resource-item/ResourceItem.constants.ts b/src/containers/course-section/resource-item/ResourceItem.constants.ts
index 847af7cf2..f54294208 100644
--- a/src/containers/course-section/resource-item/ResourceItem.constants.ts
+++ b/src/containers/course-section/resource-item/ResourceItem.constants.ts
@@ -34,5 +34,6 @@ export const availabilityIcons: Record =
export const resourceIcons: Partial> =
{
[ResourceType.Lesson]: resourcesData.lessons.icon,
- [ResourceType.Quiz]: resourcesData.quizzes.icon
+ [ResourceType.Quiz]: resourcesData.quizzes.icon,
+ [ResourceType.Attachment]: resourcesData.attachments.icon
}
diff --git a/src/containers/my-resources/attachments-container/AttachmentsContainer.constants.tsx b/src/containers/my-resources/attachments-container/AttachmentsContainer.constants.tsx
index dbe480873..e5c2bf741 100644
--- a/src/containers/my-resources/attachments-container/AttachmentsContainer.constants.tsx
+++ b/src/containers/my-resources/attachments-container/AttachmentsContainer.constants.tsx
@@ -1,5 +1,6 @@
import Typography from '@mui/material/Typography'
import AddIcon from '@mui/icons-material/Add'
+import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined'
import IconExtensionWithTitle from '~/components/icon-extension-with-title/IconExtensionWithTitle'
import AppChip from '~/components/app-chip/AppChip'
@@ -22,6 +23,7 @@ export const columns = (
calculatedCellValue: (item: Attachment) => (
}
title={item.fileName}
/>
)
diff --git a/src/containers/my-resources/lessons-container/LessonsContainer.constants.tsx b/src/containers/my-resources/lessons-container/LessonsContainer.constants.tsx
index 0c0661c6d..2163d9bf5 100644
--- a/src/containers/my-resources/lessons-container/LessonsContainer.constants.tsx
+++ b/src/containers/my-resources/lessons-container/LessonsContainer.constants.tsx
@@ -1,6 +1,6 @@
-import ListAltIcon from '@mui/icons-material/ListAlt'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
+import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import { styles } from '~/containers/my-resources/lessons-container/LessonsContainer.styles'
import AppChip from '~/components/app-chip/AppChip'
@@ -29,7 +29,7 @@ export const columns: TableColumn[] = [
return (
-
+
{item.title}
)
diff --git a/src/pages/my-resources/MyResources.constants.tsx b/src/pages/my-resources/MyResources.constants.tsx
index 47da350ec..a32d87dec 100644
--- a/src/pages/my-resources/MyResources.constants.tsx
+++ b/src/pages/my-resources/MyResources.constants.tsx
@@ -1,7 +1,8 @@
import { ReactElement } from 'react'
import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
-import AttachFileIcon from '@mui/icons-material/AttachFile'
+import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined'
+
import NoteAltOutlinedIcon from '@mui/icons-material/NoteAltOutlined'
import QuizOutlinedIcon from '@mui/icons-material/QuizOutlined'
import CategoryIcon from '@mui/icons-material/Category'
@@ -42,7 +43,7 @@ export const tabsData: MyResourcesTabsData = {
[ResourcesTabsEnum.Attachments]: {
title: 'myResourcesPage.tabs.attachments',
content: ,
- icon:
+ icon:
},
[ResourcesTabsEnum.Categories]: {
title: 'myResourcesPage.tabs.categories',
diff --git a/tests/unit/components/icon-extention-with-title/IconExtentionWithTitle.spec.jsx b/tests/unit/components/icon-extention-with-title/IconExtentionWithTitle.spec.jsx
index 48b45e653..caf980a9a 100644
--- a/tests/unit/components/icon-extention-with-title/IconExtentionWithTitle.spec.jsx
+++ b/tests/unit/components/icon-extention-with-title/IconExtentionWithTitle.spec.jsx
@@ -15,12 +15,6 @@ describe('IconExtensionWithTitle test', () => {
expect(title).toBeInTheDocument()
})
- it('Should render icon text', () => {
- const iconText = screen.getByText('doc')
-
- expect(iconText).toBeInTheDocument()
- })
-
it('Should render description', () => {
const description = screen.getByText('21.3 common.kilobytes')
diff --git a/tests/unit/containers/course-section/resource-item/ResourceItem.spec.jsx b/tests/unit/containers/course-section/resource-item/ResourceItem.spec.jsx
index d8365b61b..968dc8d03 100644
--- a/tests/unit/containers/course-section/resource-item/ResourceItem.spec.jsx
+++ b/tests/unit/containers/course-section/resource-item/ResourceItem.spec.jsx
@@ -67,7 +67,7 @@ describe('ResourceItem tests', () => {
})
it('should display lesson icon', () => {
- const lessonIcon = screen.getByTestId('ListAltIcon')
+ const lessonIcon = screen.getByTestId('ArticleOutlinedIcon')
expect(lessonIcon).toBeInTheDocument()
})
@@ -233,7 +233,7 @@ describe('ResourceItem tests when resourceType attachment', () => {
})
it('should properly display attachment', () => {
- const attachmentItem = screen.getByText('png')
+ const attachmentItem = screen.getByTestId('DescriptionOutlinedIcon')
expect(attachmentItem).toBeInTheDocument()
})