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

hide zupass button when not on devcon event #2142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 15 additions & 6 deletions apps/passport-client/new-components/screens/Home/NewHomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,27 @@ const ButtonsContainer = styled.div`
transform: translateX(-50%);
`;

const getZappsHeight = (): number => {
const getZapps = (eventId: string): [string, string][] => {
const zapps = Object.entries(appConfig.embeddedZapps);
if (eventId === "5074edf5-f079-4099-b036-22223c0c6995") {
return zapps;
}
return [];
};
const getZappsHeight = (zapps: [string, string][]): number => {
return zapps.length * ZAPP_BUTTON_HEIGHT + zapps.length * TICKET_VERTICAL_GAP;
};

const TicketsContainer = styled.div<{ $width: number }>`
const TicketsContainer = styled.div<{ $width: number; eventId: string }>`
width: ${({ $width }): number => $width}px;
display: flex;
flex-direction: column;
height: 100%;
gap: ${getZappsHeight()
? getZappsHeight() + 28 + TICKET_VERTICAL_GAP
: 28 + TICKET_VERTICAL_GAP}px;
gap: ${({ eventId }): number =>
getZappsHeight(getZapps(eventId))
? getZappsHeight(getZapps(eventId)) + 28 + TICKET_VERTICAL_GAP
: 28 + TICKET_VERTICAL_GAP}px;
transition: gap 0.2s ease-in-out;
`;

const LoadingScreenContainer = styled.div`
Expand Down Expand Up @@ -406,6 +414,7 @@ export const NewHomeScreen = (): ReactElement => {
const eventDetails = getEventDetails(packs[0]);
return (
<TicketsContainer
eventId={tickets[currentPos][0]}
$width={cardWidth}
key={packs.map((pack) => pack.eventTicket.id).join("-")}
>
Expand Down Expand Up @@ -460,7 +469,7 @@ export const NewHomeScreen = (): ReactElement => {
</_SwipableViews>
<ButtonsContainer>
<SyncIndicator />
{Object.keys(appConfig.embeddedZapps).length > 0 && (
{getZapps(tickets[currentPos][0]).length > 0 && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{getZapps(tickets[currentPos][0]).length > 0 && (
{getZapps(tickets[currentPos]?.[0]).length > 0 && (

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on that state we have to have atleast one ticket, if not we render the no events state.

<ZappButtonsContainer>
{Object.entries(appConfig.embeddedZapps).map(
([zappName, url]) => (
Expand Down
Loading