Skip to content

Commit

Permalink
[ORG-131] Buttons do not appear in event when it's past (#117)
Browse files Browse the repository at this point in the history
* usecase updated with the new exception

* exception added in view

* black

* test

* black

* add restriction in FE for the event buttons in the past
  • Loading branch information
carlotacb authored Jan 14, 2024
1 parent 87ec6a6 commit c963980
Showing 1 changed file with 53 additions and 46 deletions.
99 changes: 53 additions & 46 deletions organizator/app/(tabs)/(home)/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export default function EventPage() {
});
};

const isPast = () =>
events?.startDate ? events.startDate < new Date().toISOString() : true;

console.log(isPast());

return (
<Container>
<KeyboardAvoidingView
Expand Down Expand Up @@ -254,56 +259,58 @@ export default function EventPage() {
</View>
) : (
<View style={{ padding: 30 }}>
<ButtonsRowContainerLeft>
{isParticipant ? (
applied ? (
<AppliedContainer>
<TextLine>
<ApplicationStatus>
Your application is:
</ApplicationStatus>
<InformativeChip
name={applicationStatus}
backgroundColor={getColorForApplicationStatus(
applicationStatus,
)}
/>
</TextLine>
</AppliedContainer>
) : (
<Button
title="Apply now"
onPress={() => {
applyToEvent();
}}
color={systemColors.action}
/>
)
) : isEditable ? null : (
<>
{(isOrganizer || isOrganizerAdmin) && (
{!isPast() && (
<ButtonsRowContainerLeft>
{isParticipant ? (
applied ? (
<AppliedContainer>
<TextLine>
<ApplicationStatus>
Your application is:
</ApplicationStatus>
<InformativeChip
name={applicationStatus}
backgroundColor={getColorForApplicationStatus(
applicationStatus,
)}
/>
</TextLine>
</AppliedContainer>
) : (
<Button
title="Edit"
title="Apply now"
onPress={() => {
setIsEditable(true);
applyToEvent();
}}
color={systemColors.edit}
iconName="pencil"
color={systemColors.action}
/>
)}
{isOrganizerAdmin && (
<Button
title="Delete"
onPress={() => {
setShowAlert(true);
}}
color={systemColors.destroy}
iconName="trash"
/>
)}
</>
)}
</ButtonsRowContainerLeft>
)
) : isEditable ? null : (
<>
{(isOrganizer || isOrganizerAdmin) && (
<Button
title="Edit"
onPress={() => {
setIsEditable(true);
}}
color={systemColors.edit}
iconName="pencil"
/>
)}
{isOrganizerAdmin && (
<Button
title="Delete"
onPress={() => {
setShowAlert(true);
}}
color={systemColors.destroy}
iconName="trash"
/>
)}
</>
)}
</ButtonsRowContainerLeft>
)}
<EventDetails event={events} />
</View>
)}
Expand Down

0 comments on commit c963980

Please sign in to comment.