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

Adding login to the button #70

Merged
merged 1 commit into from
Nov 21, 2024
Merged
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
18 changes: 16 additions & 2 deletions app/components/TicketsSaleFlow/ConfirmationTab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Link } from "@remix-run/react";
import { MouseEventHandler, useCallback, useState } from "react";
import { toast } from "sonner";

import { Button } from "~/components/ui/button";
import { Card, CardContent } from "~/components/ui/card";
import {
Table,
Expand All @@ -12,6 +14,7 @@ import {
TableRow,
} from "~/components/ui/table";
import { useIsAuthReady, useIsLoggedIn } from "~/utils/supabase/AuthProvider";
import { urls } from "~/utils/urls";

import { useCreatePurchaseOrderMutation } from "./graphql/createPurchaseOrder.generated";
import { EventTicketFragmentFragment } from "./graphql/EventTicketFragment.generated";
Expand Down Expand Up @@ -167,8 +170,19 @@ export const ConfirmationTab = ({
}}
isDisabled={numberOfTickets === 0 || isDisabled || !hasSession}
total={formattedTotal}
hoverText={
!hasSession ? "Debes iniciar sesión para poder comprar tickets" : null
popoverContent={
!hasSession ? (
<div className="flex flex-col gap-4 text-sm">
Debes iniciar sesión para poder comprar tickets.
<div className="flex justify-center">
<Button variant="default" asChild>
<Link to={urls.login}>
<span className="text-xs">Inicia sesión aquí</span>
</Link>
</Button>
</div>
</div>
) : null
}
/>
</div>
Expand Down
16 changes: 8 additions & 8 deletions app/components/TicketsSaleFlow/Stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export const SecondStepFooter = ({
onClickPrevious,
onClickNext,
isDisabled,
hoverText,
popoverContent,
}: SecondStepFooterProps) => (
<div className="mt-2 flex justify-end gap-2 text-right">
<Button variant="outline" onClick={onClickPrevious}>
Atras
</Button>
<ConditionalPopoverWrapper popoverText={hoverText}>
<ConditionalPopoverWrapper popoverContent={popoverContent}>
<Button disabled={isDisabled} onClick={onClickNext}>
Pagar
</Button>
Expand All @@ -26,17 +26,17 @@ export const SecondStepFooter = ({
);

const ConditionalPopoverWrapper = ({
popoverText,
popoverContent,
children,
}: {
popoverText: string | undefined | null;
popoverContent?: React.ReactNode;
children: React.ReactNode;
}) => {
if (popoverText) {
if (popoverContent) {
return (
<Popover>
<PopoverTrigger>{children}</PopoverTrigger>
<PopoverContent>{popoverText}.</PopoverContent>
<PopoverContent>{popoverContent}</PopoverContent>
</Popover>
);
} else {
Expand All @@ -47,10 +47,10 @@ const ConditionalPopoverWrapper = ({
export const FirstStepFooter = ({
onClickNext,
isDisabled,
hoverText,
popoverContent,
}: FirstStepFooterProps) => (
<div className="mt-2 flex justify-end gap-2 text-right">
<ConditionalPopoverWrapper popoverText={hoverText}>
<ConditionalPopoverWrapper popoverContent={popoverContent}>
<Button disabled={isDisabled} onClick={onClickNext}>
Siguiente
</Button>
Expand Down
2 changes: 1 addition & 1 deletion app/components/TicketsSaleFlow/TicketSelectionTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const TicketSelectionTab = ({
steps={steps}
step={step}
total={formattedTotal}
hoverText={
popoverContent={
!isActive
? "Este evento no está activo"
: hasFinished
Expand Down
4 changes: 2 additions & 2 deletions app/components/TicketsSaleFlow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export type FirstStepFooterProps = {
steps: Step[];
step: number;
total: string | null;
hoverText?: string | null;
popoverContent?: React.ReactNode | null;
};

export type SecondStepFooterProps = {
onClickPrevious: MouseEventHandler<HTMLButtonElement>;
onClickNext: MouseEventHandler<HTMLButtonElement>;
isDisabled: boolean;
total: string | null;
hoverText?: string | null;
popoverContent?: React.ReactNode | null;
};
Loading