|
|
|
@ -4,7 +4,7 @@ import Router from 'next/router'
|
|
|
|
|
import {FormController, IntegerInput, Button} from '~/components/form'
|
|
|
|
|
import isNum from 'validator/lib/isNumeric'
|
|
|
|
|
|
|
|
|
|
import useCart from '~/hooks/useCart'
|
|
|
|
|
import useCart, {useSetCart} from '~/hooks/useCart'
|
|
|
|
|
import styles from './style.module.css'
|
|
|
|
|
|
|
|
|
|
Item.getInitialProps = async function({ctx: {axios, query: {slug}}}){
|
|
|
|
@ -21,7 +21,8 @@ Item.getInitialProps = async function({ctx: {axios, query: {slug}}}){
|
|
|
|
|
|
|
|
|
|
// TODO: Modal with full image size on clicking preview
|
|
|
|
|
export default function Item({item}){
|
|
|
|
|
const [cart, setCart] = useCart()
|
|
|
|
|
const cart = useCart()
|
|
|
|
|
const setCart = useSetCart()
|
|
|
|
|
// Pick first one with featured flag or 0
|
|
|
|
|
const featuredIndex = item.images.reduce((p, im, i) => ((p !== undefined) ? p : (im.featured ? i : undefined)), undefined) || 0
|
|
|
|
|
const [selectedIndex, setSelected] = useState(featuredIndex);
|
|
|
|
|