import React, {useState} from 'react' import Head from 'next/head' import Link from 'next/link' import Card from '~/components/card' import CategoryCard from '~/components/categoryCard' import styles from './style.module.css' Category.getInitialProps = async function({ctx: {axios, query: {slug}}}){ const {data: category} = await axios.get(`/api/categories/by-slug/${slug}`) console.log(category) if(!category) { const err = new Error("Not found") err.status = 404 throw err; } return {category} } export default function Category({category: {items, children, parent, ...category}}){ return ( <> {category.name}

{category.name}

{parent ? ( < Back to {parent.name} ) : ( < Back to all categories )}

{category.description}

{children.length > 0 &&
{children.map(childCategory => ( ))}
}
{items.length > 0 ? (
{items.map(item=> )}
) :

No items found

}
) }