2019-02-10 15:01:18 +00:00
|
|
|
import React from 'react';
|
2019-02-11 18:56:58 +00:00
|
|
|
import { compose, graphql } from 'react-apollo';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
import mutations from './mutations.graphql';
|
|
|
|
import StoreSelect from './storeSelect';
|
|
|
|
import ProductTable from './productTable';
|
2019-02-10 15:01:18 +00:00
|
|
|
|
|
|
|
interface CreateReservationProps {
|
2019-02-11 18:56:58 +00:00
|
|
|
// createReservation: Function
|
2019-02-10 15:01:18 +00:00
|
|
|
}
|
|
|
|
|
2019-02-11 18:56:58 +00:00
|
|
|
const Form = styled.form`
|
|
|
|
width: 800px;
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
margin-top: 4em;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const H1 = styled.h1`
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Button = styled.button`
|
|
|
|
background: none;
|
|
|
|
border-radius: 4px;
|
|
|
|
color: #ffffff;
|
|
|
|
cursor: pointer;
|
|
|
|
font-size: 20px;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-bottom: 8px;
|
|
|
|
width: 200px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const CreateReservation = React.memo(({ /* createReservation */ }: CreateReservationProps) => {
|
|
|
|
const [reservationProducts, setReservationProducts] = React.useState<{ [key: string]: number }>({});
|
|
|
|
const [storeId, setStoreId] = React.useState<string>('');
|
|
|
|
const onChangeQuantity = React.useCallback((productId: string, quantity: string) => {
|
|
|
|
setReservationProducts(rps => ({
|
|
|
|
...rps,
|
|
|
|
[productId]: parseInt(quantity, 10)
|
|
|
|
}));
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const onSubmit = React.useCallback((e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
}, [reservationProducts]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form onSubmit={onSubmit}>
|
|
|
|
<H1>Create reservation</H1>
|
|
|
|
<StoreSelect value={storeId} onChange={setStoreId} />
|
|
|
|
<ProductTable storeId={storeId} onChangeQuantity={onChangeQuantity} />
|
|
|
|
<Button type="submit">Reserve</Button>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
});
|
2019-02-10 15:01:18 +00:00
|
|
|
|
2019-02-11 18:56:58 +00:00
|
|
|
export default CreateReservation;
|