Skip to content

Commit

Permalink
Merge branch 'master' into auto-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchitbajaj02 authored Jun 17, 2024
2 parents 5d520e3 + 577e63d commit 4eeb94b
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions src/components/pages/user/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
"use client";
import { useState, Suspense, useMemo } from "react";
import { Briefcase, Link2, Mail, MapPin, ArrowLeft, Edit, Edit3, Calendar } from "lucide-react";
import {
Briefcase,
Link2,
Mail,
MapPin,
ArrowLeft,
Edit,
Edit3,
Calendar,
Share2,
} from "lucide-react";
import Link from "next/link";
import Image from "next/image";
import { useRouter } from "next/navigation";
Expand All @@ -9,7 +19,7 @@ import Loader from "@/app/loading";
import TrendingFeed from "@/components/core/trendingFeed";
import Footer from "@/components/core/footer";
import { ButtonLong } from "@/components/core/buttons";

import { toastify } from "@/helper/toastify";
import UserPosts from "./userPosts";
import ImageUpload from "./imageUpload";
import UpdateCard from "./updateCard";
Expand Down Expand Up @@ -47,6 +57,28 @@ export default function User({ userId }: { userId: string }) {
setHovered(true);
};

const ShareHandler = async () => {
try {
const shareData = {
title: "Share Profile!!",
text: "Share your profile!!",
url: window.location.href,
};
await navigator.share(shareData);
} catch (err) {
+ toastify(`Failed to share profile`, "error");
}
};

const CopyHandler = async () => {
try {
await navigator.clipboard.writeText(window.location.href);
toastify("Profile URL copied!!", "success");
} catch (err) {
+ toastify(`Failed to share profile`, "error");
}
};

return (
<>
{profileUpdate && <UpdateCard setProfileUpdate={setProfileUpdate} />}
Expand Down Expand Up @@ -122,8 +154,20 @@ export default function User({ userId }: { userId: string }) {
className=" w-[135px] h-[135px] relative inline-block border-4 border-white dark:border-slate-800 rounded-full object-cover cursor-pointer"
/>
</div>
<div className="flex gap-4 items-center">
<button>
<div className="flex gap-2 sm:gap-4 items-center">
<button type="button">
<Share2
width={22}
onClick={() => ShareHandler()}
className="sm:hidden h-7 w-7 sm:h-9 sm:w-9 border-2 p-1 rounded-full text-slate-700 dark:text-slate-400 border-slate-700 dark:border-slate-400 cursor-pointer "
/>
<Share2
width={22}
onClick={() => CopyHandler()}
className="hidden sm:inline h-7 w-7 sm:h-9 sm:w-9 border-2 p-1 rounded-full text-slate-700 dark:text-slate-400 border-slate-700 dark:border-slate-400 cursor-pointer "
/>
</button>
<button type="button">
{currentUserID && (
<Edit
width={25}
Expand Down

0 comments on commit 4eeb94b

Please sign in to comment.