Skip to content

Commit

Permalink
Good stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
omkaark committed May 13, 2023
1 parent 6ee3c34 commit b3f2c34
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
// Define relative imports here
import Title from './components/Title';
import DisplayContainer from './components/DisplayContainer';
import CreateRestaurantPortal from './components/CreateRestaurantPortal';

/**
* This is the root component of your React App.
Expand All @@ -12,6 +13,7 @@ import DisplayContainer from './components/DisplayContainer';
const App = () => {
return (
<div className="App">
<CreateRestaurantPortal />
<Title teamName="your_team_name"></Title>
{window.location.pathname === "/" && <DisplayContainer />}
</div>
Expand Down
56 changes: 56 additions & 0 deletions frontend/src/components/CreateRestaurantPortal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* This is a functional stateless component. Its primary function is to display the props that were passed into it.
* It is stateless so it doesn't need to extend React.Component.
* However, `import React from 'react';` needs to be stated everywhere jsx is used.
* This component will not have access to React Component Lifecycles.
*/

import React, { useState } from 'react';
import PropTypes from 'prop-types';

import './CreateRestaurantPortal.scss';

const CreateRestaurantPortal = () => {
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [restaurantIds, setRestaurantIds] = useState([]);

const handleGroupNameChange = (e) => {
setName(e.target.value);
};

const handleGroupDescriptionChange = (e) => {
setDescription(e.target.value)
};

const handleGroupRestaurantIdsChange = (e) => {
setRestaurantIds(e.target.value)
};

const handleSubmit = async (name, description, restaurantIds) => {
// Implement later
}

return (
<div className="create-restaurant-portal">
<input placeholder="Enter restaurant name" value={name} onChange={(e) => handleGroupNameChange(e)} />
<input placeholder="Enter restaurant description" value={description} onChange={(e) => handleGroupDescriptionChange(e)} />
<input placeholder="Enter restaurant ids (list format ['a', 'b'])" value={restaurantIds} onChange={(e) => handleGroupRestaurantIdsChange(e)} />
<button onClick={() => handleSubmit(name, description, restaurantIds)}>Submit</button>
</div>
)
}

export default CreateRestaurantPortal;

CreateRestaurantPortal.propTypes = {
name: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
restaurantIds: PropTypes.array.isRequired
};

CreateRestaurantPortal.defaultProps = {
name: "",
description: "",
restaurantIds: []
};
4 changes: 4 additions & 0 deletions frontend/src/components/CreateRestaurantPortal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.create-restaurant-portal {
display: flex;
flex-direction: column;
}

0 comments on commit b3f2c34

Please sign in to comment.