Skip to content

Commit fe54e95

Browse files
authored
Lego/feat/unauthenticated tickets (#67)
## Summary - /events/:id/tickets is now a unauthenticated route - Better readability in ticket list.
1 parent e883ce9 commit fe54e95

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

app/components/TicketsSaleFlow/ConfirmationTab.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TableHeader,
1212
TableRow,
1313
} from "~/components/ui/table";
14+
import { useIsAuthReady, useIsLoggedIn } from "~/utils/supabase/AuthProvider";
1415

1516
import { useCreatePurchaseOrderMutation } from "./graphql/createPurchaseOrder.generated";
1617
import { EventTicketFragmentFragment } from "./graphql/EventTicketFragment.generated";
@@ -39,6 +40,9 @@ export const ConfirmationTab = ({
3940
) => string | null;
4041
currencyId: string;
4142
}) => {
43+
const isLogged = useIsLoggedIn();
44+
const isAuthReady = useIsAuthReady();
45+
const hasSession = isAuthReady && isLogged;
4246
const [isDisabled, setIsDisabled] = useState(false);
4347
const [purchaseOrderMutation] = useCreatePurchaseOrderMutation();
4448
const createPurchaseOrder = useCallback(async () => {
@@ -98,10 +102,10 @@ export const ConfirmationTab = ({
98102
<Table>
99103
<TableHeader>
100104
<TableRow className="border-t hover:bg-transparent">
101-
<TableHead className="h-[52px] w-[200px] text-center text-base font-bold text-white">
105+
<TableHead className="h-[52px] min-w-[140px] text-center text-base font-bold text-white">
102106
Tipo de Ticket
103107
</TableHead>
104-
<TableHead className="h-[52px] text-center text-base font-bold text-white">
108+
<TableHead className="h-[52px] min-w-[300px] text-center text-base font-bold text-white">
105109
Descripción
106110
</TableHead>
107111
<TableHead className="h-[52px] w-[100px] grow-0 text-center text-base font-bold text-white">
@@ -161,8 +165,11 @@ export const ConfirmationTab = ({
161165
console.error(error);
162166
});
163167
}}
164-
isDisabled={numberOfTickets === 0 || isDisabled}
168+
isDisabled={numberOfTickets === 0 || isDisabled || !hasSession}
165169
total={formattedTotal}
170+
hoverText={
171+
!hasSession ? "Debes iniciar sesión para poder comprar tickets" : null
172+
}
166173
/>
167174
</div>
168175
);

app/components/TicketsSaleFlow/Stepper.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ export const SecondStepFooter = ({
1111
onClickPrevious,
1212
onClickNext,
1313
isDisabled,
14+
hoverText,
1415
}: SecondStepFooterProps) => (
1516
<div className="mt-2 flex justify-end gap-2 text-right">
1617
<Button variant="outline" onClick={onClickPrevious}>
1718
Atras
1819
</Button>
19-
<Button disabled={isDisabled} onClick={onClickNext}>
20-
Pagar
21-
</Button>
20+
<ConditionalPopoverWrapper popoverText={hoverText}>
21+
<Button disabled={isDisabled} onClick={onClickNext}>
22+
Pagar
23+
</Button>
24+
</ConditionalPopoverWrapper>
2225
</div>
2326
);
2427

app/components/TicketsSaleFlow/TicketSelectionTab.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export const TicketSelectionTab = ({
6363
<Table>
6464
<TableHeader>
6565
<TableRow className="border-t hover:bg-transparent">
66-
<TableHead className="h-[52px] w-[200px] text-center text-base font-bold text-white">
66+
<TableHead className="h-[52px] min-w-[140px] text-center text-base font-bold text-white">
6767
Tipo de Ticket
6868
</TableHead>
69-
<TableHead className="h-[52px] text-center text-base font-bold text-white">
69+
<TableHead className="h-[52px] min-w-[300px] text-center text-base font-bold text-white">
7070
Descripción
7171
</TableHead>
7272
<TableHead className="h-[52px] w-[100px] grow-0 text-center text-base font-bold text-white">

app/components/TicketsSaleFlow/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ export type SecondStepFooterProps = {
3838
onClickNext: MouseEventHandler<HTMLButtonElement>;
3939
isDisabled: boolean;
4040
total: string | null;
41+
hoverText?: string | null;
4142
};

app/routes/_authenticated/events/$eventId/tickets/index.tsx renamed to app/routes/events.$id/tickets/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { useParams, useSearchParams } from "@remix-run/react";
33
import EventPage from "~/components/TicketsSaleFlow";
44

55
export default function Tickets() {
6-
const params = useParams<{ eventId: string }>();
6+
const params = useParams<{ id: string }>();
77
const [searchParams] = useSearchParams();
88

9-
const eventId = params.eventId!;
9+
const eventId = params.id!;
1010
const coupon = searchParams.get("coupon") ?? undefined;
1111

1212
return <EventPage id={eventId} coupon={coupon} />;
File renamed without changes.

0 commit comments

Comments
 (0)