Skip to content

Commit d62557a

Browse files
committed
removed duplicates
1 parent 96b154a commit d62557a

File tree

8 files changed

+19
-114
lines changed

8 files changed

+19
-114
lines changed

src/components/active-students/ActiveStudentsBlock.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ const ActiveStudentsBlock = () => {
8181
</>
8282
)
8383

84-
// const activeStudents = data.items.map((cooperation) => (
85-
// <ActiveStudent
86-
// cooperationId={cooperation._id}
87-
// firstName={cooperation.user.firstName}
88-
// key={cooperation._id}
89-
// lastName={cooperation.user.lastName}
90-
// photo={cooperation.user.photo}
91-
// subjectName={cooperation.offer.subject.name}
92-
// />
93-
// ))
9484
return (
9585
<>
9686
<Typography sx={styles.title}>{t('activeStudents.title')}</Typography>

src/containers/my-cooperations/cooperation-card/CooperationCard.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const CooperationCard: FC<CooperationCardProps> = ({
3434
const { userRole } = useAppSelector((state) => state.appMain)
3535

3636
const roleBasedStatus =
37-
needAction === userRole ? StatusEnum.NeedAction : StatusEnum.RequestToClose
37+
needAction.role === userRole
38+
? StatusEnum.NeedAction
39+
: StatusEnum.RequestToClose
3840

3941
const cooperationStatus =
4042
status === StatusEnum.RequestToClose ? roleBasedStatus : cooperation.status
@@ -48,7 +50,7 @@ const CooperationCard: FC<CooperationCardProps> = ({
4850
firstName={user.firstName}
4951
lastName={user.lastName}
5052
photo={user.photo}
51-
role={user.role}
53+
role={user.role[0]}
5254
sx={styles.userProfileInfo}
5355
/>
5456
<Box sx={styles.priceWithStatus}>

src/containers/my-cooperations/cooperations-container/CooperationContainer.constants.tsx

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const columns: TableColumn<Cooperation>[] = [
2525
firstName={item.user.firstName}
2626
lastName={item.user.lastName}
2727
photo={item.user.photo}
28-
role={item.user.role}
28+
role={item.user.role[0]}
2929
sx={styles.profileInfo}
3030
/>
3131
)
@@ -63,45 +63,7 @@ export const columns: TableColumn<Cooperation>[] = [
6363
label: 'cooperationsPage.tableHeaders.status',
6464
calculatedCellValue: ({ user, needAction, status }: Cooperation) => {
6565
const cooperationStatus =
66-
user.role !== needAction && status === StatusEnum.Pending
67-
? StatusEnum.NeedAction
68-
: status
69-
return <StatusChip status={cooperationStatus} />
70-
}
71-
},
72-
{
73-
label: 'cooperationsPage.tableHeaders.title',
74-
calculatedCellValue: (item: Cooperation) => (
75-
<Typography sx={styles.title}>{item.title}</Typography>
76-
)
77-
},
78-
{
79-
label: 'cooperationsPage.tableHeaders.subject',
80-
calculatedCellValue: (item: Cooperation) => (
81-
<SubjectLevelChips
82-
proficiencyLevel={item.proficiencyLevel}
83-
subject={item.subject.name}
84-
sx={styles.chips}
85-
/>
86-
)
87-
},
88-
{
89-
label: 'cooperationsPage.tableHeaders.price',
90-
field: 'price',
91-
calculatedCellValue: (item: Cooperation, { t }: AdditionalPropsInterface) =>
92-
`${item.price} ${t('common.uah')}`
93-
},
94-
{
95-
label: 'cooperationsPage.tableHeaders.updated',
96-
field: 'updatedAt',
97-
calculatedCellValue: (item: Cooperation) =>
98-
getFormattedDate({ date: item.updatedAt })
99-
},
100-
{
101-
label: 'cooperationsPage.tableHeaders.status',
102-
calculatedCellValue: ({ user, needAction, status }: Cooperation) => {
103-
const cooperationStatus =
104-
user.role !== needAction && status === StatusEnum.Pending
66+
user.role[0] !== needAction.role && status === StatusEnum.Pending
10567
? StatusEnum.NeedAction
10668
: status
10769
return <StatusChip status={cooperationStatus} />

src/containers/my-cooperations/my-cooperations-details/MyCooperationsDetails.tsx

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -232,46 +232,9 @@ const MyCooperationsDetails = () => {
232232
</Typography>
233233
<Typography>{`${cooperationDetails.price} UAH/hour`}</Typography>
234234
</Box>
235-
<CooperationCompletion
236-
cooperationStatus={cooperationDetails.status}
237-
onCloseCooperation={handleCloseCooperation}
238-
userRole={userRole}
239-
/>
235+
{cooperationCompletion}
240236
</Box>
241-
<Typography sx={style.titles}>
242-
{t('cooperationDetailsPage.tutoringSubject')}
243-
</Typography>
244-
<Box sx={style.subjectContainer}>
245-
<Box sx={style.categoryContainer}>
246-
<CategoryIcon sx={style.iconColor(categoryColor)} />
247-
<Typography>{cooperationDetails.category.name}</Typography>
248-
</Box>
249-
<SubjectLevelChips
250-
color={cooperationDetails.category.appearance.color}
251-
proficiencyLevel={cooperationDetails.proficiencyLevel}
252-
subject={cooperationDetails.subject.name}
253-
/>
254-
</Box>
255-
<Typography sx={style.titles}>
256-
{t('cooperationDetailsPage.aboutCooperation')}
257-
</Typography>
258-
<ShowMoreCollapse
259-
collapsedSize={28}
260-
collapsedTextLength={100}
261-
description={cooperationDetails.description}
262-
sx={style.aboutCooperation}
263-
withoutTitle
264-
/>
265-
<Typography sx={style.titles}>
266-
{t('cooperationDetailsPage.tutoringLanguages')}
267-
</Typography>
268-
<Box sx={style.languageContainer}>{languages}</Box>
269-
<Typography sx={style.titles}>
270-
{t('cooperationDetailsPage.pricing')}
271-
</Typography>
272-
<Typography>{`${cooperationDetails.price} UAH/hour`}</Typography>
273237
</Box>
274-
{cooperationCompletion}
275238
</Box>
276239
)
277240
}

src/containers/offer-details/enroll-offer/EnrollOffer.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,6 @@ const EnrollOffer: React.FC<EnrollOfferProps> = ({ offer, enrollOffer }) => {
6565
void enrollOffer()
6666
}
6767

68-
// const postOffer = () => {
69-
// return cooperationService.createCooperation({
70-
// ...data,
71-
// receiver: offer.author._id,
72-
// receiverRole: offer.authorRole,
73-
// offer: offer._id,
74-
// subject: offer.subject._id,
75-
// category: offer.category._id,
76-
// description: offer.description,
77-
// languages: offer.languages
78-
// })
79-
// }
80-
8168
const { isPending, mutate: createCooperation } = useMutation({
8269
mutationFn: cooperationService.createCooperation,
8370
queryKey: ['cooperations'],
@@ -108,7 +95,7 @@ const EnrollOffer: React.FC<EnrollOfferProps> = ({ offer, enrollOffer }) => {
10895
handleSubmit
10996
} = useForm<EnrollOfferForm>({
11097
initialValues: {
111-
proficiencyLevel: offer.proficiencyLevel,
98+
proficiencyLevel: offer.proficiencyLevel[0],
11299
price: offer.price,
113100
additionalInfo: '',
114101
title: offer.title
@@ -133,7 +120,7 @@ const EnrollOffer: React.FC<EnrollOfferProps> = ({ offer, enrollOffer }) => {
133120

134121
const levelOptions = offer.proficiencyLevel.map((level) => ({
135122
title: level,
136-
value: [level]
123+
value: level
137124
}))
138125

139126
const handleFieldChange =

src/types/cooperation/interfaces/cooperation.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface CreateCooperationsParams extends EnrollOfferForm {
7777
receiverRole: UserRoleEnum
7878
subject: string
7979
category: string
80-
proficiencyLevel: ProficiencyLevelEnum[]
80+
proficiencyLevel: ProficiencyLevelEnum
8181
description: string
8282
languages: LanguagesEnum[]
8383
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Offer, ProficiencyLevelEnum } from '~/types'
22

33
export interface EnrollOfferForm extends Pick<Offer, 'price'> {
4-
proficiencyLevel: ProficiencyLevelEnum[]
4+
proficiencyLevel: ProficiencyLevelEnum
55
title: string
66
additionalInfo?: string
77
}

tests/unit/containers/my-cooperations/my-cooperations-details/MyCooperationsDetails.spec.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { URLs } from '~/constants/request'
44
import MyCooperationsDetails from '~/containers/my-cooperations/my-cooperations-details/MyCooperationsDetails.tsx'
55

66
import { screen, fireEvent } from '@testing-library/react'
7-
import { vi } from 'vitest'
7+
import { expect, vi } from 'vitest'
88

99
const mockedCooperation = { ...getCooperationByIdMockResponse }
1010
mockedCooperation.languages = ['Ukrainian', 'English']
@@ -31,20 +31,21 @@ describe('MyCooperationsDetails component', () => {
3131
})
3232

3333
it('should render title', async () => {
34+
const imgUserUrl = import.meta.env.VITE_APP_IMG_USER_URL
35+
console.log('Imported VITE_APP_IMG_USER_URL:', imgUserUrl)
36+
3437
const title = await screen.findAllByText('cooperationDetailsPage.details')
3538

3639
expect(title).toHaveLength(2)
3740
expect(...title).toBeInTheDocument()
3841
})
3942

4043
it('should render languages', async () => {
41-
const language1 = await screen.findAllByText('Ukrainian')
42-
expect(language1).toHaveLength(2)
43-
expect(...language1).toBeInTheDocument()
44+
const language1 = await screen.findByText('Ukrainian')
45+
expect(language1).toBeInTheDocument()
4446

45-
const language2 = await screen.findAllByText('English')
46-
expect(language2).toHaveLength(2)
47-
expect(...language2).toBeInTheDocument()
47+
const language2 = await screen.findByText('English')
48+
expect(language2).toBeInTheDocument()
4849
})
4950

5051
it('should open chat after clicking on chat-button', async () => {

0 commit comments

Comments
 (0)