Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: appointment display #423

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
22 changes: 12 additions & 10 deletions src/components/appointment/AppointmentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ const AppointmentCard: React.VFC<AppointmentCardProps> = ({
periodEndedAt: null,
appointmentPlanId: '',
})
setRescheduleModalVisible(true)
}

if (loadingOrderProduct) {
Expand Down Expand Up @@ -564,16 +565,17 @@ const AppointmentCard: React.VFC<AppointmentCardProps> = ({
startedAt={period.startedAt}
isEnrolled={period.currentMemberBooked}
isExcluded={period.isBookedReachLimit || period.available}
onClick={() =>
!period.currentMemberBooked && !period.isBookedReachLimit && !period.available
? setRescheduleAppointment({
rescheduleAppointment: true,
periodStartedAt: period.startedAt,
periodEndedAt: period.endedAt,
appointmentPlanId: appointmentPlanId,
})
: null
}
onClick={() => {
if (!period.currentMemberBooked && !period.isBookedReachLimit) {
setRescheduleAppointment({
rescheduleAppointment: true,
periodStartedAt: period.startedAt,
periodEndedAt: period.endedAt,
appointmentPlanId: appointmentPlanId,
})
setRescheduleModalVisible(false)
}
}}
/>
</div>
))}
Expand Down
60 changes: 20 additions & 40 deletions src/components/appointment/AppointmentPeriodCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ const AppointmentPeriodCollection: React.VFC<{
period => moment(period.startedAt).format('YYYY-MM-DD(dd)'),
appointmentPeriods
.filter(v => v.available)
.filter(
v =>
!diffPlanBookedTimes?.some(
diffPlanBookedTime => moment(v.startedAt).format('YYYY-MM-DD HH:mm').toString() === diffPlanBookedTime,
),
)
.filter(v =>
reservationType && reservationAmount && reservationAmount !== 0
? moment(v.startedAt).subtract(reservationType, reservationAmount).toDate() > moment().toDate()
Expand All @@ -50,41 +44,27 @@ const AppointmentPeriodCollection: React.VFC<{
<StyledScheduleTitle>{moment(periods[0].startedAt).format('YYYY-MM-DD(dd)')}</StyledScheduleTitle>

<div className="d-flex flex-wrap justify-content-start">
{periods.map(period => {
const ItemElem = (
<AppointmentItem
key={period.id}
id={period.id}
startedAt={period.startedAt}
isEnrolled={period.currentMemberBooked}
isExcluded={period.isBookedReachLimit || !period.available}
onClick={() =>
!period.currentMemberBooked && !period.isBookedReachLimit && !period.available
? onClick(period)
: null
{periods.map(period => (
<AppointmentItem
key={period.id}
id={period.id}
startedAt={period.startedAt}
isEnrolled={period.currentMemberBooked}
isExcluded={period.isBookedReachLimit || !period.available}
onClick={() => {
if (!isAuthenticated && setAuthModalVisible) {
setAuthModalVisible(true)
} else if (
!period.currentMemberBooked &&
!period.isBookedReachLimit &&
period.available &&
isAuthenticated
) {
onClick(period)
}
/>
)

return isAuthenticated && !period.currentMemberBooked ? (
<div key={period.id} onClick={() => onClick && onClick(period)}>
{ItemElem}
</div>
) : isAuthenticated && period.currentMemberBooked ? (
<div
key={period.id}
onClick={() => {
return
}}
>
{ItemElem}
</div>
) : (
<div key={period.id} onClick={() => setAuthModalVisible && setAuthModalVisible(true)}>
{ItemElem}
</div>
)
})}
}}
/>
))}
</div>
</div>
))}
Expand Down
8 changes: 3 additions & 5 deletions src/containers/common/AuthButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ const AuthButton: React.VFC = () => {

<Responsive.Desktop>
{renderAuthButton?.(setVisible) || (
<a href="/#">
<Button className="ml-2" onClick={handleClick}>
{formatMessage(commonMessages.button.loginRegister)}
</Button>
</a>
<Button className="ml-2" onClick={handleClick}>
{formatMessage(commonMessages.button.loginRegister)}
</Button>
)}
</Responsive.Desktop>
</>
Expand Down