Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Przemek committed Dec 10, 2024
1 parent 248aef1 commit 99761da
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const ProposedTermsContent = ({ consultation, onClose }: Props) => {
}, [onClose, setShowBookTermSuccess]);

const onClick = useCallback(async () => {
if (consultation.consultation_term_id && selectedTime) {
if (consultation?.consultation_term_id && selectedTime) {
setLoading(true);
const response = await bookConsultationTerm(
consultation.consultation_term_id,
consultation?.consultation_term_id,
selectedTime.toISOString()
);
if (response.success) {
Expand All @@ -79,7 +79,7 @@ const ProposedTermsContent = ({ consultation, onClose }: Props) => {
setLoading(false);
}
}, [
consultation.consultation_term_id,
consultation?.consultation_term_id,
selectedTime,
bookConsultationTerm,
close,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ const UserSelectDatePicker = ({ consultation, onClose }: Props) => {
}, [consultation]);

const onClick = useCallback(async () => {
if (consultation.consultation_term_id && selectedDate) {
if (consultation?.consultation_term_id && selectedDate) {
setLoading(true);
try {
if ((inComing && isApproved) || isRejected) {
await changeConsultationTerm(
consultation.consultation_term_id,
consultation?.consultation_term_id,
selectedDate.toISOString(),
consultation.executed_at || "",
user.value?.id
);
} else {
await bookConsultationTerm(
consultation.consultation_term_id,
consultation?.consultation_term_id,
selectedDate.toISOString()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const ConsultationCardButtons = ({ consultation, showBookTerm }: Props) => {
/>
);
}
if (isStarted && consultation.consultation_term_id) {
if (isStarted && consultation?.consultation_term_id) {
return (
<ConsultationCardJoinButton
consultationTermId={consultation.consultation_term_id}
consultationTermId={consultation?.consultation_term_id}
consultationId={consultation.id}
term={String(consultation.executed_at)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const ConsultationTutorCardButtons = ({ consultation }: Props) => {
const { approveConsultationTerm, rejectConsultationTerm } =
useContext(EscolaLMSContext);
const { t } = useTranslation();
const { consultation_term_id } = consultation;

const menuItems = useMemo(
() => [
Expand All @@ -26,7 +25,10 @@ const ConsultationTutorCardButtons = ({ consultation }: Props) => {
icon={<IconSuccess />}
text={t("Confirm")}
onClick={() =>
approveConsultationTerm(consultation_term_id, consultation.date)
approveConsultationTerm(
consultation?.consultation_term_id,
consultation.date
)
}
/>
),
Expand All @@ -38,15 +40,18 @@ const ConsultationTutorCardButtons = ({ consultation }: Props) => {
icon={<IconCircleError />}
text={t("Cancel")}
onClick={() =>
rejectConsultationTerm(consultation_term_id, consultation.date)
rejectConsultationTerm(
consultation?.consultation_term_id,
consultation.date
)
}
/>
),
},
],
[
approveConsultationTerm,
consultation_term_id,
consultation?.consultation_term_id,
rejectConsultationTerm,
t,
consultation.date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ const ConsultationTutorCardContentDateInfo = ({ consultation }: Props) => {
type={DateInfoTypes.ACCEPTED}
date={consultation.date}
info={
isStarted && consultation.consultation_term_id ? (
isStarted && consultation?.consultation_term_id ? (
<ConsultationTutorCardContentDateInfoButtonsStyles>
<ConsultationCardJoinButton
consultationTermId={consultation.consultation_term_id}
consultationTermId={consultation?.consultation_term_id}
// @ts-ignore
consultationId={consultation.consultation_id}
consultationId={consultation?.consultation_id}
term={consultation.date}
/>
</ConsultationTutorCardContentDateInfoButtonsStyles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const ConsultationTutorCardContentUserInfo = ({ consultation }: Props) => {
text={t("Confirm")}
onClick={() =>
approveConsultationTerm(
consultation.consultation_term_id,
consultation?.consultation_term_id,
consultation.date,
user.id
)
Expand All @@ -116,7 +116,7 @@ const ConsultationTutorCardContentUserInfo = ({ consultation }: Props) => {
text={t("Cancel")}
onClick={() =>
rejectConsultationTerm(
consultation.consultation_term_id,
consultation?.consultation_term_id,
consultation.date,
user.id
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
const ConsultationTutorCardImage = ({ product }: Props) => {
if (!product) return null;
return (
<Link to={`/consultations/${product.consultation_term_id}`}>
<Link to={`/consultations/${product?.consultation_term_id}`}>
{/* @ts-ignore TODO:add to sdk */}
{product.consultation_media ? (
<ResponsiveImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ConsultationTutorCard: React.FC<ConsultationTutorCardProps> = (props) => {
return (
<ConsultationTutorCardStyles>
<CourseCard
id={consultation.consultation_term_id}
id={consultation?.consultation_term_id}
image={<ConsultationTutorCardImage product={consultation} />}
title={<ConsultationTutorCardStatus consultation={consultation} />}
subtitle={<p>{consultation.related_product?.name}</p>}
Expand Down
1 change: 1 addition & 0 deletions src/components/Profile/ProfileTutorConsultations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const ProfileTutorConsultations = ({

const handleRefreshIfTimePassed = useCallback(() => {
consultationsData.forEach((consultation) => {
console.log("refreshing consultation", consultation);
if (!consultation.is_started && !consultation.is_ended) {
refreshConsultation(
// @ts-ignore
Expand Down

0 comments on commit 99761da

Please sign in to comment.