Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/QueryProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import { type ReactNode } from 'react'
import { QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

import { queryClient } from '~/plugins/queryClient'
import { queryClient, testQueryClient } from '~/plugins/queryClient'

type QueryProviderProps = {
children: ReactNode
testMode?: boolean
}

const QueryProvider: React.FC<QueryProviderProps> = ({ children }) => {
const QueryProvider: React.FC<QueryProviderProps> = ({
children,
testMode = false
}) => {
return (
<QueryClientProvider client={queryClient}>
<QueryClientProvider client={testMode ? testQueryClient : queryClient}>
<ReactQueryDevtools />
{children}
</QueryClientProvider>
Expand Down
21 changes: 11 additions & 10 deletions src/components/active-students/ActiveStudentsBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ const ActiveStudentsBlock = () => {
}
})

const activeStudents = data?.items.map((cooperation) => (
<ActiveStudent
cooperationId={cooperation._id}
firstName={cooperation.user.firstName}
key={cooperation._id}
lastName={cooperation.user.lastName}
photo={cooperation.user.photo}
subjectName={cooperation.subject.name}
/>
))

if (isLoading) {
return <Loader pageLoad size={50} />
}
Expand Down Expand Up @@ -70,16 +81,6 @@ const ActiveStudentsBlock = () => {
</>
)

const activeStudents = data.items.map((cooperation) => (
<ActiveStudent
cooperationId={cooperation._id}
firstName={cooperation.user.firstName}
key={cooperation._id}
lastName={cooperation.user.lastName}
photo={cooperation.user.photo}
subjectName={cooperation.offer.subject.name}
/>
))
return (
<>
<Typography sx={styles.title}>{t('activeStudents.title')}</Typography>
Expand Down
5 changes: 2 additions & 3 deletions src/constants/translations/en/offer-details-page.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "Send a Request to Create a Cooperation",
"inputs": {
"level": "Choose the appropriate level of tutoring you require.",
"info": "Ask the questions you have, describe your learning needs or specify your preferred teaching approach."
"additionalInfo": "Ask the questions you have, describe your learning needs or specify your preferred teaching approach."
},
"labels": {
"level": "Your required level",
"preferredPrice": "Set your preferred price for the lesson. Keep in mind that choosing a lower or higher price may affect tutor availability.",
"info": "Additional information"
"additionalInfo": "Additional information"
},
"successMessage": "Request for cooperation sent successfully"
},
Expand All @@ -18,7 +18,6 @@
"student": "Offer details",
"tutor": "Offer details"
},

"description": {
"student": "Here, you can access all the essential details about the offer you've selected. This page includes details about the chosen offer. Take a moment to review this information and make an informed decision about your tutoring needs.",
"tutor": "Here, you can access all the essential details about the offer you've selected. This page includes details about the chosen offer. Take a moment to review this information and make an informed decision about your tutoring needs."
Expand Down
5 changes: 2 additions & 3 deletions src/constants/translations/uk/offer-details-page.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"description": "Надіслати запит на створення співпраці",
"inputs": {
"level": "Виберіть відповідний рівень, який вам потрібен.",
"info": "Задайте свої запитання, опишіть свої потреби, або вкажіть бажаний підхід до викладання."
"additionalInfo": "Задайте свої запитання, опишіть свої потреби, або вкажіть бажаний підхід до викладання."
},
"labels": {
"level": "Ваш рівень",
"preferredPrice": "Встановіть бажану ціну за урок. Майте на увазі, що вибір нижчої або вищої ціни може вплинути на доступність репетитора.",
"info": "Додаткова інформація"
"additionalInfo": "Додаткова інформація"
},
"successMessage": "Запит на співпрацю надіслано успішно"
},
Expand All @@ -18,7 +18,6 @@
"student": "Деталі пропозиції",
"tutor": "Деталі пропозиції"
},

