Compare commits
No commits in common. "master" and "FRE-2-store-products-query" have entirely different histories.
master
...
FRE-2-stor
|
@ -6,7 +6,7 @@ import StoreSelect from './storeSelect';
|
|||
import ProductTable from './productTable';
|
||||
|
||||
interface CreateReservationProps {
|
||||
createReservation: Function
|
||||
// createReservation: Function
|
||||
}
|
||||
|
||||
const Form = styled.form`
|
||||
|
@ -30,7 +30,7 @@ const Button = styled.button`
|
|||
width: 200px;
|
||||
`;
|
||||
|
||||
const CreateReservation = React.memo(({ createReservation }: CreateReservationProps) => {
|
||||
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) => {
|
||||
|
@ -42,14 +42,7 @@ const CreateReservation = React.memo(({ createReservation }: CreateReservationPr
|
|||
|
||||
const onSubmit = React.useCallback((e) => {
|
||||
e.preventDefault();
|
||||
createReservation({
|
||||
variables: {
|
||||
reservationProducts: Object.keys(reservationProducts).map(productId => ({
|
||||
productId,
|
||||
quantity: reservationProducts[productId]
|
||||
}))
|
||||
}
|
||||
});
|
||||
|
||||
}, [reservationProducts]);
|
||||
|
||||
return (
|
||||
|
@ -62,8 +55,4 @@ const CreateReservation = React.memo(({ createReservation }: CreateReservationPr
|
|||
);
|
||||
});
|
||||
|
||||
|
||||
export default compose(
|
||||
graphql(mutations.createReservation, { name: 'createReservation' })
|
||||
)(CreateReservation);
|
||||
|
||||
export default CreateReservation;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
input ReservationProductInput {
|
||||
productId: ID
|
||||
quantity: Int
|
||||
}
|
||||
|
||||
mutation createReservation($reservationProducts: [ReservationProductInput]) {
|
||||
createReservation(input: { reservationProducts: $reservationProducts }) {
|
||||
date
|
||||
id
|
||||
}
|
||||
}
|
|
@ -60,9 +60,7 @@ const ProductTable = React.memo(({ onChangeQuantity, storeId }: ProductTableProp
|
|||
<Description>{description}</Description>
|
||||
</td>
|
||||
<PriceTd>€ {price.toFixed(2)}</PriceTd>
|
||||
<QuantityTd>
|
||||
<QuantitySelect id={id} onChange={onChangeQuantity} />
|
||||
</QuantityTd>
|
||||
|
||||
</Tr>
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue