Skip to content

Commit

Permalink
Refactor GlobalError component and add error handling to ProjectPage …
Browse files Browse the repository at this point in the history
…and VortexUi components
  • Loading branch information
hasanshahriar32 committed Oct 13, 2024
1 parent 4801c53 commit 19e7e5d
Show file tree
Hide file tree
Showing 7 changed files with 334 additions and 22 deletions.
File renamed without changes.
18 changes: 18 additions & 0 deletions app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client'

export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
return (
<html>
<body>
<h2>Something went wrong!</h2>
<button onClick={() => reset()}>Try again</button>
</body>
</html>
)
}
286 changes: 286 additions & 0 deletions app/not-found.tsx

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion components/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { EncodeDataAttributeCallback } from '@sanity/react-loader'
import Link from 'next/link'
import { Suspense } from 'react'

import { ProjectListItem } from '@/components/pages/home/ProjectListItem'
import AllProjects from '@/components/shared/allProjects'
Expand Down Expand Up @@ -52,7 +53,8 @@ export function HomePage({ data, data2, encodeDataAttribute }: HomePageProps) {
<TimelineShowcase />
<AllProjects data2={data2} />
<Gemini />
<GlobeView />
<Suspense><GlobeView /></Suspense>

</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion components/pages/project/ProjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function ProjectPage({ data, encodeDataAttribute }: ProjectPageProps) {
)}
</div>
<SocialShare />
<VortexUi />
<VortexUi url={data?.slug} />
<div className="absolute left-0 w-screen my-6 border-t" />
<DisqusLoader data={data} />
</div>
Expand Down
6 changes: 3 additions & 3 deletions components/pages/project/VortexUi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import React from 'react'

import { Vortex } from '@/components/ui/vortex'

export function VortexUi() {
export function VortexUi({url}: any) {
const router = useRouter()
const handleClick = () => {
const currentWindow = window.location.href
router.push(`${currentWindow}/gallery`)
// const currentWindow = window.location.href
router.push(`${url}/gallery`)
}
return (
<div className="w-[calc(100%-4rem)] mx-auto rounded-md h-[30rem] overflow-hidden">
Expand Down
40 changes: 23 additions & 17 deletions components/ui/card-hover-effect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CommentIcon } from '@sanity/icons'
import { CommentCount } from 'disqus-react'
import { AnimatePresence, motion } from 'framer-motion'
import Link from 'next/link'
import { useEffect,useState } from 'react'
import { Suspense, useEffect,useState } from 'react'

import ImageBox from '@/components/shared/ImageBox'
import {
Expand Down Expand Up @@ -75,7 +75,7 @@ export const HoverEffect = ({
>
{visibleItems?.map((item: any, idx: any) => (
<Link
href={`/blog/post/${item?.slug}`}
href={`/projects/${item?.slug}`}
key={item?._id}
className="group relative block h-full w-full p-2"
onMouseEnter={() => setHoveredIndex(idx)}
Expand Down Expand Up @@ -109,28 +109,34 @@ export const HoverEffect = ({
<CardTitle>{item?.title}</CardTitle>
<div className="-mt-5 flex items-center justify-end gap-2 font-mono text-xs text-slate-500">
<CommentIcon />
<CommentCount
shortname="hstu"
<Suspense fallback={<p>err..</p>}>
{isClient ? (
<CommentCount
shortname="ece21"
config={{
url: pageURL,
identifier: item?.slug,
title: item?.title,
}}
/>
/>): "loading"}
</Suspense>
</div>

<CardDescription>
{isClient ? (
<CustomPortableText
value={item?.overview as PortableTextBlock[]}
/>
) : (
<div className="space-y-2">
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-3/4" />
</div>
)}
</CardDescription>
<Suspense fallback={<Skeleton className="h-4 w-full" />}>
{isClient ? (
<CardDescription>
{isClient ? (
<CustomPortableText
value={item?.overview as PortableTextBlock[]}
/>
) : (
<div className="space-y-2">
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-3/4" />
</div>
)}
</CardDescription>): <Skeleton className="h-4 w-full" />}
</Suspense>
</Card>
</Link>
))}
Expand Down

0 comments on commit 19e7e5d

Please sign in to comment.