Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
  • Loading branch information
xvpc committed Sep 16, 2023
1 parent a6f6aa3 commit 885a0ad
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 51 deletions.
6 changes: 3 additions & 3 deletions components/sections/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Introduction({ title, country, image, home }: Introducti
className={`order-1 rounded overflow-hidden shadow ${matchSm ? "w-25" : ""} m-auto`}
initial={{y: "100vh", opacity: 0}}
animate={{y: 0, opacity: 1}}
transition={{duration: 0.6}}
transition={{duration: 1.1, delay: 1.9}}
>
{
home ?
Expand All @@ -55,15 +55,15 @@ export default function Introduction({ title, country, image, home }: Introducti
className='fw-bold text-primary-emphasis'
initial={{y: "100vh", opacity: 0}}
animate={{y: 0, opacity: 1}}
transition={{duration: 0.8, delay: 0.7}}
transition={{duration: 0.6}}
>
{title || "Quick Recipes"}
</motion.h1>
<motion.p
className='ps-0 ps-sm-2 fw-normal text-secondary text-truncate text-wrap fs-5 w-100'
initial={{opacity: 0}}
animate={{opacity: 1}}
transition={{duration: 1.8, delay: 1.5}}
transition={{duration: 1, delay: 0.8}}
>
{country || `Search for Recipes and Learn A lot of Cool Meals,
and Share them with others.`}
Expand Down
103 changes: 55 additions & 48 deletions pages/recipes/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@ import Info from '@/components/pages/Info'
// Lib
import getInfo from '@/lib/getInfo'

function InfoPage({ router }: { router : any}) {
export default function InfoPage({ data }: { data : any}) {
// const router = useRouter();
const [data, setData] = useState<any>(null)
// const [data, setData] = useState<any>(null)

const id = router.query?.id || null;
// const id = router.query?.id || null;

// TODO: Fix this shit
useEffect(() => {
if(id){
(async() => {
try{
const data = await getInfo({id: String(id)})
// // TODO: Fix this shit
// useEffect(() => {
// if(id){
// (async() => {
// try{
// const data = await getInfo({id: String(id)})

if(data?.error){
console.log(`Error message => ${data?.error}`)
// if(data?.error){
// console.log(`Error message => ${data?.error}`)

// router.push('/404')
}else{
setData(data)
}
}catch(err: any){
console.log(`Error from useEffect ${err.message}`)
// // router.push('/404')
// }else{
// setData(data)
// }
// }catch(err: any){
// console.log(`Error from useEffect ${err.message}`)

router.push('/')
}
})()
}
}, [])
// router.push('/')
// }
// })()
// }
// }, [])

return (
<Layout title=''>
Expand All @@ -47,7 +47,7 @@ function InfoPage({ router }: { router : any}) {
)
}

export default withRouter(InfoPage)
// export default withRouter(InfoPage)

// export async function getStaticPaths(){
// return{
Expand All @@ -56,32 +56,39 @@ export default withRouter(InfoPage)
// }
// }

// export async function getServerSideProps(context: GetServerSidePropsContext){
// const id = context.params?.id as string;
export async function getServerSideProps({ params: { id } }: { params: { id: string } }){
// const id = context.params?.id as string;

// //
// try{
// const data = await getInfo({id: id})
// if(data?.error){
// console.log(`Error message => ${data?.error}`)
//
if(id){
try{
const data = await getInfo({id: id})
if(data?.error){
console.log(`Error message => ${data?.error}`)

// return {
// notFound: true
// };
// }else{
// // console.log(data)
return {
notFound: true
};
}else{
// console.log(data)

// return {
// props: {
// data: data // Returns first meal (Object)
// }
// };
// }
// }catch(err: any){
// console.log(`Error from getStaticProps ${err.message}`)
return {
props: {
data: data // Returns first meal (Object)
}
};
}
}catch(err: any){
console.log(`Error from getStaticProps ${err.message}`)

// return {
// notFound: true
// };
// }
// }
return {
notFound: true
};
}
}else{
console.log("Something went wrong when getting the id")
return{
notFound: true
}
}
}

0 comments on commit 885a0ad

Please sign in to comment.