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

share invite drawer #231

Merged
merged 1 commit into from
Jan 19, 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
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ npm run check-types ||

echo ''

npm run format
# npm run format

echo ''

Expand Down
7 changes: 7 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,10 @@ export interface SessionContextProps {
login: (token: string, userId: string) => void;
logout: () => void;
}

export interface TicketModalProps {
userId: string;
eventId: string;
isOpen: boolean;
onClose: () => void;
}
2 changes: 1 addition & 1 deletion components/Home/homefooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export default function HomeFooter() {
);
})}
</div>
<p className="text-sm font-semibold text-primary-100"> &copy; {currentYear} Evento. All rights reserved.</p>
<p className="text-sm font-semibold text-primary-100"> &copy; {currentYear} Evento. All rights reserved.</p>
<div>
<Link href={''} className="pr-4 text-gray-500 font-medium">
Terms of Service
Expand Down
132 changes: 132 additions & 0 deletions components/share/ShareInvite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
'use client';

import * as React from 'react';
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from '@ui/drawer';
import Button from '@ui/NewButton';
import useMediaQuery from '@/hooks/use-media-query';
import { useEventContext } from '@/context/EventContext';
import {
TwitterShareButton,
XIcon,
FacebookShareButton,
FacebookIcon,
LinkedinShareButton,
LinkedinIcon,
WhatsappShareButton,
WhatsappIcon,
} from 'react-share';
import { toast } from 'react-toastify';
import { ExportCurve } from 'iconsax-react';
import { nunito } from '../Settings/Data-Security.tsx/modal/enable2Fa';
import { cn } from '@/utils/twcx';
import { FaShareAlt } from 'react-icons/fa';

interface ShareInviteProps {
Id: string;
}

export default function ShareInvite({ Id }: ShareInviteProps) {
const [open, setOpen] = React.useState(false);
const { isDesktop } = useMediaQuery();
const { shareEventLink } = useEventContext();
const eventLink = shareEventLink(Id);

return (
<Drawer open={open} onOpenChange={setOpen}>
<DrawerTrigger asChild>
<Button
style={{
boxShadow: '0px 1px 2px 0px rgba(16, 24, 40, 0.05)',
}}
className="text-[16px] text-[#e0580c] mt-2 font-[500] leading-[24px] w-[100%] rounded-[8px] py-[30px] px-[20px] flex justify-center items-center gap-4 bg-transparent border border-[#e0580c] "
>
<ExportCurve size="32" color="#FF8A65" />
<span className={nunito.className}>Share Event</span>
</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle className={`${nunito.className} font-medium text-[24px] `}>Share with your friends</DrawerTitle>
<DrawerDescription className={`${nunito.className} font-medium text-[16px] leading-[24px]`}>
Click on any of the icons
</DrawerDescription>
</DrawerHeader>
<SharedLink eventLink={eventLink} />
<DrawerFooter className="pt-2">
<DrawerClose asChild>
<Button
intent={'secondary'}
className={`${nunito.className} font-medium text-[20px] leading-[24px] capitalize w-full border border-[#e0580c] text-[#e0580c]`}
>
close
</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}

interface EventLink {
eventLink: string;
}

function SharedLink({ className, eventLink }: React.ComponentProps<'div'> & EventLink) {
const [isLinkCopied, setIsLinkCopied] = React.useState(false);
const handleButtonClick = async () => {
try {
await navigator.clipboard.writeText(eventLink);
setIsLinkCopied(true);
toast.success('Link copied to clipboard!');
} catch (error) {
console.error('Unable to copy to clipboard', error);
}
};
return (
<div className={cn('flex items-start', className)}>
<div className={'w-full rounded-md py-4 mx-5 flex justify-between items-center '}>
<FacebookShareButton
url={eventLink}
className="text-[#e0580c] hover:text-[#FF8A65] cursor-pointer ml-4 animate-bounce"
>
<FacebookIcon size={40} round={true} />
</FacebookShareButton>
<TwitterShareButton
url={eventLink}
className="text-[#e0580c] hover:text-[#FF8A65] cursor-pointer ml-4 animate-bounce"
>
<XIcon size={40} round={true} />
</TwitterShareButton>
<LinkedinShareButton
url={eventLink}
className="text-[#e0580c] hover:text-[#FF8A65] cursor-pointer ml-4 animate-bounce"
>
<LinkedinIcon size={40} round={true} />
</LinkedinShareButton>
<WhatsappShareButton
url={eventLink}
className="text-[#e0580c] hover:text-[#FF8A65] cursor-pointer ml-4 animate-bounce"
>
<WhatsappIcon size={40} round={true} />
</WhatsappShareButton>

<button
className="transition-all ease-in-out duration-500 animate-bounce"
title="Copy event link"
onClick={handleButtonClick}
>
<FaShareAlt color="#FF8A65" size={24} />
</button>
</div>
</div>
);
}
18 changes: 18 additions & 0 deletions components/ui/NewLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import * as React from 'react';
import * as LabelPrimitive from '@radix-ui/react-label';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../utils/twcx';

const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');

const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
));
Label.displayName = LabelPrimitive.Root.displayName;

export { Label };
97 changes: 97 additions & 0 deletions components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
'use client';

import * as React from 'react';
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { X } from 'lucide-react';

import { cn } from '../../utils/twcx';

const Dialog = DialogPrimitive.Root;

const DialogTrigger = DialogPrimitive.Trigger;

const DialogPortal = DialogPrimitive.Portal;

const DialogClose = DialogPrimitive.Close;

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className,
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;

const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
className,
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;

const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} {...props} />
);
DialogHeader.displayName = 'DialogHeader';

const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)} {...props} />
);
DialogFooter.displayName = 'DialogFooter';

const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold leading-none tracking-tight', className)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;

const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
};
89 changes: 89 additions & 0 deletions components/ui/drawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
'use client';

import * as React from 'react';
import { Drawer as DrawerPrimitive } from 'vaul';

import { cn } from '../../utils/twcx';

const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
);
Drawer.displayName = 'Drawer';

const DrawerTrigger = DrawerPrimitive.Trigger;

const DrawerPortal = DrawerPrimitive.Portal;

const DrawerClose = DrawerPrimitive.Close;

const DrawerOverlay = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Overlay ref={ref} className={cn('fixed inset-0 z-50 bg-black-main/80', className)} {...props} />
));
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;

const DrawerContent = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DrawerPortal>
<DrawerOverlay />
<DrawerPrimitive.Content
ref={ref}
className={cn(
'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-white-100',
className,
)}
{...props}
>
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
{children}
</DrawerPrimitive.Content>
</DrawerPortal>
));
DrawerContent.displayName = 'DrawerContent';

const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)} {...props} />
);
DrawerHeader.displayName = 'DrawerHeader';

const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />
);
DrawerFooter.displayName = 'DrawerFooter';

const DrawerTitle = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold leading-none tracking-tight', className)}
{...props}
/>
));
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;

const DrawerDescription = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
));
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;

export {
Drawer,
DrawerPortal,
DrawerOverlay,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
};
Loading
Loading