From 3bfc7aa323713880741ffc25cd46a9bc71c71649 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:54:02 +0000 Subject: [PATCH 1/3] style: format code with Prettier and StandardJS This commit fixes the style issues introduced in c269069 according to the output from Prettier and StandardJS. Details: None --- .../[domain]/blog/[slug]/opengraph-image.tsx | 130 +- app/(domain)/[domain]/blog/[slug]/page.tsx | 324 ++-- app/(domain)/[domain]/blog/layout.tsx | 175 +- app/(domain)/[domain]/blog/page.tsx | 253 ++- app/(domain)/[domain]/layout.tsx | 147 +- app/(domain)/[domain]/page.tsx | 85 +- app/ClerkProvider.tsx | 14 +- app/NextUIProvider.tsx | 54 +- app/ThemeProvider.tsx | 10 +- app/api/domain/[slug]/verify/route.ts | 72 +- app/api/feedback/route.ts | 41 +- app/api/generate/route.ts | 128 +- app/api/ping/route.ts | 12 +- app/api/portfolio/route.ts | 48 +- app/api/resume/route.ts | 47 +- app/api/track/route.ts | 181 ++- app/api/upload/route.ts | 60 +- app/api/uploadthing/core.ts | 50 +- app/api/uploadthing/route.ts | 8 +- app/api/user/certificate/route.ts | 47 +- app/api/user/project/route.ts | 47 +- app/api/webhook/user/route.ts | 128 +- .../(auth)/sign-in/[[...sign-in]]/page.tsx | 17 +- .../(auth)/sign-up/[[...sign-up]]/page.tsx | 14 +- app/app/community/page.tsx | 22 +- app/app/dashboard/feedback/page.tsx | 14 +- app/app/dashboard/layout.tsx | 40 +- app/app/dashboard/page.tsx | 26 +- .../portfolio/[slug]/analytics/page.tsx | 71 +- .../[slug]/blog/[blogslug]/not-found.tsx | 30 +- .../portfolio/[slug]/blog/[blogslug]/page.tsx | 64 +- .../[slug]/blog/[blogslug]/settings/page.tsx | 24 +- .../dashboard/portfolio/[slug]/blog/page.tsx | 69 +- app/app/dashboard/portfolio/[slug]/layout.tsx | 63 +- .../dashboard/portfolio/[slug]/loading.tsx | 13 +- .../dashboard/portfolio/[slug]/not-found.tsx | 46 +- app/app/dashboard/portfolio/[slug]/page.tsx | 101 +- .../[slug]/settings/AppearanceSection.tsx | 126 +- .../[slug]/settings/CertificateSection.tsx | 15 +- .../[slug]/settings/DomainSection.tsx | 83 +- .../[slug]/settings/EducationSection.tsx | 82 +- .../[slug]/settings/GeneralSection.tsx | 152 +- .../[slug]/settings/PortfolioSettingNav.tsx | 148 +- .../[slug]/settings/SkillsToolsSection.tsx | 123 +- .../portfolio/[slug]/settings/WorkSection.tsx | 85 +- .../portfolio/[slug]/settings/page.tsx | 48 +- app/app/dashboard/portfolio/page.tsx | 24 +- app/app/dashboard/settings/page.tsx | 286 ++-- app/app/editor/page.tsx | 14 +- app/app/explore/page.tsx | 30 +- app/app/page.tsx | 16 +- app/home/page.tsx | 54 +- app/layout.tsx | 74 +- app/not-found.tsx | 73 +- commitlint.config.js | 78 +- components/blur-image.tsx | 36 +- components/common/Footer.tsx | 36 +- components/common/NavBar.tsx | 246 ++- components/common/NavbarMenu.tsx | 156 +- components/common/ThemeToggler.tsx | 64 +- components/common/Typography.tsx | 221 ++- components/dashboard/AlertCard.tsx | 39 +- components/dashboard/DashBoardSideNavBar.tsx | 408 ++--- .../dashboard/feedback/FeedbackForm.tsx | 151 +- .../dashboard/portfolio/AllPortfolio.tsx | 87 +- components/dashboard/portfolio/BarList.tsx | 129 +- .../dashboard/portfolio/BlogAnalytics.tsx | 18 +- .../dashboard/portfolio/CreatePortfolio.tsx | 380 ++--- .../dashboard/portfolio/PorfolioBarChart.tsx | 55 +- .../portfolio/PortfolioAnaytlics.tsx | 163 +- .../dashboard/portfolio/PortfolioCard.tsx | 106 +- .../portfolio/UserAgentsAnalytics.tsx | 25 +- .../dashboard/portfolio/blog/all-blogs.tsx | 94 +- .../dashboard/portfolio/blog/blog-card.tsx | 122 +- .../dashboard/portfolio/blog/blog-editor.tsx | 268 ++-- .../portfolio/blog/create-blog-button.tsx | 66 +- .../portfolio/education/EducationCard.tsx | 119 +- .../dashboard/portfolio/skills/SkillForm.tsx | 182 +-- .../dashboard/portfolio/skills/ToolForm.tsx | 293 ++-- .../portfolio/work/WorkExperienceCard.tsx | 140 +- components/dashboard/settings/EditProfile.tsx | 200 +-- components/domain/blog-card.tsx | 68 +- components/explore/BlogPreview.tsx | 226 ++- components/explore/Cta.tsx | 56 +- components/explore/FeatureShowcase.tsx | 139 +- components/explore/LandingPage.tsx | 41 +- components/explore/Testimonials.tsx | 86 +- components/form/delete-post-form.tsx | 140 +- components/form/delete-site-form.tsx | 146 +- components/form/domain-configuration.tsx | 302 ++-- components/form/domain-status.tsx | 50 +- components/form/education-form.tsx | 715 +++++---- components/form/index.tsx | 343 ++-- components/form/site-about-form.tsx | 143 +- components/form/social-media-form.tsx | 287 ++-- components/form/uploader.tsx | 311 ++-- components/form/use-domain-status.ts | 32 +- components/form/work-form.tsx | 736 ++++----- components/home/WaitListForm.tsx | 263 ++- components/home/buildbyDevelopers.tsx | 43 +- components/home/buildwithcreativity.tsx | 64 +- components/home/landingsection.tsx | 147 +- components/mdx.module.css | 86 +- components/mdx.tsx | 161 +- components/placeholder-card.tsx | 22 +- components/themes/DefaultTheme.tsx | 169 +- components/themes/default/AboutSection.tsx | 78 +- components/themes/default/ContactSection.tsx | 178 +-- .../themes/default/EducationSection.tsx | 81 +- .../themes/default/ExperienceSection.tsx | 103 +- components/themes/default/FooterSection.tsx | 34 +- components/themes/default/HomeSection.tsx | 205 ++- components/themes/default/Navbar.tsx | 249 ++- components/themes/default/ProjectSection.tsx | 139 +- components/themes/default/TechStack.tsx | 107 +- components/ui/3d-card.tsx | 246 +-- components/ui/Spotlight.tsx | 96 +- components/ui/alert-dialog.tsx | 86 +- components/ui/alert.tsx | 34 +- components/ui/animated-tooltip.tsx | 168 +- components/ui/avatar.tsx | 28 +- components/ui/badge.tsx | 24 +- components/ui/button.tsx | 52 +- components/ui/calendar.tsx | 68 +- components/ui/card.tsx | 49 +- components/ui/command.tsx | 68 +- components/ui/container-scroll-animation.tsx | 233 ++- components/ui/dialog.tsx | 56 +- components/ui/dropdown-menu.tsx | 92 +- components/ui/form.tsx | 105 +- components/ui/google-gemini-effect.tsx | 294 ++-- components/ui/infinite-moving-cards.tsx | 222 +-- components/ui/input.tsx | 16 +- components/ui/label.tsx | 20 +- components/ui/lamp.tsx | 186 +-- components/ui/macbook-scroll.tsx | 1214 +++++++------- components/ui/navigation-menu.tsx | 60 +- components/ui/new-tabs.tsx | 208 +-- components/ui/parallax-scroll.tsx | 146 +- components/ui/popover.tsx | 22 +- components/ui/scroll-area.tsx | 32 +- components/ui/select.tsx | 72 +- components/ui/separator.tsx | 20 +- components/ui/sheet.tsx | 72 +- components/ui/sonner.tsx | 26 +- components/ui/sparkles.tsx | 850 +++++----- components/ui/tabs.tsx | 30 +- components/ui/text-generate-effect.tsx | 90 +- components/ui/text-reveal-card.tsx | 294 ++-- components/ui/textarea.tsx | 14 +- components/ui/toast.tsx | 64 +- components/ui/toaster.tsx | 12 +- components/ui/tracing-beam.tsx | 246 +-- components/ui/typewriter-effect.tsx | 328 ++-- components/ui/use-toast.ts | 149 +- lib/actions.ts | 1418 ++++++++--------- lib/analytics.ts | 837 +++++----- lib/auth.ts | 331 ++-- lib/contants.ts | 62 +- lib/db.ts | 7 +- lib/domains.ts | 220 +-- lib/edgedb.ts | 6 +- lib/fetchers.ts | 356 ++--- lib/hooks/use-window-size.ts | 60 +- lib/remark-plugins.tsx | 194 +-- lib/types.ts | 90 +- lib/uploadthing.ts | 6 +- lib/utils.ts | 55 +- middleware.ts | 120 +- next.config.js | 58 +- postcss.config.js | 6 +- styles/fonts.ts | 188 ++- styles/globals.css | 41 +- styles/theme.ts | 10 +- tailwind.config.ts | 140 +- 175 files changed, 12083 insertions(+), 12154 deletions(-) diff --git a/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx b/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx index 42ab23c..d4efe8b 100644 --- a/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx +++ b/app/(domain)/[domain]/blog/[slug]/opengraph-image.tsx @@ -1,31 +1,30 @@ /* eslint-disable @next/next/no-img-element */ -import prisma from "@/lib/edgedb"; -import { truncate } from "@/lib/utils"; -import { ImageResponse } from "next/og"; +import prisma from '@/lib/edgedb'; +import { truncate } from '@/lib/utils'; +import { ImageResponse } from 'next/og'; - -export const runtime = "edge"; +export const runtime = 'edge'; type PostOGResponse = { - title: string; - description: string; - image: string; - authorName: string; - authorImage: string; -} + title: string; + description: string; + image: string; + authorName: string; + authorImage: string; +}; export default async function PostOG({ - params, + params, }: { - params: { domain: string; slug: string }; + params: { domain: string; slug: string }; }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); - const subdomain = domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) - ? domain.replace(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, "") - : null; + const subdomain = domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) + ? domain.replace(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, '') + : null; - const response = await prisma.$queryRaw` + const response = await prisma.$queryRaw` SELECT blog.title, blog.description, blog.image, "user".firstname as "authorName", "user".avatar as "authorImage" FROM "blog" AS blog @@ -38,58 +37,55 @@ export default async function PostOG({ ) AND blog.slug = ${slug} LIMIT 1; - ` - ; - + `; + console.log('response ====>', response); - console.log("response ====>", response) + const data = (response as PostOGResponse[])[0]; - const data = (response as PostOGResponse[])[0]; + if (!data) { + return new Response('Not found', { status: 404 }); + } - if (!data) { - return new Response("Not found", { status: 404 }); - } - - const clashData = await fetch( - new URL("@/styles/CalSans-SemiBold.otf", import.meta.url), - ).then((res) => res.arrayBuffer()); + const clashData = await fetch( + new URL('@/styles/CalSans-SemiBold.otf', import.meta.url) + ).then((res) => res.arrayBuffer()); - return new ImageResponse( - ( -
-
-

- {data.title} -

-

- {truncate(data.description, 120)} -

-
- {data.authorName} -

by {data.authorName}

-
- {data.title} -
-
- ), + return new ImageResponse( + ( +
+
+

+ {data.title} +

+

+ {truncate(data.description, 120)} +

+
+ {data.authorName} +

by {data.authorName}

+
+ {data.title} +
+
+ ), + { + width: 1200, + height: 600, + fonts: [ { - width: 1200, - height: 600, - fonts: [ - { - name: "Clash", - data: clashData, - }, - ], - emoji: "blobmoji", + name: 'Clash', + data: clashData, }, - ); + ], + emoji: 'blobmoji', + } + ); } diff --git a/app/(domain)/[domain]/blog/[slug]/page.tsx b/app/(domain)/[domain]/blog/[slug]/page.tsx index 78a9019..f5955fa 100644 --- a/app/(domain)/[domain]/blog/[slug]/page.tsx +++ b/app/(domain)/[domain]/blog/[slug]/page.tsx @@ -1,176 +1,186 @@ -import BlurImage from "@/components/blur-image"; -import BlogCard from "@/components/domain/blog-card"; -import MDX from "@/components/mdx"; -import { TracingBeam } from "@/components/ui/tracing-beam"; -import { TrackAnalytics } from "@/lib/analytics"; -import prisma from "@/lib/db"; -import { getBlogData, getSiteData } from "@/lib/fetchers"; -import { placeholderBlurhash, toDateString } from "@/lib/utils"; -import Link from "next/link"; -import { notFound } from "next/navigation"; +import BlurImage from '@/components/blur-image'; +import BlogCard from '@/components/domain/blog-card'; +import MDX from '@/components/mdx'; +import { TracingBeam } from '@/components/ui/tracing-beam'; +import { TrackAnalytics } from '@/lib/analytics'; +import prisma from '@/lib/db'; +import { getBlogData, getSiteData } from '@/lib/fetchers'; +import { placeholderBlurhash, toDateString } from '@/lib/utils'; +import Link from 'next/link'; +import { notFound } from 'next/navigation'; import readingTime from 'reading-time'; -export const dynamic = 'force-dynamic' +export const dynamic = 'force-dynamic'; +export async function generateMetadata({ + params, +}: { + params: { domain: string; slug: string }; +}) { + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); -export async function generateMetadata({ params }: { params: { domain: string; slug: string } }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); + const [data, siteData] = await Promise.all([ + getBlogData(domain, slug), + getSiteData(domain), + ]); + if (!data || !siteData) { + return null; + } + const { title, description } = data; - const [data, siteData] = await Promise.all([ - getBlogData(domain, slug), - getSiteData(domain), - ]); - if (!data || !siteData) { - return null; - } - const { title, description } = data; - - return { - title, - description, - openGraph: { - title, - description, - }, - twitter: { - card: "summary_large_image", - title, - description, - creator: "@" + siteData?.twitterid || "abhishektwts", - }, - }; + return { + title, + description, + openGraph: { + title, + description, + }, + twitter: { + card: 'summary_large_image', + title, + description, + creator: '@' + siteData?.twitterid || 'abhishektwts', + }, + }; } export async function generateStaticParams() { - const allPosts = await prisma.blog.findMany({ + const allPosts = await prisma.blog.findMany({ + select: { + slug: true, + site: { select: { - slug: true, - site: { - select: { - subdomain: true, - customDomain: true, - }, - }, + subdomain: true, + customDomain: true, }, - // where: { - // slug: "none" - // } - }); + }, + }, + // where: { + // slug: "none" + // } + }); - const allPaths = allPosts - .flatMap(({ site, slug }) => [ - site?.subdomain && { - domain: `${site.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - slug, - }, - site?.customDomain && { - domain: site.customDomain, - slug, - }, - ]) - .filter(Boolean); + const allPaths = allPosts + .flatMap(({ site, slug }) => [ + site?.subdomain && { + domain: `${site.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + slug, + }, + site?.customDomain && { + domain: site.customDomain, + slug, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } -export default async function SitePostPage({ params }: { params: { domain: string; slug: string } }) { - const domain = decodeURIComponent(params.domain); - const slug = decodeURIComponent(params.slug); - const data = await getBlogData(domain, slug); - const sitedata = await getSiteData(domain) +export default async function SitePostPage({ + params, +}: { + params: { domain: string; slug: string }; +}) { + const domain = decodeURIComponent(params.domain); + const slug = decodeURIComponent(params.slug); + const data = await getBlogData(domain, slug); + const sitedata = await getSiteData(domain); - if (!data || !sitedata) { - notFound(); - } + if (!data || !sitedata) { + notFound(); + } - const readingstats = readingTime(data.content || ""); + const readingstats = readingTime(data.content || ''); + try { + TrackAnalytics('blog', { + path: `➡️${data.title}`, + blogId: data?.id || '', + }); + } catch (error) { + console.log(error); + } - try { - TrackAnalytics("blog", { - path: `➡️${data.title}`, - blogId: data?.id || "", - }); - } catch (error) { - console.log(error); - } - - return ( - <> -
-
- -
-
-

- {data.title} -

-

- {toDateString(data.createdAt)} | {readingstats.text} -

-

- {data.description} -

-
- -
- -
- {data.site?.name} -
-
- -
-
- - - + return ( + <> +
+
+ +
+
+

+ {data.title} +

+

+ {toDateString(data.createdAt)} | {readingstats.text} +

+

+ {data.description} +

+
+ +
+ +
+ {data.site?.name}
- {data.adjacentPosts.length > 0 && ( -
- - )} - {data.adjacentPosts && ( -
- {data.adjacentPosts.map((data: any, index: number) => ( - - ))} -
- )} - - ); +
+ +
+
+ + + +
+ {data.adjacentPosts.length > 0 && ( +
+ + )} + {data.adjacentPosts && ( +
+ {data.adjacentPosts.map((data: any, index: number) => ( + + ))} +
+ )} + + ); } diff --git a/app/(domain)/[domain]/blog/layout.tsx b/app/(domain)/[domain]/blog/layout.tsx index f40e3e1..f7042f2 100644 --- a/app/(domain)/[domain]/blog/layout.tsx +++ b/app/(domain)/[domain]/blog/layout.tsx @@ -1,104 +1,103 @@ - -import { getSiteData } from "@/lib/fetchers"; -import { fontMapper } from "@/styles/fonts"; -import { Metadata } from "next"; -import Image from "next/image"; -import Link from "next/link"; -import { notFound, redirect } from "next/navigation"; -import { ReactNode } from "react"; +import { getSiteData } from '@/lib/fetchers'; +import { fontMapper } from '@/styles/fonts'; +import { Metadata } from 'next'; +import Image from 'next/image'; +import Link from 'next/link'; +import { notFound, redirect } from 'next/navigation'; +import { ReactNode } from 'react'; export async function generateMetadata({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }): Promise { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); - if (!data) { - return null; - } - const { - name: title, - description, - image, - logo, - } = data as { - name: string; - description: string; - image: string; - logo: string; - }; + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); + if (!data) { + return null; + } + const { + name: title, + description, + image, + logo, + } = data as { + name: string; + description: string; + image: string; + logo: string; + }; - return { - title, - description, - openGraph: { - title, - description, - images: [image], - }, - twitter: { - card: "summary_large_image", - title, - description, - images: [image], - creator: "@vercel", - }, - icons: [logo], - metadataBase: new URL(`https://${domain}`), - // Optional: Set canonical URL to custom domain if it exists - // ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - // data.customDomain && { - // alternates: { - // canonical: `https://${data.customDomain}`, - // }, - // }), - }; + return { + title, + description, + openGraph: { + title, + description, + images: [image], + }, + twitter: { + card: 'summary_large_image', + title, + description, + images: [image], + creator: '@vercel', + }, + icons: [logo], + metadataBase: new URL(`https://${domain}`), + // Optional: Set canonical URL to custom domain if it exists + // ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + // data.customDomain && { + // alternates: { + // canonical: `https://${data.customDomain}`, + // }, + // }), + }; } export default async function SiteLayout({ - params, - children, + params, + children, }: { - params: { domain: string }; - children: ReactNode; + params: { domain: string }; + children: ReactNode; }) { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); - if (!data) { - notFound(); - } + if (!data) { + notFound(); + } - // Optional: Redirect to custom domain if it exists - if ( - domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && - process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === "true" - ) { - return redirect(`https://${data.customDomain}`); - } + // Optional: Redirect to custom domain if it exists + if ( + domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && + process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === 'true' + ) { + return redirect(`https://${data.customDomain}`); + } - return ( -
-
-
- -
- {data.name -
- - {data.name} - - -
+ return ( +
+
+
+ +
+ {data.name
-
{children}
+ + {data.name} + +
- ); +
+
{children}
+
+ ); } diff --git a/app/(domain)/[domain]/blog/page.tsx b/app/(domain)/[domain]/blog/page.tsx index 3c49e86..d06623f 100644 --- a/app/(domain)/[domain]/blog/page.tsx +++ b/app/(domain)/[domain]/blog/page.tsx @@ -1,140 +1,139 @@ - -import BlurImage from "@/components/blur-image"; -import BlogCard from "@/components/domain/blog-card"; -import prisma from "@/lib/db"; -import { getBlogsForSite, getSiteData } from "@/lib/fetchers"; -import { placeholderBlurhash, toDateString } from "@/lib/utils"; -import Image from "next/image"; -import Link from "next/link"; -import { notFound } from "next/navigation"; +import BlurImage from '@/components/blur-image'; +import BlogCard from '@/components/domain/blog-card'; +import prisma from '@/lib/db'; +import { getBlogsForSite, getSiteData } from '@/lib/fetchers'; +import { placeholderBlurhash, toDateString } from '@/lib/utils'; +import Image from 'next/image'; +import Link from 'next/link'; +import { notFound } from 'next/navigation'; export async function generateStaticParams() { - const allSites = await prisma.site.findMany({ - select: { - subdomain: true, - customDomain: true, - }, - // feel free to remove this filter if you want to generate paths for all sites - // where: { - // subdomain: "demo", - // }, - }); + const allSites = await prisma.site.findMany({ + select: { + subdomain: true, + customDomain: true, + }, + // feel free to remove this filter if you want to generate paths for all sites + // where: { + // subdomain: "demo", + // }, + }); - const allPaths = allSites - .flatMap(({ subdomain, customDomain }) => [ - subdomain && { - domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - }, - customDomain && { - domain: customDomain, - }, - ]) - .filter(Boolean); + const allPaths = allSites + .flatMap(({ subdomain, customDomain }) => [ + subdomain && { + domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + }, + customDomain && { + domain: customDomain, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } export default async function SiteHomePage({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }) { - const domain = decodeURIComponent(params.domain); - const [data, posts] = await Promise.all([ - getSiteData(domain), - getBlogsForSite(domain), - ]); - - if (!data) { - notFound(); - } + const domain = decodeURIComponent(params.domain); + const [data, posts] = await Promise.all([ + getSiteData(domain), + getBlogsForSite(domain), + ]); - return ( - <> -
- {posts.length > 0 ? ( -
- -
- -
-
-

- {posts[0].title} -

-

- {posts[0].description} -

-
-
- {data.user?.avatar ? ( - - ) : ( -
- ? -
- )} -
-

- {data.user?.firstname} {" "} {data.user?.lastname} -

-
-

- {toDateString(posts[0].createdAt)} -

-
-
- -
- ) : ( -
- missing post - missing post -

- No posts yet. -

-
- )} -
+ if (!data) { + notFound(); + } - {posts.length > 1 && ( -
-

- More stories -

-
- {posts.slice(1).map((metadata: any, index: number) => ( - - ))} -
+ return ( + <> +
+ {posts.length > 0 ? ( +
+ +
+ +
+
+

+ {posts[0].title} +

+

+ {posts[0].description} +

+
+
+ {data.user?.avatar ? ( + + ) : ( +
+ ? +
+ )} +
+

+ {data.user?.firstname} {data.user?.lastname} +

+
+

+ {toDateString(posts[0].createdAt)} +

- )} - - ); +
+ +
+ ) : ( +
+ missing post + missing post +

+ No posts yet. +

+
+ )} +
+ + {posts.length > 1 && ( +
+

+ More stories +

+
+ {posts.slice(1).map((metadata: any, index: number) => ( + + ))} +
+
+ )} + + ); } diff --git a/app/(domain)/[domain]/layout.tsx b/app/(domain)/[domain]/layout.tsx index 4119ee2..b9beb06 100644 --- a/app/(domain)/[domain]/layout.tsx +++ b/app/(domain)/[domain]/layout.tsx @@ -1,88 +1,89 @@ -import { ReactNode } from "react"; +import { ReactNode } from 'react'; // import CTA from "@/components/cta"; // import ReportAbuse from "@/components/report-abuse"; -import { getSiteData } from "@/lib/fetchers"; -import { fontMapper } from "@/styles/fonts"; -import { Metadata } from "next"; -import { notFound, redirect } from "next/navigation"; -export const dynamic = 'force-dynamic' +import { getSiteData } from '@/lib/fetchers'; +import { fontMapper } from '@/styles/fonts'; +import { Metadata } from 'next'; +import { notFound, redirect } from 'next/navigation'; +export const dynamic = 'force-dynamic'; export async function generateMetadata({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }): Promise { - const domain = decodeURIComponent(params.domain); - const data = await getSiteData(domain); - if (!data) { - return null; - } - const { - name: title, - description, - image, - logo, - } = data as { - name: string; - description: string; - image: string; - logo: string; - }; - // Todo: To make sure that when user create thier site the user profile logo is used .... - return { - title, - description, - openGraph: { - title, - description, - images: [image], + const domain = decodeURIComponent(params.domain); + const data = await getSiteData(domain); + if (!data) { + return null; + } + const { + name: title, + description, + image, + logo, + } = data as { + name: string; + description: string; + image: string; + logo: string; + }; + // Todo: To make sure that when user create thier site the user profile logo is used .... + return { + title, + description, + openGraph: { + title, + description, + images: [image], + }, + twitter: { + card: 'summary_large_image', + title, + description, + images: [image], + creator: data.twitterid || '@abhishekkushwaha', + }, + icons: [logo], + metadataBase: new URL(`https://${domain}`), + // Optional: Set canonical URL to custom domain if it exists + ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && { + alternates: { + canonical: `https://${data.customDomain}`, }, - twitter: { - card: "summary_large_image", - title, - description, - images: [image], - creator: data.twitterid || "@abhishekkushwaha", - }, - icons: [logo], - metadataBase: new URL(`https://${domain}`), - // Optional: Set canonical URL to custom domain if it exists - ...(params.domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && { - alternates: { - canonical: `https://${data.customDomain}`, - }, - }), - }; + }), + }; } export default async function HostedPortfolioLayout({ - params, - children, + params, + children, }: { - params: { domain: string }; - children: ReactNode; + params: { domain: string }; + children: ReactNode; }) { - const domain = decodeURIComponent(params.domain); - const [data] = await Promise.all([ - getSiteData(domain), - ]); - if (!data) { - notFound(); - } + const domain = decodeURIComponent(params.domain); + const [data] = await Promise.all([getSiteData(domain)]); + if (!data) { + notFound(); + } - // Optional: Redirect to custom domain if it exists - if ( - domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && - data.customDomain && - process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === "true" - ) { - return redirect(`https://${data.customDomain}`); - } + // Optional: Redirect to custom domain if it exists + if ( + domain.endsWith(`.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`) && + data.customDomain && + process.env.REDIRECT_TO_CUSTOM_DOMAIN_IF_EXISTS === 'true' + ) { + return redirect(`https://${data.customDomain}`); + } - return ( -
- {children} -
- ); + return ( +
+ {children} +
+ ); } diff --git a/app/(domain)/[domain]/page.tsx b/app/(domain)/[domain]/page.tsx index 20149d0..c0e12f1 100644 --- a/app/(domain)/[domain]/page.tsx +++ b/app/(domain)/[domain]/page.tsx @@ -1,54 +1,53 @@ - -import DefaultTheme from "@/components/themes/DefaultTheme"; -import prisma from "@/lib/db"; -import { getSiteAbout, getSiteData } from "@/lib/fetchers"; -import { notFound } from "next/navigation"; -export const dynamic = 'force-dynamic' +import DefaultTheme from '@/components/themes/DefaultTheme'; +import prisma from '@/lib/db'; +import { getSiteAbout, getSiteData } from '@/lib/fetchers'; +import { notFound } from 'next/navigation'; +export const dynamic = 'force-dynamic'; export async function generateStaticParams() { - const allSites = await prisma.site.findMany({ - select: { - subdomain: true, - customDomain: true, - }, - // feel free to remove this filter if you want to generate paths for all sites - // where: { - // subdomain: "demo", - // }, - }); + const allSites = await prisma.site.findMany({ + select: { + subdomain: true, + customDomain: true, + }, + // feel free to remove this filter if you want to generate paths for all sites + // where: { + // subdomain: "demo", + // }, + }); - const allPaths = allSites - .flatMap(({ subdomain, customDomain }) => [ - subdomain && { - domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, - }, - customDomain && { - domain: customDomain, - }, - ]) - .filter(Boolean); + const allPaths = allSites + .flatMap(({ subdomain, customDomain }) => [ + subdomain && { + domain: `${subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`, + }, + customDomain && { + domain: customDomain, + }, + ]) + .filter(Boolean); - return allPaths; + return allPaths; } export default async function SiteHomePage({ - params, + params, }: { - params: { domain: string }; + params: { domain: string }; }) { - const domain = decodeURIComponent(params.domain); - const [data, aboutdata] = await Promise.all([ - getSiteData(domain), - getSiteAbout(domain) - ]); + const domain = decodeURIComponent(params.domain); + const [data, aboutdata] = await Promise.all([ + getSiteData(domain), + getSiteAbout(domain), + ]); - if (!data) { - notFound(); - } - return ( - <> - {/* {data.theme} */} - - - ); + if (!data) { + notFound(); + } + return ( + <> + {/* {data.theme} */} + + + ); } diff --git a/app/ClerkProvider.tsx b/app/ClerkProvider.tsx index 6347c00..67cd79c 100644 --- a/app/ClerkProvider.tsx +++ b/app/ClerkProvider.tsx @@ -1,13 +1,9 @@ -import { ClerkProvider } from '@clerk/nextjs' +import { ClerkProvider } from '@clerk/nextjs'; export default function RootLayout({ - children, + children, }: { - children: React.ReactNode + children: React.ReactNode; }) { - return ( - - {children} - - ) -} \ No newline at end of file + return {children}; +} diff --git a/app/NextUIProvider.tsx b/app/NextUIProvider.tsx index 418b8ba..9e6b486 100644 --- a/app/NextUIProvider.tsx +++ b/app/NextUIProvider.tsx @@ -1,36 +1,36 @@ // app/providers.tsx -'use client' +'use client'; import { ClerkProvider } from '@clerk/nextjs'; import { dark } from '@clerk/themes'; import { NextUIProvider } from '@nextui-org/react'; import { useRouter } from 'next/navigation'; import NextNProgress from 'nextjs-progressbar'; -import { Toaster } from "sonner"; +import { Toaster } from 'sonner'; import { ThemeProvider } from './ThemeProvider'; export function Providers({ children }: { children: React.ReactNode }) { - const router = useRouter(); - return ( - - - - - - - {children} - - - - ) -} \ No newline at end of file + const router = useRouter(); + return ( + + + + + + + {children} + + + + ); +} diff --git a/app/ThemeProvider.tsx b/app/ThemeProvider.tsx index 4b40449..1f84abd 100644 --- a/app/ThemeProvider.tsx +++ b/app/ThemeProvider.tsx @@ -1,10 +1,8 @@ -"use client"; +'use client'; -import { ThemeProvider as NextThemesProvider } from "next-themes"; -import { type ThemeProviderProps } from "next-themes/dist/types"; +import { ThemeProvider as NextThemesProvider } from 'next-themes'; +import { type ThemeProviderProps } from 'next-themes/dist/types'; export function ThemeProvider({ children, ...props }: ThemeProviderProps) { - return - {children} - + return {children}; } diff --git a/app/api/domain/[slug]/verify/route.ts b/app/api/domain/[slug]/verify/route.ts index 681b8cc..01af7be 100644 --- a/app/api/domain/[slug]/verify/route.ts +++ b/app/api/domain/[slug]/verify/route.ts @@ -1,48 +1,48 @@ import { - getConfigResponse, - getDomainResponse, - verifyDomain, -} from "@/lib/domains"; -import { DomainVerificationStatusProps } from "@/lib/types"; -import { NextResponse } from "next/server"; + getConfigResponse, + getDomainResponse, + verifyDomain, +} from '@/lib/domains'; +import { DomainVerificationStatusProps } from '@/lib/types'; +import { NextResponse } from 'next/server'; export async function GET( - _req: Request, - { params }: { params: { slug: string } }, + _req: Request, + { params }: { params: { slug: string } } ) { - const domain = decodeURIComponent(params.slug); - let status: DomainVerificationStatusProps = "Valid Configuration"; + const domain = decodeURIComponent(params.slug); + let status: DomainVerificationStatusProps = 'Valid Configuration'; - const [domainJson, configJson] = await Promise.all([ - getDomainResponse(domain), - getConfigResponse(domain), - ]); + const [domainJson, configJson] = await Promise.all([ + getDomainResponse(domain), + getConfigResponse(domain), + ]); - if (domainJson?.error?.code === "not_found") { - // domain not found on Vercel project - status = "Domain Not Found"; + if (domainJson?.error?.code === 'not_found') { + // domain not found on Vercel project + status = 'Domain Not Found'; - // unknown error - } else if (domainJson.error) { - status = "Unknown Error"; + // unknown error + } else if (domainJson.error) { + status = 'Unknown Error'; - // if domain is not verified, we try to verify now - } else if (!domainJson.verified) { - status = "Pending Verification"; - const verificationJson = await verifyDomain(domain); + // if domain is not verified, we try to verify now + } else if (!domainJson.verified) { + status = 'Pending Verification'; + const verificationJson = await verifyDomain(domain); - // domain was just verified - if (verificationJson && verificationJson.verified) { - status = "Valid Configuration"; - } - } else if (configJson.misconfigured) { - status = "Invalid Configuration"; - } else { - status = "Valid Configuration"; + // domain was just verified + if (verificationJson && verificationJson.verified) { + status = 'Valid Configuration'; } + } else if (configJson.misconfigured) { + status = 'Invalid Configuration'; + } else { + status = 'Valid Configuration'; + } - return NextResponse.json({ - status, - domainJson, - }); + return NextResponse.json({ + status, + domainJson, + }); } diff --git a/app/api/feedback/route.ts b/app/api/feedback/route.ts index 178b61f..ad5cd14 100644 --- a/app/api/feedback/route.ts +++ b/app/api/feedback/route.ts @@ -1,28 +1,25 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; -export const dynamic = 'force-dynamic' +export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - - const userID = await auth() - const { feedback } = await request.json(); - const postfeedback = await prisma.feedback.create({ - data: { - feedback: feedback, - feedback_type: "other" as string, - user_id: userID.userId!, - }, - }); - return Response.json({ ok: "ok" }); - } else { - return Response.json({ - error: "Method not allowed", - }) - } + if (request.method === 'POST') { + const userID = await auth(); + const { feedback } = await request.json(); + const postfeedback = await prisma.feedback.create({ + data: { + feedback: feedback, + feedback_type: 'other' as string, + user_id: userID.userId!, + }, + }); + return Response.json({ ok: 'ok' }); + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } - - export const GET = handler; export const POST = handler; diff --git a/app/api/generate/route.ts b/app/api/generate/route.ts index e4186e3..a9e7591 100644 --- a/app/api/generate/route.ts +++ b/app/api/generate/route.ts @@ -1,84 +1,82 @@ -import { Ratelimit } from "@upstash/ratelimit"; +import { Ratelimit } from '@upstash/ratelimit'; import { Redis } from '@upstash/redis'; -import { OpenAIStream, StreamingTextResponse } from "ai"; -import { Configuration, OpenAIApi } from "openai-edge"; - +import { OpenAIStream, StreamingTextResponse } from 'ai'; +import { Configuration, OpenAIApi } from 'openai-edge'; const redis = new Redis({ - url: process.env.UPSTASH_REDIS_REST_URL!, - token: process.env.UPSTASH_REDIS_REST_TOKEN!, -}) - + url: process.env.UPSTASH_REDIS_REST_URL!, + token: process.env.UPSTASH_REDIS_REST_TOKEN!, +}); const config = new Configuration({ - apiKey: process.env.OPENAI_API_KEY, + apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIApi(config); -export const runtime = "edge"; +export const runtime = 'edge'; export async function POST(req: Request): Promise { - if ( - process.env.NODE_ENV != "development" && - process.env.KV_REST_API_URL && - process.env.KV_REST_API_TOKEN - ) { - const ip = req.headers.get("x-forwarded-for"); - const ratelimit = new Ratelimit({ - redis: redis, - limiter: Ratelimit.slidingWindow(50, "1 d"), - }); + if ( + process.env.NODE_ENV != 'development' && + process.env.KV_REST_API_URL && + process.env.KV_REST_API_TOKEN + ) { + const ip = req.headers.get('x-forwarded-for'); + const ratelimit = new Ratelimit({ + redis: redis, + limiter: Ratelimit.slidingWindow(50, '1 d'), + }); - const { success, limit, reset, remaining } = await ratelimit.limit( - `platforms_ratelimit_${ip}`, - ); + const { success, limit, reset, remaining } = await ratelimit.limit( + `platforms_ratelimit_${ip}` + ); - if (!success) { - return new Response("You have reached your request limit for the day.", { - status: 429, - headers: { - "X-RateLimit-Limit": limit.toString(), - "X-RateLimit-Remaining": remaining.toString(), - "X-RateLimit-Reset": reset.toString(), - }, - }); - } + if (!success) { + return new Response('You have reached your request limit for the day.', { + status: 429, + headers: { + 'X-RateLimit-Limit': limit.toString(), + 'X-RateLimit-Remaining': remaining.toString(), + 'X-RateLimit-Reset': reset.toString(), + }, + }); } + } - let { prompt: content } = await req.json(); + let { prompt: content } = await req.json(); - // remove trailing slash, - // slice the content from the end to prioritize later characters - content = content.replace(/\/$/, "").slice(-5000); + // remove trailing slash, + // slice the content from the end to prioritize later characters + content = content.replace(/\/$/, '').slice(-5000); - const response = await openai.createChatCompletion({ - model: "gpt-3.5-turbo", - messages: [ - { - role: "system", - content: - "You are an AI writing assistant that continues existing text based on context from prior text. " + - "Give more weight/priority to the later characters than the beginning ones. " + - "Limit your response to no more than 200 characters, but make sure to construct complete sentences.", - // we're disabling markdown for now until we can figure out a way to stream markdown text with proper formatting: https://github.com/steven-tey/novel/discussions/7 - // "Use Markdown formatting when appropriate.", - }, - { - role: "user", - content, - }, - ], - temperature: 0.7, - top_p: 1, - frequency_penalty: 0, - presence_penalty: 0, - stream: true, - n: 1, - }); + const response = await openai.createChatCompletion({ + model: 'gpt-3.5-turbo', + messages: [ + { + role: 'system', + content: + 'You are an AI writing assistant that continues existing text based on context from prior text. ' + + 'Give more weight/priority to the later characters than the beginning ones. ' + + 'Limit your response to no more than 200 characters, but make sure to construct complete sentences.', + // we're disabling markdown for now until we can figure out a way to stream markdown text with proper formatting: https://github.com/steven-tey/novel/discussions/7 + // "Use Markdown formatting when appropriate.", + }, + { + role: 'user', + content, + }, + ], + temperature: 0.7, + top_p: 1, + frequency_penalty: 0, + presence_penalty: 0, + stream: true, + n: 1, + }); - // Convert the response into a friendly text-stream - const stream = OpenAIStream(response); + // Convert the response into a friendly text-stream + const stream = OpenAIStream(response); - // Respond with the stream - return new StreamingTextResponse(stream); + // Respond with the stream + return new StreamingTextResponse(stream); } diff --git a/app/api/ping/route.ts b/app/api/ping/route.ts index 09018d1..ca0c381 100644 --- a/app/api/ping/route.ts +++ b/app/api/ping/route.ts @@ -1,9 +1,9 @@ -import { NextResponse } from "next/server"; +import { NextResponse } from 'next/server'; export async function GET(request: Request) { - return NextResponse.json({ - "message": 'pong! welcome to dresume.me', - "status": 200, - "data": null, - }) + return NextResponse.json({ + message: 'pong! welcome to dresume.me', + status: 200, + data: null, + }); } diff --git a/app/api/portfolio/route.ts b/app/api/portfolio/route.ts index 3194146..9a80107 100644 --- a/app/api/portfolio/route.ts +++ b/app/api/portfolio/route.ts @@ -1,31 +1,31 @@ - -import prisma from "@/lib/db"; +import prisma from '@/lib/db'; import { NextResponse } from 'next/server'; async function handler(request: Request) { - const payload = await request.json(); - - try { - const sites = await prisma.site.findMany({ - where: { - user: { - id: payload.userId as string, - }, - }, - orderBy: { - createdAt: "asc", - } - }); + const payload = await request.json(); - return NextResponse.json({ - sites: sites, - status: "success" - }, { status: 200 }); - } catch (error: any) { - return NextResponse.json({ error: error }, { status: 500 }); - } + try { + const sites = await prisma.site.findMany({ + where: { + user: { + id: payload.userId as string, + }, + }, + orderBy: { + createdAt: 'asc', + }, + }); + return NextResponse.json( + { + sites: sites, + status: 'success', + }, + { status: 200 } + ); + } catch (error: any) { + return NextResponse.json({ error: error }, { status: 500 }); + } } - -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/resume/route.ts b/app/api/resume/route.ts index af26ce9..57ab15b 100644 --- a/app/api/resume/route.ts +++ b/app/api/resume/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.resume.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! resume created created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.resume.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! resume created created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/track/route.ts b/app/api/track/route.ts index 5950a66..fe49224 100644 --- a/app/api/track/route.ts +++ b/app/api/track/route.ts @@ -1,107 +1,104 @@ -import prisma from "@/lib/db"; -import { NextRequest } from "next/server"; +import prisma from '@/lib/db'; +import { NextRequest } from 'next/server'; import UAParser from 'ua-parser-js'; async function handler(request: NextRequest) { - const userAgent = request.headers.get('user-agent') ?? ''; - const uaParser = new UAParser(); - uaParser.setUA(userAgent); - const os = uaParser.getOS().name; - const v = uaParser.getEngine().name; - const browser = uaParser.getBrowser().name; - const ip = request.ip || request.headers.get('X-Forwarded-For'); - const ipinfo = await fetch(`https://ipinfo.io/${ip}/json`).then((res) => res.json()); + const userAgent = request.headers.get('user-agent') ?? ''; + const uaParser = new UAParser(); + uaParser.setUA(userAgent); + const os = uaParser.getOS().name; + const v = uaParser.getEngine().name; + const browser = uaParser.getBrowser().name; + const ip = request.ip || request.headers.get('X-Forwarded-For'); + const ipinfo = await fetch(`https://ipinfo.io/${ip}/json`).then((res) => + res.json() + ); - if (request.method === "GET") { - try { - return Response.json({ - status: "ok! lookup created", - ip: ip, - ipinfo: ipinfo, - os: os, - browser: browser, - v: { - type: v, - viewport: { - messae: "hjdklqehlk" - } - } - }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else if (request.method === "POST") { - - const payload = await request.json(); - const { namespace, event } = payload - - - const pcThreshold = 1024; - const tabletThreshold = 768; + if (request.method === 'GET') { + try { + return Response.json({ + status: 'ok! lookup created', + ip: ip, + ipinfo: ipinfo, + os: os, + browser: browser, + v: { + type: v, + viewport: { + messae: 'hjdklqehlk', + }, + }, + }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); + } + } else if (request.method === 'POST') { + const payload = await request.json(); + const { namespace, event } = payload; - let device; + const pcThreshold = 1024; + const tabletThreshold = 768; - if (event.event.width < tabletThreshold) { - device = "mobile"; - } else if (event.event.width < pcThreshold) { - device = "tablet"; - } else { - device = "pc"; - } + let device; + if (event.event.width < tabletThreshold) { + device = 'mobile'; + } else if (event.event.width < pcThreshold) { + device = 'tablet'; + } else { + device = 'pc'; + } - try { - const response = await prisma.analytics.create({ - data: { - type: namespace, - os: os, - browser: browser, - device, - location: `${ipinfo.city}, ${ipinfo.region}, ${ipinfo.country}`, - path: event.path, - siteId: event.event.siteId || null, - blogId: event.event.blogId || null, - } - }) + try { + const response = await prisma.analytics.create({ + data: { + type: namespace, + os: os, + browser: browser, + device, + location: `${ipinfo.city}, ${ipinfo.region}, ${ipinfo.country}`, + path: event.path, + siteId: event.event.siteId || null, + blogId: event.event.blogId || null, + }, + }); - if (event.event.siteId) { - await prisma.site.update({ - where: { - id: event.event.siteId - }, - data: { - totalviews: { - increment: 1 - } - } - }) - } + if (event.event.siteId) { + await prisma.site.update({ + where: { + id: event.event.siteId, + }, + data: { + totalviews: { + increment: 1, + }, + }, + }); + } - if (event.event.blogId) { - await prisma.blog.update({ - where: { - id: event.event.blogId - }, - data: { - totalviews: { - increment: 1 - } - } - }) - } + if (event.event.blogId) { + await prisma.blog.update({ + where: { + id: event.event.blogId, + }, + data: { + totalviews: { + increment: 1, + }, + }, + }); + } - return Response.json({ status: "tracked " }); - } catch (error) { - console.error({ error: error }) - return Response.json({ error: error }); - } - } else { - return Response.json({ error: "Method not allowed" }, { status: 405 }); + return Response.json({ status: 'tracked ' }); + } catch (error) { + console.error({ error: error }); + return Response.json({ error: error }); } + } else { + return Response.json({ error: 'Method not allowed' }, { status: 405 }); + } } - export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts index ec4b41e..895bf3d 100644 --- a/app/api/upload/route.ts +++ b/app/api/upload/route.ts @@ -1,37 +1,41 @@ -import { NextResponse } from "next/server"; -import { UTApi } from "uploadthing/server"; -export const runtime = "edge"; +import { NextResponse } from 'next/server'; +import { UTApi } from 'uploadthing/server'; +export const runtime = 'edge'; const utapi = new UTApi(); export async function POST(req: Request) { - if (!process.env.UPLOADTHING_SECRET) { - return new Response( - "Missing UPLOADTHING_SECRET. Don't forget to add that to your .env file.", - { - status: 401, - }, - ); - } - - // console.log(req.body) + if (!process.env.UPLOADTHING_SECRET) { + return new Response( + "Missing UPLOADTHING_SECRET. Don't forget to add that to your .env file.", + { + status: 401, + } + ); + } - const file = req.body || ""; - const filename = req.headers.get("x-vercel-filename") || "file.txt"; - const contentType = req.headers.get("content-type") || "text/plain"; - const fileType = `.${contentType.split("/")[1]}`; + // console.log(req.body) - // construct final filename based on content-type if not provided - const finalName = filename.includes(fileType) - ? filename - : `${filename}${fileType}`; + const file = req.body || ''; + const filename = req.headers.get('x-vercel-filename') || 'file.txt'; + const contentType = req.headers.get('content-type') || 'text/plain'; + const fileType = `.${contentType.split('/')[1]}`; - const fileData = await new Response(file).arrayBuffer(); + // construct final filename based on content-type if not provided + const finalName = filename.includes(fileType) + ? filename + : `${filename}${fileType}`; + const fileData = await new Response(file).arrayBuffer(); - const upload = await utapi.uploadFiles(new File([new Uint8Array(fileData)], finalName)); - return NextResponse.json({ - url: upload.data?.url - }, { - status: 200, - }); + const upload = await utapi.uploadFiles( + new File([new Uint8Array(fileData)], finalName) + ); + return NextResponse.json( + { + url: upload.data?.url, + }, + { + status: 200, + } + ); } diff --git a/app/api/uploadthing/core.ts b/app/api/uploadthing/core.ts index 3f1e7b3..1b76ae5 100644 --- a/app/api/uploadthing/core.ts +++ b/app/api/uploadthing/core.ts @@ -1,5 +1,5 @@ -import { auth } from "@clerk/nextjs/server"; -import { createUploadthing, type FileRouter } from "uploadthing/next"; +import { auth } from '@clerk/nextjs/server'; +import { createUploadthing, type FileRouter } from 'uploadthing/next'; const f = createUploadthing(); @@ -7,28 +7,28 @@ const f = createUploadthing(); // FileRouter for your app, can contain multiple FileRoutes export const ourFileRouter = { - // Define as many FileRoutes as you like, each with a unique routeSlug - imageUploader: f({ image: { maxFileSize: "64MB" } }) - // Set permissions and file types for this FileRoute - .middleware(async ({ req }) => { - // This code runs on your server before upload - const user = await auth(); - - // If you throw, the user will not be able to upload - if (!user) throw new Error("Unauthorized"); - - // Whatever is returned here is accessible in onUploadComplete as `metadata` - return { userId: user.userId }; - }) - .onUploadComplete(async ({ metadata, file }) => { - // This code RUNS ON YOUR SERVER after upload - // console.log("Upload complete for userId:", metadata.userId); - - // console.log("file url", file.url); - - // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback - return { uploadedBy: metadata.userId }; - }), + // Define as many FileRoutes as you like, each with a unique routeSlug + imageUploader: f({ image: { maxFileSize: '64MB' } }) + // Set permissions and file types for this FileRoute + .middleware(async ({ req }) => { + // This code runs on your server before upload + const user = await auth(); + + // If you throw, the user will not be able to upload + if (!user) throw new Error('Unauthorized'); + + // Whatever is returned here is accessible in onUploadComplete as `metadata` + return { userId: user.userId }; + }) + .onUploadComplete(async ({ metadata, file }) => { + // This code RUNS ON YOUR SERVER after upload + // console.log("Upload complete for userId:", metadata.userId); + + // console.log("file url", file.url); + + // !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback + return { uploadedBy: metadata.userId }; + }), } satisfies FileRouter; -export type OurFileRouter = typeof ourFileRouter; \ No newline at end of file +export type OurFileRouter = typeof ourFileRouter; diff --git a/app/api/uploadthing/route.ts b/app/api/uploadthing/route.ts index cb3ddf6..56cb516 100644 --- a/app/api/uploadthing/route.ts +++ b/app/api/uploadthing/route.ts @@ -1,8 +1,8 @@ -import { createNextRouteHandler } from "uploadthing/next"; +import { createNextRouteHandler } from 'uploadthing/next'; -import { ourFileRouter } from "./core"; +import { ourFileRouter } from './core'; // Export routes for Next App Router export const { GET, POST } = createNextRouteHandler({ - router: ourFileRouter, -}); \ No newline at end of file + router: ourFileRouter, +}); diff --git a/app/api/user/certificate/route.ts b/app/api/user/certificate/route.ts index 0137da7..1fa7e49 100644 --- a/app/api/user/certificate/route.ts +++ b/app/api/user/certificate/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.userCertificate.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! certificate created created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.userCertificate.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! certificate created created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/user/project/route.ts b/app/api/user/project/route.ts index 6e7dde1..072482a 100644 --- a/app/api/user/project/route.ts +++ b/app/api/user/project/route.ts @@ -1,32 +1,31 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs"; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs'; export const dynamic = 'force-dynamic'; async function handler(request: Request) { - if (request.method === "POST") { - try { - const userID = auth(); - if (!userID) return Response.json({ status: "Not Authorised" }); - const { ...data } = await request.json(); - await prisma.projects.create({ - data: { - ...data, - user_id: userID.userId!, - }, - }); - return Response.json({ status: "ok! created" }); - } - catch (err) { - console.error({ error: err }) - return Response.json({ error: err }); - } - } else { - return Response.json({ - error: "Method not allowed", - }) + if (request.method === 'POST') { + try { + const userID = auth(); + if (!userID) return Response.json({ status: 'Not Authorised' }); + const { ...data } = await request.json(); + await prisma.projects.create({ + data: { + ...data, + user_id: userID.userId!, + }, + }); + return Response.json({ status: 'ok! created' }); + } catch (err) { + console.error({ error: err }); + return Response.json({ error: err }); } + } else { + return Response.json({ + error: 'Method not allowed', + }); + } } export const GET = handler; -export const POST = handler; \ No newline at end of file +export const POST = handler; diff --git a/app/api/webhook/user/route.ts b/app/api/webhook/user/route.ts index 84c53b8..e46500d 100644 --- a/app/api/webhook/user/route.ts +++ b/app/api/webhook/user/route.ts @@ -1,77 +1,79 @@ -import prisma from "@/lib/db"; -import { IncomingHttpHeaders } from "http"; -import { headers } from "next/headers"; -import { NextResponse } from "next/server"; -import { Webhook, WebhookRequiredHeaders } from "svix"; +import prisma from '@/lib/db'; +import { IncomingHttpHeaders } from 'http'; +import { headers } from 'next/headers'; +import { NextResponse } from 'next/server'; +import { Webhook, WebhookRequiredHeaders } from 'svix'; -const webhookSecret = process.env.CLERK_WEBHOOK_SIGNING_KEY || ""; +const webhookSecret = process.env.CLERK_WEBHOOK_SIGNING_KEY || ''; async function handler(request: Request) { - const payload = await request.json(); - const headersList = headers(); - const heads = { - "svix-id": headersList.get("svix-id"), - "svix-timestamp": headersList.get("svix-timestamp"), - "svix-signature": headersList.get("svix-signature"), - }; - const wh = new Webhook(webhookSecret); - let evt: Event | null = null; + const payload = await request.json(); + const headersList = headers(); + const heads = { + 'svix-id': headersList.get('svix-id'), + 'svix-timestamp': headersList.get('svix-timestamp'), + 'svix-signature': headersList.get('svix-signature'), + }; + const wh = new Webhook(webhookSecret); + let evt: Event | null = null; - try { - evt = wh.verify( - JSON.stringify(payload), - heads as IncomingHttpHeaders & WebhookRequiredHeaders - ) as Event; - } catch (err) { - console.error((err as Error).message); - return NextResponse.json({}, { status: 400 }); - } + try { + evt = wh.verify( + JSON.stringify(payload), + heads as IncomingHttpHeaders & WebhookRequiredHeaders + ) as Event; + } catch (err) { + console.error((err as Error).message); + return NextResponse.json({}, { status: 400 }); + } - const eventType: EventType = evt.type; - if (eventType === "user.created" || eventType === "user.updated") { + const eventType: EventType = evt.type; + if (eventType === 'user.created' || eventType === 'user.updated') { + const { + id, + username, + email_addresses, + first_name, + last_name, + profile_image_url, + ...attributes + } = evt.data; - const { id, - username, - email_addresses, - first_name, - last_name, - profile_image_url, - ...attributes - } = evt.data; + await prisma.user.upsert({ + where: { id: id as string }, + create: { + id: id as string, + username: username as string, + email: email_addresses[0].email_address as string, + firstname: (first_name as string) || '', + lastname: (last_name as string) || '', + avatar: profile_image_url, + attributes: attributes, + }, + update: { + username: username as string, + email: email_addresses[0].email_address as string, + firstname: (first_name as string) || '', + lastname: (last_name as string) || '', + attributes: attributes, + }, + }); + } - await prisma.user.upsert({ - where: { id: id as string }, - create: { - id: id as string, - username: username as string, - email: email_addresses[0].email_address as string, - firstname: first_name as string || "", - lastname: last_name as string || "", - avatar: profile_image_url, - attributes: attributes - }, - update: { - username: username as string, - email: email_addresses[0].email_address as string, - firstname: first_name as string || "", - lastname: last_name as string || "", - attributes: attributes, - }, - }); - } - - - return NextResponse.json({ - message: "ok", - }, { status: 200 }); + return NextResponse.json( + { + message: 'ok', + }, + { status: 200 } + ); } -type EventType = "user.created" | "user.updated" | "*"; +type EventType = 'user.created' | 'user.updated' | '*'; type Event = { - data: Record; - object: "event"; - type: EventType; + data: Record; + object: 'event'; + type: EventType; }; export const GET = handler; diff --git a/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx b/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx index 51a26b0..8722f84 100644 --- a/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx +++ b/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx @@ -1,12 +1,9 @@ -import { SignIn } from "@clerk/nextjs"; +import { SignIn } from '@clerk/nextjs'; export default function Page() { - return ( -
- -
- ) -} \ No newline at end of file + return ( +
+ +
+ ); +} diff --git a/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx b/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx index 3d6b29b..b44b5c5 100644 --- a/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx +++ b/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx @@ -1,9 +1,9 @@ -import { SignUp } from "@clerk/nextjs"; +import { SignUp } from '@clerk/nextjs'; export default function Page() { - return ( -
- -
- ) -} \ No newline at end of file + return ( +
+ +
+ ); +} diff --git a/app/app/community/page.tsx b/app/app/community/page.tsx index b9a5880..71978ef 100644 --- a/app/app/community/page.tsx +++ b/app/app/community/page.tsx @@ -1,15 +1,15 @@ -import NavBar from "@/components/common/NavBar" -import { TypographyH1 } from "@/components/common/Typography" +import NavBar from '@/components/common/NavBar'; +import { TypographyH1 } from '@/components/common/Typography'; function CommunityPage() { - return ( - <> - -
- Comming Soon -
- - ) + return ( + <> + +
+ Comming Soon +
+ + ); } -export default CommunityPage \ No newline at end of file +export default CommunityPage; diff --git a/app/app/dashboard/feedback/page.tsx b/app/app/dashboard/feedback/page.tsx index 76bf078..5a23350 100644 --- a/app/app/dashboard/feedback/page.tsx +++ b/app/app/dashboard/feedback/page.tsx @@ -1,11 +1,11 @@ -import FeedbackForm from "@/components/dashboard/feedback/FeedbackForm" +import FeedbackForm from '@/components/dashboard/feedback/FeedbackForm'; function FeedbackPage() { - return ( -
- -
- ) + return ( +
+ +
+ ); } -export default FeedbackPage \ No newline at end of file +export default FeedbackPage; diff --git a/app/app/dashboard/layout.tsx b/app/app/dashboard/layout.tsx index 6416a51..ca4f9c1 100644 --- a/app/app/dashboard/layout.tsx +++ b/app/app/dashboard/layout.tsx @@ -1,30 +1,24 @@ - - -import NavBar from "@/components/common/NavBar"; -import SideNavBar from "@/components/dashboard/DashBoardSideNavBar"; -import { APP_DESC, APP_NAME } from "@/lib/contants"; - +import NavBar from '@/components/common/NavBar'; +import SideNavBar from '@/components/dashboard/DashBoardSideNavBar'; +import { APP_DESC, APP_NAME } from '@/lib/contants'; export const metadata = { - title: `Dashboard - ${APP_NAME}`, - description: APP_DESC, + title: `Dashboard - ${APP_NAME}`, + description: APP_DESC, }; - export default function DashboardLayout({ - children, // will be a page or nested layout + children, // will be a page or nested layout }: { - children: React.ReactNode + children: React.ReactNode; }) { - return ( -
- -
- -
- {children} -
-
-
- ) -} \ No newline at end of file + return ( +
+ +
+ +
{children}
+
+
+ ); +} diff --git a/app/app/dashboard/page.tsx b/app/app/dashboard/page.tsx index 341f7d2..2b1221e 100644 --- a/app/app/dashboard/page.tsx +++ b/app/app/dashboard/page.tsx @@ -1,17 +1,15 @@ - -import AlertCard from "@/components/dashboard/AlertCard"; -import { currentUser } from "@clerk/nextjs/server"; -import { redirect } from "next/navigation"; - +import AlertCard from '@/components/dashboard/AlertCard'; +import { currentUser } from '@clerk/nextjs/server'; +import { redirect } from 'next/navigation'; export default async function Page() { - const User = await currentUser(); - if (!User) { - redirect("/sign-in") - } - return ( -
- -
- ) + const User = await currentUser(); + if (!User) { + redirect('/sign-in'); + } + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/analytics/page.tsx b/app/app/dashboard/portfolio/[slug]/analytics/page.tsx index 2012de4..70e3135 100644 --- a/app/app/dashboard/portfolio/[slug]/analytics/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/analytics/page.tsx @@ -1,40 +1,39 @@ -import { TypographyH1, TypographyH3 } from "@/components/common/Typography"; -import PortfolioAnaytlics from "@/components/dashboard/portfolio/PortfolioAnaytlics"; -import UserAgentsAnalytics from "@/components/dashboard/portfolio/UserAgentsAnalytics"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import { TypographyH1, TypographyH3 } from '@/components/common/Typography'; +import PortfolioAnaytlics from '@/components/dashboard/portfolio/PortfolioAnaytlics'; +import UserAgentsAnalytics from '@/components/dashboard/portfolio/UserAgentsAnalytics'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; async function AnalyticsPage({ params }: { params: { slug: string } }) { - - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - - - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - - return ( -
- Analytics 🔍🐬 - Portfolio Insights 🔍 - -

- -
- ) + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); + + if (!data || data.userId !== session.userId) { + notFound(); + } + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + + return ( +
+ Analytics 🔍🐬 + + Portfolio Insights 🔍 + + +
+
+ +
+ ); } -export default AnalyticsPage \ No newline at end of file +export default AnalyticsPage; diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx index 9727873..df6408e 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/not-found.tsx @@ -1,18 +1,18 @@ -import Image from "next/image"; +import Image from 'next/image'; export default function NotFoundPost() { - return ( -
-

404

- missing site -

- Blogs does not exist, or you do not have permission to edit it -

-
- ); + return ( +
+

404

+ missing site +

+ Blogs does not exist, or you do not have permission to edit it +

+
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx index dddacc6..78ac2d3 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/page.tsx @@ -1,34 +1,34 @@ -import BlogEditor from "@/components/dashboard/portfolio/blog/blog-editor"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; - -export default async function BlogPage({ params }: { params: { blogslug: string } }) { - - const session = auth(); - - if (!session) { - redirect("/sign-in"); - } - - - const data = await prisma.blog.findUnique({ - where: { - id: decodeURIComponent(params.blogslug), +import BlogEditor from '@/components/dashboard/portfolio/blog/blog-editor'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; + +export default async function BlogPage({ + params, +}: { + params: { blogslug: string }; +}) { + const session = auth(); + + if (!session) { + redirect('/sign-in'); + } + + const data = await prisma.blog.findUnique({ + where: { + id: decodeURIComponent(params.blogslug), + }, + include: { + site: { + select: { + subdomain: true, }, - include: { - site: { - select: { - subdomain: true, - }, - }, - }, - }); - if (!data || data.userId !== session.userId) { - notFound(); - } - - - return ; + }, + }, + }); + if (!data || data.userId !== session.userId) { + notFound(); + } + + return ; } - diff --git a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx index c5caa07..82207bf 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/[blogslug]/settings/page.tsx @@ -1,9 +1,9 @@ -import Form from "@/components/form"; -import DeletePostForm from "@/components/form/delete-post-form"; -import { updatePostMetadata } from "@/lib/actions"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import Form from '@/components/form'; +import DeletePostForm from '@/components/form/delete-post-form'; +import { updatePostMetadata } from '@/lib/actions'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; export default async function PostSettings({ params, @@ -12,7 +12,7 @@ export default async function PostSettings({ }) { const session = auth(); if (!session) { - redirect("/login"); + redirect('/login'); } const data = await prisma.blog.findUnique({ where: { @@ -33,10 +33,10 @@ export default async function PostSettings({ description="The slug is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens." helpText="Please use a slug that is unique to this post." inputAttrs={{ - name: "slug", - type: "text", + name: 'slug', + type: 'text', defaultValue: data?.slug!, - placeholder: "slug", + placeholder: 'slug', }} handleSubmit={updatePostMetadata} /> @@ -46,8 +46,8 @@ export default async function PostSettings({ description="The thumbnail image for your post. Accepted formats: .png, .jpg, .jpeg" helpText="Max file size 2MB. Recommended size 1200x630." inputAttrs={{ - name: "image", - type: "file", + name: 'image', + type: 'file', defaultValue: data?.image!, }} handleSubmit={updatePostMetadata} diff --git a/app/app/dashboard/portfolio/[slug]/blog/page.tsx b/app/app/dashboard/portfolio/[slug]/blog/page.tsx index f39c913..56c6567 100644 --- a/app/app/dashboard/portfolio/[slug]/blog/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/blog/page.tsx @@ -1,40 +1,43 @@ -import AllBlogs from "@/components/dashboard/portfolio/blog/all-blogs"; -import CreateBlogButton from "@/components/dashboard/portfolio/blog/create-blog-button"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; +import AllBlogs from '@/components/dashboard/portfolio/blog/all-blogs'; +import CreateBlogButton from '@/components/dashboard/portfolio/blog/create-blog-button'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; -export default async function SiteBlogsPage({ params, }: { params: { slug: string } }) { - const session = auth(); +export default async function SiteBlogsPage({ + params, +}: { + params: { slug: string }; +}) { + const session = auth(); - if (!session.userId) { - redirect("/sign-in"); - } + if (!session.userId) { + redirect('/sign-in'); + } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - if (!data || data.userId !== session.userId) { - notFound(); - } + if (!data || data.userId !== session.userId) { + notFound(); + } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - return ( - <> -
-
-

- All Posts for {data.name} -

-
- -
- - - ) + return ( + <> +
+
+

+ All Posts for {data.name} +

+
+ +
+ + + ); } - diff --git a/app/app/dashboard/portfolio/[slug]/layout.tsx b/app/app/dashboard/portfolio/[slug]/layout.tsx index 83f4707..3d0706e 100644 --- a/app/app/dashboard/portfolio/[slug]/layout.tsx +++ b/app/app/dashboard/portfolio/[slug]/layout.tsx @@ -1,33 +1,32 @@ - -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; -import { ReactNode } from "react"; - - -export default async function SiteLayout({ children, params }: - { children: ReactNode, params: { slug: string } }) { - - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } - - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - return ( -
- {children} -
- ); +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; +import { ReactNode } from 'react'; + +export default async function SiteLayout({ + children, + params, +}: { + children: ReactNode; + params: { slug: string }; +}) { + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); + + if (!data || data.userId !== session.userId) { + notFound(); + } + + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; + + return ( +
{children}
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/loading.tsx b/app/app/dashboard/portfolio/[slug]/loading.tsx index 30fa440..1ea5973 100644 --- a/app/app/dashboard/portfolio/[slug]/loading.tsx +++ b/app/app/dashboard/portfolio/[slug]/loading.tsx @@ -1,12 +1,11 @@ // a bunch of loading divs -import { Loader2Icon } from "lucide-react"; - +import { Loader2Icon } from 'lucide-react'; export default function Loading() { - return ( -
- -
- ); + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/not-found.tsx b/app/app/dashboard/portfolio/[slug]/not-found.tsx index 22656df..e9cc9c0 100644 --- a/app/app/dashboard/portfolio/[slug]/not-found.tsx +++ b/app/app/dashboard/portfolio/[slug]/not-found.tsx @@ -1,26 +1,26 @@ -import Image from "next/image"; +import Image from 'next/image'; export default function NotFoundSite() { - return ( -
-

404

- missing site - missing site -

- Site does not exist, or you do not have permission to view it -

-
- ); + return ( +
+

404

+ missing site + missing site +

+ Site does not exist, or you do not have permission to view it +

+
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/page.tsx b/app/app/dashboard/portfolio/[slug]/page.tsx index e09fb96..332ba55 100644 --- a/app/app/dashboard/portfolio/[slug]/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/page.tsx @@ -1,57 +1,52 @@ -import { TypographyH1, TypographyH2 } from "@/components/common/Typography"; -import BlogAnalytics from "@/components/dashboard/portfolio/BlogAnalytics"; -import PortfolioAnaytlics from "@/components/dashboard/portfolio/PortfolioAnaytlics"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { Button } from "@nextui-org/react"; -import Link from "next/link"; -import { notFound, redirect } from "next/navigation"; -async function SinglePortfolioPage({ - params, -}: { - params: { slug: string }; -}) { +import { TypographyH1, TypographyH2 } from '@/components/common/Typography'; +import BlogAnalytics from '@/components/dashboard/portfolio/BlogAnalytics'; +import PortfolioAnaytlics from '@/components/dashboard/portfolio/PortfolioAnaytlics'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { Button } from '@nextui-org/react'; +import Link from 'next/link'; +import { notFound, redirect } from 'next/navigation'; +async function SinglePortfolioPage({ params }: { params: { slug: string } }) { + const session = auth(); + if (!session) { + redirect('/sign-in'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - const session = auth(); - if (!session) { - redirect("/sign-in"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); + if (!data || data.userId !== session.userId) { + notFound(); + } + const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - if (!data || data.userId !== session.userId) { - notFound(); - } - const url = `${data.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`; - - - - return ( -
- - - - Portfolio Insights 🔍 - - Blogs Insights 🔍 - -
- ) + return ( +
+ + + + + Portfolio Insights 🔍 + + + Blogs Insights 🔍 + +
+ ); } -export default SinglePortfolioPage \ No newline at end of file +export default SinglePortfolioPage; diff --git a/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx index d7752ef..02ab760 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/AppearanceSection.tsx @@ -1,64 +1,66 @@ -import Form from "@/components/form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; +import Form from '@/components/form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; -export default async function AppearanceSection({ siteId }: { siteId: string }) { +export default async function AppearanceSection({ + siteId, +}: { + siteId: string; +}) { + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(siteId), + }, + }); - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(siteId), - }, - }); - - - return ( -
-
- - - -
- ) -} \ No newline at end of file + return ( +
+ + + + +
+ ); +} diff --git a/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx index ff80892..c212591 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/CertificateSection.tsx @@ -1,12 +1,11 @@ -import { TypographyH1 } from "@/components/common/Typography" +import { TypographyH1 } from '@/components/common/Typography'; function CertificateSection() { - return ( -
- Comming Soon... - -
- ) + return ( +
+ Comming Soon... +
+ ); } -export default CertificateSection \ No newline at end of file +export default CertificateSection; diff --git a/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx index 82ca705..f546131 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/DomainSection.tsx @@ -1,47 +1,44 @@ -import Form from "@/components/form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; - +import Form from '@/components/form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; export default async function DomainSection({ siteId }: { siteId: string }) { + // console.log(siteId) + const data = await prisma.site.findUnique({ + where: { + id: siteId as string, + }, + }); - // console.log(siteId) - const data = await prisma.site.findUnique({ - where: { - id: siteId as string, - }, - }); - - - return ( -
- - -
- ) + return ( +
+ + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx index 5f6d370..cf1cc9c 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/EducationSection.tsx @@ -1,49 +1,43 @@ - -import EducationCard from "@/components/dashboard/portfolio/education/EducationCard"; -import AddEducationForm from "@/components/form/education-form"; -import { Separator } from "@/components/ui/separator"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import EducationCard from '@/components/dashboard/portfolio/education/EducationCard'; +import AddEducationForm from '@/components/form/education-form'; +import { Separator } from '@/components/ui/separator'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; async function EducationSection({ siteId }: { siteId: string }) { + const user = auth(); + if (!user.userId) { + return '/'; + } + const education = await prisma.userEducation.findMany({ + where: { + user_id: user.userId as string, + siteId, + }, + orderBy: { + school_end_date: 'desc', + }, + }); - const user = auth(); - if (!user.userId) { - return ("/") - } - const education = await prisma.userEducation.findMany({ - where: { - user_id: user.userId as string, - siteId, - }, - orderBy: { - school_end_date: "desc", - }, - }) - - - return education.length > 0 ? ( -
-
- Add Education - -
- {education.map((education) => ( - - ))} - -
- ) : ( -
-

- You do not have any Education yet. Create one to get started. -

- -
- ); + return education.length > 0 ? ( +
+
+ Add Education + +
+ {education.map((education) => ( + + ))} + +
+ ) : ( +
+

+ You do not have any Education yet. Create one to get started. +

+ +
+ ); } -export default EducationSection \ No newline at end of file +export default EducationSection; diff --git a/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx index 069c2b7..cdf10da 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/GeneralSection.tsx @@ -1,81 +1,81 @@ -import { TypographyH2 } from "@/components/common/Typography"; -import Form from "@/components/form"; -import DeleteSiteForm from "@/components/form/delete-site-form"; -import AboutEditor from "@/components/form/site-about-form"; -import SocialMediaForm from "@/components/form/social-media-form"; -import { updateSite } from "@/lib/actions"; -import prisma from "@/lib/db"; - +import { TypographyH2 } from '@/components/common/Typography'; +import Form from '@/components/form'; +import DeleteSiteForm from '@/components/form/delete-site-form'; +import AboutEditor from '@/components/form/site-about-form'; +import SocialMediaForm from '@/components/form/social-media-form'; +import { updateSite } from '@/lib/actions'; +import prisma from '@/lib/db'; export default async function GeneralSection({ siteId }: { siteId: string }) { - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(siteId), - }, - }); + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(siteId), + }, + }); - return ( -
- + return ( +
+ - - - - Social Media 🤖 - - Danger Zone - -
- ) + + + + Social Media 🤖 + + + Danger Zone + + +
+ ); } - diff --git a/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx b/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx index 6c6968f..78b7a73 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/PortfolioSettingNav.tsx @@ -1,80 +1,76 @@ -import { - Tabs, - TabsContent, - TabsList, - TabsTrigger, -} from "@/components/ui/tabs"; -import AppearanceSection from "./AppearanceSection"; -import CertificateSection from "./CertificateSection"; -import DomainSection from "./DomainSection"; -import EducationSection from "./EducationSection"; -import GeneralSection from "./GeneralSection"; -import SkillsToolsSection from "./SkillsToolsSection"; -import WorkExperienceSection from "./WorkSection"; - +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; +import AppearanceSection from './AppearanceSection'; +import CertificateSection from './CertificateSection'; +import DomainSection from './DomainSection'; +import EducationSection from './EducationSection'; +import GeneralSection from './GeneralSection'; +import SkillsToolsSection from './SkillsToolsSection'; +import WorkExperienceSection from './WorkSection'; export default function SiteSettingsNav({ slug }: { slug: string }) { - const navItems = [ - { - name: "General", - value: "general", - component: , - }, - { - name: "Domain", - value: "domain", - component: , - }, - { - name: "Education", - value: "education", - component: , - }, - { - name: "Skills & Tools", - value: "tools", - component: , - }, - { - name: "Work", - value: "work", - component: , - }, - { - name: "Project", - value: "project", - component: , - }, - { - name: "Certification", - value: "certificate", - component: , - }, - { - name: "Appearance", - value: "appearance", - component: - }, - ]; + const navItems = [ + { + name: 'General', + value: 'general', + component: , + }, + { + name: 'Domain', + value: 'domain', + component: , + }, + { + name: 'Education', + value: 'education', + component: , + }, + { + name: 'Skills & Tools', + value: 'tools', + component: , + }, + { + name: 'Work', + value: 'work', + component: , + }, + { + name: 'Project', + value: 'project', + component: , + }, + { + name: 'Certification', + value: 'certificate', + component: , + }, + { + name: 'Appearance', + value: 'appearance', + component: , + }, + ]; - return ( -
- - - { - navItems.map((nav, index) => ( - {nav.name} - )) - } - - { - navItems.map((nav, index) => ( - {nav.component} - )) - } - -
- ); + return ( +
+ + + {navItems.map((nav, index) => ( + + {nav.name} + + ))} + + {navItems.map((nav, index) => ( + + {nav.component} + + ))} + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx index 658940d..8666ef3 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/SkillsToolsSection.tsx @@ -1,65 +1,68 @@ -import SkillForm from "@/components/dashboard/portfolio/skills/SkillForm"; -import ToolForm from "@/components/dashboard/portfolio/skills/ToolForm"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import SkillForm from '@/components/dashboard/portfolio/skills/SkillForm'; +import ToolForm from '@/components/dashboard/portfolio/skills/ToolForm'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +export default async function SkillsToolsSection({ + siteId, +}: { + siteId: string; +}) { + const user = auth(); + if (!user.userId) { + return '/'; + } -export default async function SkillsToolsSection({ siteId }: { siteId: string }) { - const user = auth(); - if (!user.userId) { - return ("/") - } + const masterdata = await Promise.all([ + await prisma.site.findFirst({ + where: { + id: siteId, + }, + select: { + skills: true, + siteTechStack: true, + }, + }), + prisma.techStack.findMany({ + where: { + siteTechStack: { + some: { + siteId: siteId, + }, + }, + }, + }), + await prisma.techStack.findMany(), + ]); + // const Siteskills = await prisma.site.findFirst({ + // where: { + // id: siteId + // }, + // select: { + // skills: true, + // siteTechStack: true + // } + // }) + // const techstack = await prisma.techStack.findMany({ + // where: { + // siteTechStack: { + // some: { + // siteId: siteId + // } + // } + // } + // }) + // const alltechstack = await prisma.techStack.findMany(); - - const masterdata = await Promise.all([ - await prisma.site.findFirst({ - where: { - id: siteId - }, - select: { - skills: true, - siteTechStack: true - } - }), - prisma.techStack.findMany({ - where: { - siteTechStack: { - some: { - siteId: siteId - } - } - } - }), - await prisma.techStack.findMany() - ]) - // const Siteskills = await prisma.site.findFirst({ - // where: { - // id: siteId - // }, - // select: { - // skills: true, - // siteTechStack: true - // } - // }) - // const techstack = await prisma.techStack.findMany({ - // where: { - // siteTechStack: { - // some: { - // siteId: siteId - // } - // } - // } - // }) - - - // const alltechstack = await prisma.techStack.findMany(); - - - return ( -
- - -
- ) + return ( +
+ + +
+ ); } diff --git a/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx b/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx index 3dba533..f2ad083 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/WorkSection.tsx @@ -1,46 +1,43 @@ -import WorkExperienceCard from "@/components/dashboard/portfolio/work/WorkExperienceCard"; -import WorkExperienceForm from "@/components/form/work-form"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; +import WorkExperienceCard from '@/components/dashboard/portfolio/work/WorkExperienceCard'; +import WorkExperienceForm from '@/components/form/work-form'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +export default async function WorkExperienceSection({ + siteId, +}: { + siteId: string; +}) { + const user = auth(); + if (!user.userId) { + return '/'; + } + const work = await prisma.userWorkExperience.findMany({ + where: { + siteId, + user_id: user.userId as string, + }, + orderBy: { + employment_start_date: 'desc', + }, + }); -export default async function WorkExperienceSection({ siteId }: { siteId: string }) { - const user = auth(); - if (!user.userId) { - return ("/") - } - const work = await prisma.userWorkExperience.findMany({ - where: { - siteId, - user_id: user.userId as string - }, - orderBy: { - employment_start_date: "desc", - }, - - }) - - - - return work.length > 0 ? ( -
-
- Add Work Experience - -
- {work.map((work) => ( - - ))} -
- ) : ( -
-

- You do not have any Work Experience yet. Create one to get started. -

- -
- ); -} \ No newline at end of file + return work.length > 0 ? ( +
+
+ Add Work Experience + +
+ {work.map((work) => ( + + ))} +
+ ) : ( +
+

+ You do not have any Work Experience yet. Create one to get started. +

+ +
+ ); +} diff --git a/app/app/dashboard/portfolio/[slug]/settings/page.tsx b/app/app/dashboard/portfolio/[slug]/settings/page.tsx index 8fb7ccc..0adc645 100644 --- a/app/app/dashboard/portfolio/[slug]/settings/page.tsx +++ b/app/app/dashboard/portfolio/[slug]/settings/page.tsx @@ -1,32 +1,30 @@ -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { notFound, redirect } from "next/navigation"; -import SiteSettingsNav from "./PortfolioSettingNav"; - +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { notFound, redirect } from 'next/navigation'; +import SiteSettingsNav from './PortfolioSettingNav'; export default async function PortfolioSettingsIndex({ - params, + params, }: { - params: { slug: string }; + params: { slug: string }; }) { + const session = auth(); + if (!session.userId) { + redirect('/'); + } + const data = await prisma.site.findUnique({ + where: { + id: decodeURIComponent(params.slug), + }, + }); - const session = auth(); - if (!session.userId) { - redirect("/"); - } - const data = await prisma.site.findUnique({ - where: { - id: decodeURIComponent(params.slug), - }, - }); - - if (!data || data.userId !== session.userId) { - notFound(); - } + if (!data || data.userId !== session.userId) { + notFound(); + } - return ( -
- -
- ) + return ( +
+ +
+ ); } diff --git a/app/app/dashboard/portfolio/page.tsx b/app/app/dashboard/portfolio/page.tsx index 13cb686..3814ae3 100644 --- a/app/app/dashboard/portfolio/page.tsx +++ b/app/app/dashboard/portfolio/page.tsx @@ -1,15 +1,15 @@ -import { TypographyH3 } from "@/components/common/Typography"; -import AllPortfolioLayout from "@/components/dashboard/portfolio/AllPortfolio"; -import CreatePortfolio from "@/components/dashboard/portfolio/CreatePortfolio"; +import { TypographyH3 } from '@/components/common/Typography'; +import AllPortfolioLayout from '@/components/dashboard/portfolio/AllPortfolio'; +import CreatePortfolio from '@/components/dashboard/portfolio/CreatePortfolio'; export default async function PortfolioPage() { - return ( -
-
- All Portfolio - -
- -
- ) + return ( +
+
+ All Portfolio + +
+ +
+ ); } diff --git a/app/app/dashboard/settings/page.tsx b/app/app/dashboard/settings/page.tsx index 24699c0..f6f5236 100644 --- a/app/app/dashboard/settings/page.tsx +++ b/app/app/dashboard/settings/page.tsx @@ -1,148 +1,148 @@ -import { TypographyH2 } from "@/components/common/Typography"; -import Form from "@/components/form"; -import { editUser } from "@/lib/actions"; -import prisma from "@/lib/db"; -import { auth } from "@clerk/nextjs/server"; -import { redirect } from "next/navigation"; +import { TypographyH2 } from '@/components/common/Typography'; +import Form from '@/components/form'; +import { editUser } from '@/lib/actions'; +import prisma from '@/lib/db'; +import { auth } from '@clerk/nextjs/server'; +import { redirect } from 'next/navigation'; // import { editUser } from "@/lib/actions"; export default async function SettingsPage() { - const user = auth(); - if (!user) { - return redirect("/sign-in"); - } + const user = auth(); + if (!user) { + return redirect('/sign-in'); + } - const userdetails = await prisma.user.findUnique({ - where: { - id: user.userId!, - }, - }); + const userdetails = await prisma.user.findUnique({ + where: { + id: user.userId!, + }, + }); - return ( -
-
-

- User Settings 🌱 -

- {/* */} - - - - - - Social Media 🤖 - - - - -
-
- ); + return ( +
+
+

+ User Settings 🌱 +

+ {/* */} + + + + + + Social Media 🤖 + + + + +
+
+ ); } diff --git a/app/app/editor/page.tsx b/app/app/editor/page.tsx index 74ff004..459c8f2 100644 --- a/app/app/editor/page.tsx +++ b/app/app/editor/page.tsx @@ -1,15 +1,7 @@ -import { Editor } from "novel" - - +import { Editor } from 'novel'; function page() { - return ( - - ) + return ; } -export default page \ No newline at end of file +export default page; diff --git a/app/app/explore/page.tsx b/app/app/explore/page.tsx index a5d79bf..fc2ec29 100644 --- a/app/app/explore/page.tsx +++ b/app/app/explore/page.tsx @@ -1,19 +1,17 @@ - -import BlogPreviewSection from "@/components/explore/BlogPreview"; -import CallToActionPreview from "@/components/explore/Cta"; -import ProductShowcase from "@/components/explore/FeatureShowcase"; -import LandingPage from "@/components/explore/LandingPage"; -import TestimonialsSection from "@/components/explore/Testimonials"; +import BlogPreviewSection from '@/components/explore/BlogPreview'; +import CallToActionPreview from '@/components/explore/Cta'; +import ProductShowcase from '@/components/explore/FeatureShowcase'; +import LandingPage from '@/components/explore/LandingPage'; +import TestimonialsSection from '@/components/explore/Testimonials'; export default async function Explore() { - return ( - <> - - - - - - - ) + return ( + <> + + + + + + + ); } - diff --git a/app/app/page.tsx b/app/app/page.tsx index f01e80a..4e6688c 100644 --- a/app/app/page.tsx +++ b/app/app/page.tsx @@ -1,14 +1,14 @@ -import Footer from "@/components/common/Footer"; -import NavBar from "@/components/common/NavBar"; -import BlogPreviewSection from "@/components/explore/BlogPreview"; -import CallToActionPreview from "@/components/explore/Cta"; -import ProductShowcase from "@/components/explore/FeatureShowcase"; -import TestimonialsSection from "@/components/explore/Testimonials"; -import LandingSection from "@/components/home/landingsection"; +import Footer from '@/components/common/Footer'; +import NavBar from '@/components/common/NavBar'; +import BlogPreviewSection from '@/components/explore/BlogPreview'; +import CallToActionPreview from '@/components/explore/Cta'; +import ProductShowcase from '@/components/explore/FeatureShowcase'; +import TestimonialsSection from '@/components/explore/Testimonials'; +import LandingSection from '@/components/home/landingsection'; export default function Home() { return ( -
+
diff --git a/app/home/page.tsx b/app/home/page.tsx index e63279f..d43d67d 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -1,34 +1,28 @@ -import { TypographyH1 } from "@/components/common/Typography" -import { Button } from "@nextui-org/react" -import Image from "next/image" -import Link from "next/link" - +import { TypographyH1 } from '@/components/common/Typography'; +import { Button } from '@nextui-org/react'; +import Image from 'next/image'; +import Link from 'next/link'; function Page() { - return ( -
- 🤫 Dicovered something unTold❗ - cool stuff discovered - - - -
- ) + return ( +
+ + 🤫 Dicovered something unTold❗ + + cool stuff discovered + + + +
+ ); } -export default Page \ No newline at end of file +export default Page; diff --git a/app/layout.tsx b/app/layout.tsx index aa58e29..b7c7e98 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,49 +1,53 @@ -import { Toaster } from "@/components/ui/sonner"; +import { Toaster } from '@/components/ui/sonner'; import { APP_DESC, APP_NAME } from '@/lib/contants'; -import { SpeedInsights } from "@vercel/speed-insights/next"; +import { SpeedInsights } from '@vercel/speed-insights/next'; import { GeistSans } from 'geist/font/sans'; -import { Metadata } from "next"; +import { Metadata } from 'next'; import '.././styles/globals.css'; import { Providers } from './NextUIProvider'; -const image = "https://app.dresume.me/placeholder.png"; +const image = 'https://app.dresume.me/placeholder.png'; export const metadata: Metadata = { + title: APP_NAME, + description: APP_DESC, + icons: ['https://app.dresume.me/favicon.ico'], + openGraph: { title: APP_NAME, description: APP_DESC, - icons: ["https://app.dresume.me/favicon.ico"], - openGraph: { - title: APP_NAME, - description: APP_DESC, - images: [image], - }, - twitter: { - card: "summary_large_image", - title: APP_NAME, - description: APP_DESC, - images: [image], - creator: "@abhishekkushwaha", - }, - metadataBase: new URL("https://app.dresume.me"), + images: [image], + }, + twitter: { + card: 'summary_large_image', + title: APP_NAME, + description: APP_DESC, + images: [image], + creator: '@abhishekkushwaha', + }, + metadataBase: new URL('https://app.dresume.me'), }; export default function RootLayout({ - children, + children, }: { - children: React.ReactNode; + children: React.ReactNode; }) { - return ( - - - - - - {/* */} - - {children} - - - - - - ); + return ( + + + + + + {/* */} + + {children} + + + + + + ); } diff --git a/app/not-found.tsx b/app/not-found.tsx index 3a2b986..89127a7 100644 --- a/app/not-found.tsx +++ b/app/not-found.tsx @@ -1,45 +1,36 @@ -import { TypographyH1 } from "@/components/common/Typography"; -import { Button } from "@nextui-org/react"; -import Image from "next/image"; -import Link from "next/link"; - - +import { TypographyH1 } from '@/components/common/Typography'; +import { Button } from '@nextui-org/react'; +import Image from 'next/image'; +import Link from 'next/link'; function NotFoundSite() { - return ( -
- 😖 404 😖 - missing site - missing site -

- LOOKS! Like you found a non registered sub domain with Us 🤖 -

- - - -
- ) + return ( +
+ 😖 404 😖 + missing site + missing site +

+ LOOKS! Like you found a non registered sub domain with Us 🤖 +

+ + + +
+ ); } -export default NotFoundSite \ No newline at end of file +export default NotFoundSite; diff --git a/commitlint.config.js b/commitlint.config.js index b0dc5b2..8ede5fd 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -9,42 +9,42 @@ // test: Adding missing tests or correcting existing tests module.exports = { - extends: ['@commitlint/config-conventional'], - rules: { - 'body-leading-blank': [1, 'always'], - 'body-max-line-length': [2, 'always', 100], - 'footer-leading-blank': [1, 'always'], - 'footer-max-line-length': [2, 'always', 100], - 'header-max-length': [2, 'always', 100], - 'scope-case': [2, 'always', 'lower-case'], - 'subject-case': [ - 2, - 'never', - ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], - ], - 'subject-empty': [2, 'never'], - 'subject-full-stop': [2, 'never', '.'], - 'type-case': [2, 'always', 'lower-case'], - 'type-empty': [2, 'never'], - 'type-enum': [ - 2, - 'always', - [ - 'build', - 'chore', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test', - 'translation', - 'security', - 'changeset', - ], - ], - }, -}; \ No newline at end of file + extends: ['@commitlint/config-conventional'], + rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 100], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 100], + 'header-max-length': [2, 'always', 100], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-case': [ + 2, + 'never', + ['sentence-case', 'start-case', 'pascal-case', 'upper-case'] + ], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'type-enum': [ + 2, + 'always', + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + 'translation', + 'security', + 'changeset' + ] + ] + } +} diff --git a/components/blur-image.tsx b/components/blur-image.tsx index f37ced1..0c42278 100644 --- a/components/blur-image.tsx +++ b/components/blur-image.tsx @@ -1,24 +1,24 @@ -"use client"; +'use client'; -import cn from "clsx"; -import Image from "next/image"; -import { useState } from "react"; +import cn from 'clsx'; +import Image from 'next/image'; +import { useState } from 'react'; -import type { ComponentProps } from "react"; +import type { ComponentProps } from 'react'; export default function BlurImage(props: ComponentProps) { - const [isLoading, setLoading] = useState(true); + const [isLoading, setLoading] = useState(true); - return ( - {props.alt} setLoading(false)} - /> - ); + return ( + {props.alt} setLoading(false)} + /> + ); } diff --git a/components/common/Footer.tsx b/components/common/Footer.tsx index 3e0506f..2919dbb 100644 --- a/components/common/Footer.tsx +++ b/components/common/Footer.tsx @@ -1,20 +1,22 @@ -import Link from "next/link"; -import { TypographyP } from "./Typography"; +import Link from 'next/link'; +import { TypographyP } from './Typography'; export default function Footer() { - return ( -
-
- Made with 💚 by - - Abhishek Kushwaha - -
-
- ); + return ( +
+
+ Made with 💚 by + + Abhishek Kushwaha + +
+
+ ); } diff --git a/components/common/NavBar.tsx b/components/common/NavBar.tsx index 9ef855d..18b0f60 100644 --- a/components/common/NavBar.tsx +++ b/components/common/NavBar.tsx @@ -1,138 +1,136 @@ -"use client" +'use client'; -import { APP_DASHBOARD_LINK, APP_NAME } from '@/lib/contants' -import { UserButton } from '@clerk/nextjs' -import { Dialog } from '@headlessui/react' -import { X as CrossIcon, MenuIcon } from 'lucide-react' -import Link from 'next/link' -import { useState } from 'react' -import { Button } from '../ui/button' -import { ThemeModeToggle } from './ThemeToggler' -import { TypographyLarge } from './Typography' +import { APP_DASHBOARD_LINK, APP_NAME } from '@/lib/contants'; +import { UserButton } from '@clerk/nextjs'; +import { Dialog } from '@headlessui/react'; +import { X as CrossIcon, MenuIcon } from 'lucide-react'; +import Link from 'next/link'; +import { useState } from 'react'; +import { Button } from '../ui/button'; +import { ThemeModeToggle } from './ThemeToggler'; +import { TypographyLarge } from './Typography'; -import { ScrollArea } from "@/components/ui/scroll-area" +import { ScrollArea } from '@/components/ui/scroll-area'; import { - Sheet, - SheetContent, - SheetHeader, - SheetTitle, - SheetTrigger -} from "@/components/ui/sheet" + Sheet, + SheetContent, + SheetHeader, + SheetTitle, + SheetTrigger, +} from '@/components/ui/sheet'; -const navigation = [ - { name: 'Dashboard', href: '/dashboard' }, -] +const navigation = [{ name: 'Dashboard', href: '/dashboard' }]; function NavBar() { - const [mobileMenuOpen, setMobileMenuOpen] = useState(false) - return ( -
- + +
+ +
+ +
+
+
+
+ {navigation.map((item) => ( + + {item.name} + + ))} +
+
+
+
+ + +
+
+
+
+ ); } -export default NavBar - - - +export default NavBar; diff --git a/components/common/NavbarMenu.tsx b/components/common/NavbarMenu.tsx index c2a5efd..fb3de26 100644 --- a/components/common/NavbarMenu.tsx +++ b/components/common/NavbarMenu.tsx @@ -1,48 +1,48 @@ -"use client" +'use client'; import { - NavigationMenu, - NavigationMenuContent, - NavigationMenuItem, - NavigationMenuLink, - NavigationMenuList, - NavigationMenuTrigger -} from "@/components/ui/navigation-menu" -import { APP_DESC, APP_NAME } from "@/lib/contants" -import { cn } from "@/lib/utils" -import Image from "next/image" -import * as React from "react" + NavigationMenu, + NavigationMenuContent, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, +} from '@/components/ui/navigation-menu'; +import { APP_DESC, APP_NAME } from '@/lib/contants'; +import { cn } from '@/lib/utils'; +import Image from 'next/image'; +import * as React from 'react'; export function NavBarMenu() { - return ( - - - - Getting started - -
    -
  • - - - bash school logo -
    - {APP_NAME} -
    -

    - {APP_DESC} -

    -
    -
    -
  • - {/* + return ( + + + + Getting started + +
      +
    • + + + bash school logo +
      + {APP_NAME} +
      +

      + {APP_DESC} +

      +
      +
      +
    • + {/* Explore a wide range of courses tailored to your interests and goals. @@ -51,13 +51,13 @@ export function NavBarMenu() { Learn more about Bash School and our mission to make coding accessible to everyone. */} -
    -
    -
    - - Pricing - - {/*
      +
    +
    +
    + + Pricing + + {/*
      {Courses.map((course) => ( ))}
    */} -
    -
    - {/* + + + {/* Blogs */} -
    -
    - ) + + + ); } const ListItem = React.forwardRef< - React.ElementRef<"a">, - React.ComponentPropsWithoutRef<"a"> + React.ElementRef<'a'>, + React.ComponentPropsWithoutRef<'a'> >(({ className, title, children, ...props }, ref) => { - return ( -
  • - - -
    {title}
    -

    - {children} -

    -
    -
    -
  • - ) -}) -ListItem.displayName = "ListItem" + return ( +
  • + + +
    {title}
    +

    + {children} +

    +
    +
    +
  • + ); +}); +ListItem.displayName = 'ListItem'; diff --git a/components/common/ThemeToggler.tsx b/components/common/ThemeToggler.tsx index 26b0f85..04fd70e 100644 --- a/components/common/ThemeToggler.tsx +++ b/components/common/ThemeToggler.tsx @@ -1,39 +1,39 @@ -"use client"; +'use client'; -import { MoonIcon, SunIcon } from "@radix-ui/react-icons"; -import { useTheme } from "next-themes"; +import { MoonIcon, SunIcon } from '@radix-ui/react-icons'; +import { useTheme } from 'next-themes'; -import { Button } from "@/components/ui/button"; +import { Button } from '@/components/ui/button'; import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu'; export function ThemeModeToggle() { - const { setTheme } = useTheme() + const { setTheme } = useTheme(); - return ( - - - - - - setTheme("light")}> - Light - - setTheme("dark")}> - Dark - - setTheme("system")}> - System - - - - ) + return ( + + + + + + setTheme('light')}> + Light + + setTheme('dark')}> + Dark + + setTheme('system')}> + System + + + + ); } diff --git a/components/common/Typography.tsx b/components/common/Typography.tsx index c54e751..5ebcc78 100644 --- a/components/common/Typography.tsx +++ b/components/common/Typography.tsx @@ -1,152 +1,139 @@ - - -export function TypographyH1({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyH1({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -

    - {children} -

    - ) + return ( +

    + {children} +

    + ); } - -export function TypographyH2({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyH2({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -

    - {children} -

    - ) + return ( +

    + {children} +

    + ); } - -export function TypographyH3({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyH3({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -

    - {children} -

    - ) + return ( +

    + {children} +

    + ); } - -export function TypographyH4({ children }: { - children: React.ReactNode -}) { - return ( -

    - {children} -

    - ) +export function TypographyH4({ children }: { children: React.ReactNode }) { + return ( +

    + {children} +

    + ); } - -export function TypographyP({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyP({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -

    - {children} -

    - ) + return

    {children}

    ; } - -export function TypographyBlockquote({ children }: { - children: React.ReactNode +export function TypographyBlockquote({ + children, +}: { + children: React.ReactNode; }) { - return ( -
    - {children} -
    - ) + return ( +
    {children}
    + ); } - -export function TypographyInlineCode({ children }: { - children: React.ReactNode +export function TypographyInlineCode({ + children, +}: { + children: React.ReactNode; }) { - return ( - - {children} - - ) + return ( + + {children} + + ); } -export function TypographyLead({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyLead({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -

    - {children} -

    - ) + return ( +

    {children}

    + ); } - -export function TypographyLarge({ children, className }: { - children: React.ReactNode, - className?: string +export function TypographyLarge({ + children, + className, +}: { + children: React.ReactNode; + className?: string; }) { - return ( -
    - {children} -
    - ) + return
    {children}
    ; } - - -export function TypographySmall({ children }: { - children: React.ReactNode -}) { - return ( - - {children} - - ) +export function TypographySmall({ children }: { children: React.ReactNode }) { + return {children}; } - -export function TypographyMuted({ children }: { - children: React.ReactNode -}) { - return ( -

    - {children} -

    - ) +export function TypographyMuted({ children }: { children: React.ReactNode }) { + return

    {children}

    ; } - -export function TypographyList({ children, liststyle }: { - children: React.ReactNode, - liststyle?: string +export function TypographyList({ + children, + liststyle, +}: { + children: React.ReactNode; + liststyle?: string; }) { - return ( -
      li]:mt-2`}> - {children} -
    - ) + return ( +
      li]:mt-2`}> + {children} +
    + ); } - - -export function TypographyListItem({ children }: { - children: React.ReactNode +export function TypographyListItem({ + children, +}: { + children: React.ReactNode; }) { - return ( -
  • {children}
  • - ) + return
  • {children}
  • ; } - diff --git a/components/dashboard/AlertCard.tsx b/components/dashboard/AlertCard.tsx index 3ab502b..38f049e 100644 --- a/components/dashboard/AlertCard.tsx +++ b/components/dashboard/AlertCard.tsx @@ -1,28 +1,19 @@ -import { - Alert, - AlertDescription, - AlertTitle, -} from "@/components/ui/alert"; -import { User } from "@clerk/nextjs/server"; -import { AlertCircle } from "lucide-react"; - - - +import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; +import { User } from '@clerk/nextjs/server'; +import { AlertCircle } from 'lucide-react'; function AlertCard({ user }: { user: User }) { - return ( -
    -
    - - - You are in 🚀 {user?.username} - - Thanks for joining waitlist!! - - -
    -
    - ) + return ( +
    +
    + + + You are in 🚀 {user?.username} + Thanks for joining waitlist!! + +
    +
    + ); } -export default AlertCard \ No newline at end of file +export default AlertCard; diff --git a/components/dashboard/DashBoardSideNavBar.tsx b/components/dashboard/DashBoardSideNavBar.tsx index 8e4ed4c..c8f8e59 100644 --- a/components/dashboard/DashBoardSideNavBar.tsx +++ b/components/dashboard/DashBoardSideNavBar.tsx @@ -1,209 +1,221 @@ 'use client'; - -import { Button } from "@/components/ui/button"; +import { Button } from '@/components/ui/button'; import { - Sheet, - SheetContent, - SheetHeader, - SheetTitle, - SheetTrigger -} from "@/components/ui/sheet"; -import { ArrowLeft, BarChart3, Boxes, CircleUser, Edit3, LayoutDashboard, MenuIcon, Newspaper, PartyPopper, Rss, Settings, Settings2, SettingsIcon, UserCircle } from "lucide-react"; -import Link from "next/link"; - -import { ScrollArea } from "@/components/ui/scroll-area"; -import { getSiteFromPostId } from "@/lib/actions"; -import { APP_NAME } from "@/lib/contants"; -import { useParams, useSelectedLayoutSegments } from "next/navigation"; -import { useEffect, useMemo, useState } from "react"; -import { TypographyLarge } from "../common/Typography"; + Sheet, + SheetContent, + SheetHeader, + SheetTitle, + SheetTrigger, +} from '@/components/ui/sheet'; +import { + ArrowLeft, + BarChart3, + Boxes, + CircleUser, + Edit3, + LayoutDashboard, + MenuIcon, + Newspaper, + PartyPopper, + Rss, + Settings, + Settings2, + SettingsIcon, + UserCircle, +} from 'lucide-react'; +import Link from 'next/link'; + +import { ScrollArea } from '@/components/ui/scroll-area'; +import { getSiteFromPostId } from '@/lib/actions'; +import { APP_NAME } from '@/lib/contants'; +import { useParams, useSelectedLayoutSegments } from 'next/navigation'; +import { useEffect, useMemo, useState } from 'react'; +import { TypographyLarge } from '../common/Typography'; function SideNavBar() { - return ( - <> -
    + return ( + <> +
    + +
    +
    + + + + + + + + {APP_NAME} + + + +
    -
    -
    - - - - - - - - {APP_NAME} - - - -
    - -
    -
    -
    -
    -
    - - ) +
    + + + +
    + + ); } - - const NavBarOptions = () => { - const segments = useSelectedLayoutSegments(); - const { blogslug, slug } = useParams() as { blogslug?: string, slug?: string }; - const [siteId, setSiteId] = useState(); - useEffect(() => { - if (segments[2] === "blog" && blogslug) { - getSiteFromPostId(blogslug).then((slug) => { - setSiteId(slug); - }); - } - }, [segments, blogslug]); - console.log(segments) - - - const tabs = useMemo(() => { - if (segments[0] === "portfolio" && slug && segments[2] === "blog" && blogslug) { - return [ - { - name: "Back to All Post", - icon: , - Link: `/dashboard/portfolio/${slug}/blog`, - urlname: "dashboard" - }, - { - name: "Editor", - Link: `/dashboard/portfolio/${slug}/blog/${blogslug}`, - isActive: segments.length === 4, - icon: , - }, - { - name: "Settings", - Link: `/dashboard/portfolio/${slug}/blog/${blogslug}/settings`, - isActive: segments.includes("settings"), - icon: , - }, - - ] - } else if (segments[0] === "settings") { - // for only settings navs ....... - return [ - { - name: "Back to DashBoard", - icon: , - Link: "/dashboard", - urlname: "dashboard" - }, - { - name: "User Settings", - icon: , - Link: `/dashboard/settings`, - urlname: "settings", - isActive: segments.length === 1, - }, - ]; - } else if (segments[0] === "portfolio" && slug) { - - return [ - { - name: "Back to All Portfolio", - icon: , - Link: "/dashboard/portfolio", - urlname: "portfolio" - }, - { - name: "Overview", - icon: , - Link: `/dashboard/portfolio/${slug}`, - isActive: segments.length === 2, - }, - { - name: "Blogs", - icon: , - Link: `/dashboard/portfolio/${slug}/blog`, - isActive: segments.includes("blog"), - }, - { - name: "Analytics", - icon: , - Link: `/dashboard/portfolio/${slug}/analytics`, - urlname: "analytics", - isActive: segments.includes("analytics"), - }, - { - name: "Settings", - icon: , - Link: `/dashboard/portfolio/${slug}/settings`, - urlname: "settings", - isActive: segments.includes("settings"), - }, - ]; - } - // default one at root ......... - return [ - { - name: "Overview", - Link: "/dashboard", - urlname: "dashboard", - isActive: segments.length === 0, - icon: , - }, - { - name: "Portfolio", - Link: "/dashboard/portfolio", - urlname: "portfolio", - isActive: segments[0] === "portfolio", - icon: , - }, - { - name: "Explore", - Link: "/community", - urlname: "community", - isActive: segments[0] === "community", - icon: , - }, - { - name: "Give Feebback", - Link: "/dashboard/feedback", - urlname: "feedback", - isActive: segments[0] === "feedback", - icon: , - }, - { - name: "User Settings", - Link: "/dashboard/settings", - urlname: "settings", - isActive: segments[0] === "settings", - icon: , - }, - - ]; - }, [segments, slug, blogslug]) - - - - return ( -
    - { - tabs.map((nav, index) => ( - - - - )) - } -
    - ) -} + const segments = useSelectedLayoutSegments(); + const { blogslug, slug } = useParams() as { + blogslug?: string; + slug?: string; + }; + const [siteId, setSiteId] = useState(); + useEffect(() => { + if (segments[2] === 'blog' && blogslug) { + getSiteFromPostId(blogslug).then((slug) => { + setSiteId(slug); + }); + } + }, [segments, blogslug]); + console.log(segments); + + const tabs = useMemo(() => { + if ( + segments[0] === 'portfolio' && + slug && + segments[2] === 'blog' && + blogslug + ) { + return [ + { + name: 'Back to All Post', + icon: , + Link: `/dashboard/portfolio/${slug}/blog`, + urlname: 'dashboard', + }, + { + name: 'Editor', + Link: `/dashboard/portfolio/${slug}/blog/${blogslug}`, + isActive: segments.length === 4, + icon: , + }, + { + name: 'Settings', + Link: `/dashboard/portfolio/${slug}/blog/${blogslug}/settings`, + isActive: segments.includes('settings'), + icon: , + }, + ]; + } else if (segments[0] === 'settings') { + // for only settings navs ....... + return [ + { + name: 'Back to DashBoard', + icon: , + Link: '/dashboard', + urlname: 'dashboard', + }, + { + name: 'User Settings', + icon: , + Link: `/dashboard/settings`, + urlname: 'settings', + isActive: segments.length === 1, + }, + ]; + } else if (segments[0] === 'portfolio' && slug) { + return [ + { + name: 'Back to All Portfolio', + icon: , + Link: '/dashboard/portfolio', + urlname: 'portfolio', + }, + { + name: 'Overview', + icon: , + Link: `/dashboard/portfolio/${slug}`, + isActive: segments.length === 2, + }, + { + name: 'Blogs', + icon: , + Link: `/dashboard/portfolio/${slug}/blog`, + isActive: segments.includes('blog'), + }, + { + name: 'Analytics', + icon: , + Link: `/dashboard/portfolio/${slug}/analytics`, + urlname: 'analytics', + isActive: segments.includes('analytics'), + }, + { + name: 'Settings', + icon: , + Link: `/dashboard/portfolio/${slug}/settings`, + urlname: 'settings', + isActive: segments.includes('settings'), + }, + ]; + } + // default one at root ......... + return [ + { + name: 'Overview', + Link: '/dashboard', + urlname: 'dashboard', + isActive: segments.length === 0, + icon: , + }, + { + name: 'Portfolio', + Link: '/dashboard/portfolio', + urlname: 'portfolio', + isActive: segments[0] === 'portfolio', + icon: , + }, + { + name: 'Explore', + Link: '/community', + urlname: 'community', + isActive: segments[0] === 'community', + icon: , + }, + { + name: 'Give Feebback', + Link: '/dashboard/feedback', + urlname: 'feedback', + isActive: segments[0] === 'feedback', + icon: , + }, + { + name: 'User Settings', + Link: '/dashboard/settings', + urlname: 'settings', + isActive: segments[0] === 'settings', + icon: , + }, + ]; + }, [segments, slug, blogslug]); + + return ( +
    + {tabs.map((nav, index) => ( + + + + ))} +
    + ); +}; export default SideNavBar; diff --git a/components/dashboard/feedback/FeedbackForm.tsx b/components/dashboard/feedback/FeedbackForm.tsx index ce367cf..a32678a 100644 --- a/components/dashboard/feedback/FeedbackForm.tsx +++ b/components/dashboard/feedback/FeedbackForm.tsx @@ -1,86 +1,87 @@ -"use client" +'use client'; -import { TypographyMuted } from "@/components/common/Typography"; -import { Button } from "@/components/ui/button"; +import { TypographyMuted } from '@/components/common/Typography'; +import { Button } from '@/components/ui/button'; import { - Form, - FormControl, - FormField, - FormItem, - FormMessage -} from "@/components/ui/form"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { Textarea } from "@nextui-org/react"; + Form, + FormControl, + FormField, + FormItem, + FormMessage, +} from '@/components/ui/form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { Textarea } from '@nextui-org/react'; import axios from 'axios'; -import { useForm } from "react-hook-form"; -import { toast } from "sonner"; -import * as z from "zod"; - +import { useForm } from 'react-hook-form'; +import { toast } from 'sonner'; +import * as z from 'zod'; const formSchema = z.object({ - feedback: z.string().min(20, { - message: "feedback must be at least 20 characters.", - }), -}) + feedback: z.string().min(20, { + message: 'feedback must be at least 20 characters.', + }), +}); export default function FeedbackForm() { + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + feedback: '', + }, + }); - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - feedback: "", - }, - }) - - // 2. Define a submit handler. - async function onSubmit(values: z.infer) { - // Do something with the form values. - // ✅ This will be type-safe and validated. - await axios.post('/api/feedback', values) - .then(response => { - // console.log(response); - // Handle success - if (response.status === 200) { - form.reset() - toast.success("Feedback Submitted Successfully") - } + // 2. Define a submit handler. + async function onSubmit(values: z.infer) { + // Do something with the form values. + // ✅ This will be type-safe and validated. + await axios + .post('/api/feedback', values) + .then((response) => { + // console.log(response); + // Handle success + if (response.status === 200) { + form.reset(); + toast.success('Feedback Submitted Successfully'); + } + }) + .catch((error) => { + console.log(error); + // Handle error + toast.error('Something went wrong'); + }); + console.log(values); + } - }) - .catch(error => { - console.log(error); - // Handle error - toast.error("Something went wrong") - }); - console.log(values) - } - - return ( - - Your Feedback makes us meet your expectations 🧑‍💻⭐ - - ( - - -