import React, {useState} from 'react'
import router from 'next/router'
import Link from 'next/link'
import axios from 'axios'
import {Button} from '@rmwc/button'
import ActionBar from '~/components/admin/actionBar'
import Table from '~/components/table'
CategoryList.getInitialProps = async ({ctx}) => {
const {data: categories} = await ctx.axios.get('/api/categories')
return {categories}
}
export default function CategoryList({categories: _categories}) {
const [categories, setCategories] = useState(_categories)
const remove = uuid => async ev => {
if(ev) ev.preventDefault()
const {data: categories} = await axios.delete(`/api/categories/${uuid}`)
setCategories(categories)
}
return (
<>