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

feat: Invite others functionality (#19) #129

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/assets/icons/favicon.svg" />
<meta name="description" content="OpenGrame is a modern social media app that allows users to connect, share, and explore content in a seamless and engaging way." />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OpenGrame</title>
</head>
Expand Down
61 changes: 61 additions & 0 deletions src/components/shared/InviteForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";

const formSchema = z.object({
email: z.string().min(2).max(50).email(),
});



export default function InviteForm() {

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
email: "",
},
});


const onSubmit = async(values: z.infer<typeof formSchema>) => {
console.log(values)
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
className="bg-dark-2"
placeholder="Email..."
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button className="bg-primary-500" type="submit">
Send
</Button>
</form>
</Form>
);
}
45 changes: 45 additions & 0 deletions src/components/shared/InviteModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"use client"
import { Share2Icon, UserPlus2Icon } from "lucide-react";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTrigger,
} from "../ui/dialog";
import InviteForm from "./InviteForm";
import { Button } from "../ui/button";

export default function InviteModal() {

const shareData = {
title: "Invite Friends!!",
text: "OpenGrame is a modern social media app that allows users to connect, share, and explore content in a seamless and engaging way.",
url: `${window.location.href}`,
};

const shareHandler = async() => {
await navigator.share(shareData);
}

return (
<Dialog>
<DialogTrigger className="flex items-center gap-4 p-2">
<UserPlus2Icon className="group-hover:invert-white text-blue-500 w-5 h-5" />{" "}
Invite
</DialogTrigger>
<DialogContent>
<DialogHeader className="flex flex-row font-bold gap-2 items-start justify-start">
<UserPlus2Icon className="w-5 h-5" /> Invite Friends
</DialogHeader>
<InviteForm />
<DialogFooter>
<Button onClick={()=>shareHandler()} className="flex gap-2" variant={"outline"}>
<Share2Icon className="h-5 w-5" />
Share
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
5 changes: 5 additions & 0 deletions src/components/shared/LeftSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Link, NavLink, useLocation } from "react-router-dom";
import { useUserContext } from "@/context/AuthContext";
import { sidebarLinks } from "@/constants";
import { INavLink } from "@/types";
import InviteModal from "./InviteModal";

const LeftSidebar = () => {
const { user } = useUserContext();
Expand Down Expand Up @@ -58,6 +59,10 @@ const LeftSidebar = () => {
</li>
);
})}

<li className={`leftsidebar-link group `}>
<InviteModal />
</li>
</ul>
</div>
</nav>
Expand Down
Loading