Skip to content

Commit

Permalink
fixed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nebby2105 committed Dec 4, 2024
1 parent c1ebcad commit 0e86f8c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
ButtonVariantEnum,
SizeEnum,
CooperationMaterialsAccessEnum,
UserRoleEnum
UserRoleEnum,
StatusEnum
} from '~/types'
import { useAppSelector } from '~/hooks/use-redux'

interface CooperationCompletionProps {
onCloseCooperation: () => void
Expand All @@ -27,6 +29,7 @@ const CooperationCompletion: React.FC<CooperationCompletionProps> = ({
userRole
}) => {
const { t } = useTranslation()
const cooperationStatus = useAppSelector((state) => state.cooperations.status)

const [materialsAccess, setMaterialsAccess] =
useState<CooperationMaterialsAccessEnum>(
Expand All @@ -47,6 +50,7 @@ const CooperationCompletion: React.FC<CooperationCompletionProps> = ({
>
<AppButton
data-testid='close-cooperation-btn'
disabled={cooperationStatus !== StatusEnum.Active}
onClick={onCloseCooperation}
size={SizeEnum.Medium}
sx={styles.closeBtn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,22 @@ const CooperationDetails = () => {
return cooperationContent
}

const isCooperationClosingRequestSend =
response.needAction === userRole &&
response.status === StatusEnum.RequestToClose
const closeCooperationInitiator =
response.needAction === response.receiverRole
? response.initiator
: response.receiver

const acceptClosingProccess = !isClosed && (
const acceptClosingProcess = !isClosed && (
<AcceptCooperationClosing
onAccept={handleCooperationCloseAccept}
user={response.initiator.firstName ?? 'user'}
user={closeCooperationInitiator.firstName}
/>
)

const isCooperationClosingRequestSend =
response.needAction === userRole &&
response.status === StatusEnum.RequestToClose

const iconConditionals = isNotesOpen ? (
<KeyboardDoubleArrowRightIcon />
) : (
Expand Down Expand Up @@ -200,7 +205,7 @@ const CooperationDetails = () => {
</Box>
{activeTab === CooperationTabsEnum.Activities &&
isCooperationClosingRequestSend &&
acceptClosingProccess}
acceptClosingProcess}
<Box sx={styles.notesBlock}>
<Box sx={styles.pageContent}>{pageContent()}</Box>
{!isDesktop && isNotesOpen && (
Expand Down
4 changes: 4 additions & 0 deletions src/types/cooperation/interfaces/cooperation.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ export interface Cooperation extends CommonEntityFields {
role: UserRoleEnum
}
initiator: Pick<UserResponse, 'firstName' | 'lastName'>
initiatorRole: 'tutor' | 'student'
title: Offer['title']
price: Offer['price']
proficiencyLevel: ProficiencyLevelEnum
status: StatusEnum
needAction: UserRoleEnum
receiver: Pick<UserResponse, 'firstName' | 'lastName'>
receiverRole: 'tutor' | 'student'
sections: CourseSection[]
}

Expand Down Expand Up @@ -52,6 +55,7 @@ export interface MyCooperationDetails<TOffer extends Offer> {
proficiencyLevel: ProficiencyLevelEnum
initiator: UserResponse
initiatorRole: UserRoleEnum
status: StatusEnum
}

export interface CreateCooperationsParams extends EnrollOfferForm {
Expand Down

0 comments on commit 0e86f8c

Please sign in to comment.