"description": {
"student": "Тут ви можете отримати доступ до всіх важливих деталей про вибрану пропозицію. На цій сторінці міститься інформація про вибрану пропозицію. Знайдіть час, щоб переглянути цю інформацію та прийняти обґрунтоване рішення щодо ваших потреб у репетиторстві.",
"tutor": "Тут ви можете отримати доступ до всіх важливих деталей про вибрану пропозицію. На цій сторінці міститься інформація про вибрану пропозицію. Знайдіть час, щоб переглянути цю інформацію та прийняти обґрунтоване рішення щодо ваших потреб у репетиторстві."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import { snackbarVariants } from '~/constants'
import { styles } from '~/containers/my-cooperations/accept-cooperation-modal/AcceptCooperation.styles'
import useSnackbarAlert from '~/hooks/use-snackbar-alert'
import { useAppSelector } from '~/hooks/use-redux'

interface AcceptCooperationModalProps {
cooperation: Cooperation
Expand All @@ -41,26 +42,25 @@ const AcceptCooperationModal: React.FC<AcceptCooperationModalProps> = ({
const { closeModal } = useModalContext()
const { checkConfirmation } = useConfirm()
const { handleAlert, handleErrorAlert } = useSnackbarAlert()
const [minPrice, maxPrice] = minMaxPrice(cooperation.offer.price, 0.25)
const [minPrice, maxPrice] = minMaxPrice(cooperation.price, 0.25)
const { userRole } = useAppSelector((state) => state.appMain)

const needAction = cooperation.user.role !== cooperation.needAction.role
const needAction = userRole === cooperation.needAction.role

const handleUpdateCooperation = useCallback(
(params: Omit<UpdateCooperationsParams, '_id'>) => {
return cooperationService.updateCooperation({
_id: cooperation._id,
...params
})
},
[cooperation._id]
)
const handleUpdateCooperation = (
params?: Omit<UpdateCooperationsParams, '_id'>
) =>
cooperationService.updateCooperation({
_id: cooperation._id,
...params
})

const handleUpdateOffer = useCallback(
() =>
OfferService.updateOfferWithBaseService(cooperation.offer._id, {
OfferService.updateOfferWithBaseService(cooperation.offer, {
enrolledUsers: []
}),
[cooperation.offer._id]
[cooperation.offer]
)

const onResponse = () => {
Expand Down Expand Up @@ -193,7 +193,7 @@ const AcceptCooperationModal: React.FC<AcceptCooperationModalProps> = ({
title={t('cooperationsPage.acceptModal.level')}
/>
<TitleWithDescription
description={`${cooperation.offer.price} ${t('common.uah')}`}
description={`${cooperation.price} ${t('common.uah')}`}
style={styles.titleDescription}
title={t('cooperationsPage.acceptModal.price')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@ const CooperationCard: FC<CooperationCardProps> = ({
sx
}) => {
const { t } = useTranslation()
const { user, offer, updatedAt, proficiencyLevel, price } = cooperation
const { user, updatedAt, proficiencyLevel, price, status, needAction } =
cooperation

const { userRole } = useAppSelector((state) => state.appMain)

const roleBasedStatus =
cooperation.needAction.role === userRole
needAction.role === userRole
? StatusEnum.NeedAction
: StatusEnum.RequestToClose

const cooperationStatus =
cooperation.status === StatusEnum.RequestToClose
? roleBasedStatus
: cooperation.status
status === StatusEnum.RequestToClose ? roleBasedStatus : cooperation.status

return (
<AppCard onClick={onClick} sx={spliceSx(styles.root, sx)}>
Expand All @@ -51,7 +50,7 @@ const CooperationCard: FC<CooperationCardProps> = ({
firstName={user.firstName}
lastName={user.lastName}
photo={user.photo}
role={user.role}
role={user.role[0]}
sx={styles.userProfileInfo}
/>
<Box sx={styles.priceWithStatus}>
Expand All @@ -64,12 +63,12 @@ const CooperationCard: FC<CooperationCardProps> = ({
</Box>
</Box>
<SubjectLevelChips
color={offer.category.appearance.color}
color={cooperation.category.appearance.color}
proficiencyLevel={proficiencyLevel}
subject={offer.subject.name}
subject={cooperation.subject.name}
sx={styles.chipBox}
/>
<Typography sx={styles.title}>{cooperation.offer.title}</Typography>
<Typography sx={styles.title}>{cooperation.title}</Typography>
</AppCard>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ const CooperationDetails = () => {
isError
} = useQuery({
queryFn: getCooperation,
queryKey: ['cooperation', id],
options: {
staleTime: Infinity
}
queryKey: ['cooperation', id]
})

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const columns: TableColumn<Cooperation>[] = [
firstName={item.user.firstName}
lastName={item.user.lastName}
photo={item.user.photo}
role={item.user.role}
role={item.user.role[0]}
sx={styles.profileInfo}
/>
)
Expand All @@ -34,15 +34,15 @@ export const columns: TableColumn<Cooperation>[] = [
{
label: 'cooperationsPage.tableHeaders.title',
calculatedCellValue: (item: Cooperation) => (
<Typography sx={styles.title}>{item.offer.title}</Typography>
<Typography sx={styles.title}>{item.title}</Typography>
)
},
{
label: 'cooperationsPage.tableHeaders.subject',
calculatedCellValue: (item: Cooperation) => (
<SubjectLevelChips
proficiencyLevel={item.proficiencyLevel}
subject={item.offer.subject.name}
subject={item.subject.name}
sx={styles.chips}
/>
)
Expand All @@ -63,7 +63,7 @@ export const columns: TableColumn<Cooperation>[] = [
label: 'cooperationsPage.tableHeaders.status',
calculatedCellValue: ({ user, needAction, status }: Cooperation) => {
const cooperationStatus =
user.role !== needAction?.role && status === StatusEnum.Pending
user.role[0] !== needAction.role && status === StatusEnum.Pending
? StatusEnum.NeedAction
: status
return <StatusChip status={cooperationStatus} />
Expand Down
Loading