|
| 1 | +/** |
| 2 | + * This is a functional stateless component. Its primary function is to display the props that were passed into it. |
| 3 | + * It is stateless so it doesn't need to extend React.Component. |
| 4 | + * However, `import React from 'react';` needs to be stated everywhere jsx is used. |
| 5 | + * This component will not have access to React Component Lifecycles. |
| 6 | + */ |
| 7 | + |
| 8 | +import React, { useState } from 'react'; |
| 9 | +import PropTypes from 'prop-types'; |
| 10 | + |
| 11 | +import './CreateRestaurantPortal.scss'; |
| 12 | + |
| 13 | +const CreateRestaurantPortal = () => { |
| 14 | + const [name, setName] = useState(""); |
| 15 | + const [description, setDescription] = useState(""); |
| 16 | + const [restaurantIds, setRestaurantIds] = useState([]); |
| 17 | + |
| 18 | + const handleGroupNameChange = (e) => { |
| 19 | + setName(e.target.value); |
| 20 | + }; |
| 21 | + |
| 22 | + const handleGroupDescriptionChange = (e) => { |
| 23 | + setDescription(e.target.value) |
| 24 | + }; |
| 25 | + |
| 26 | + const handleGroupRestaurantIdsChange = (e) => { |
| 27 | + setRestaurantIds(e.target.value) |
| 28 | + }; |
| 29 | + |
| 30 | + const handleSubmit = async (name, description, restaurantIds) => { |
| 31 | + // Implement later |
| 32 | + } |
| 33 | + |
| 34 | + return ( |
| 35 | + <div className="create-restaurant-portal"> |
| 36 | + <input placeholder="Enter restaurant name" value={name} onChange={(e) => handleGroupNameChange(e)} /> |
| 37 | + <input placeholder="Enter restaurant description" value={description} onChange={(e) => handleGroupDescriptionChange(e)} /> |
| 38 | + <input placeholder="Enter restaurant ids (list format ['a', 'b'])" value={restaurantIds} onChange={(e) => handleGroupRestaurantIdsChange(e)} /> |
| 39 | + <button onClick={() => handleSubmit(name, description, restaurantIds)}>Submit</button> |
| 40 | + </div> |
| 41 | + ) |
| 42 | +} |
| 43 | + |
| 44 | +export default CreateRestaurantPortal; |
| 45 | + |
| 46 | +CreateRestaurantPortal.propTypes = { |
| 47 | + name: PropTypes.string.isRequired, |
| 48 | + description: PropTypes.string.isRequired, |
| 49 | + restaurantIds: PropTypes.array.isRequired |
| 50 | +}; |
| 51 | + |
| 52 | +CreateRestaurantPortal.defaultProps = { |
| 53 | + name: "", |
| 54 | + description: "", |
| 55 | + restaurantIds: [] |
| 56 | +}; |
0 commit comments