-
Notifications
You must be signed in to change notification settings - Fork 1
build api manager room #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThienLy3ky
wants to merge
3
commits into
develop
Choose a base branch
from
feature/Managerrooms
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import * as React from "react"; | ||
| import Box from "@mui/material/Box"; | ||
| import Card from "@mui/material/Card"; | ||
| import CardActions from "@mui/material/CardActions"; | ||
| import CardContent from "@mui/material/CardContent"; | ||
| import Button from "@mui/material/Button"; | ||
| import Typography from "@mui/material/Typography"; | ||
|
|
||
| const bull = ( | ||
| <Box | ||
| component="span" | ||
| sx={{ display: "inline-block", mx: "2px", transform: "scale(0.8)" }} | ||
| > | ||
| • | ||
| </Box> | ||
| ); | ||
|
|
||
| export default function BasicCard(props) { | ||
| return ( | ||
| <Card sx={{ minWidth: 275 }}> | ||
| <CardContent> | ||
| <Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom> | ||
| {props.inTitle} | ||
| </Typography> | ||
| <Typography variant="h5" component="div"> | ||
| {props.title} | ||
| </Typography> | ||
| <Typography sx={{ mb: 1.5 }} color="text.secondary"> | ||
| {props.underTitle} | ||
| </Typography> | ||
| <Typography variant="body2" style={{ color: "black" }}> | ||
| {props.content} | ||
| <br />a benevolent smile | ||
| </Typography> | ||
| </CardContent> | ||
| <CardActions> | ||
| <Button size="small">{props.button}</Button> | ||
| </CardActions> | ||
| </Card> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import * as React from "react"; | ||
| import Button from "@mui/material/Button"; | ||
| import Snackbar from "@mui/material/Snackbar"; | ||
| import IconButton from "@mui/material/IconButton"; | ||
| import CloseIcon from "@mui/icons-material/Close"; | ||
|
|
||
| export default function SimpleSnackbar(props) { | ||
| const [open, setOpen] = React.useState(false); | ||
| React.useEffect(() => { | ||
| setOpen(props.open); | ||
| }, [props]); | ||
| const handleClose = () => { | ||
| setOpen(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <Snackbar | ||
| open={open} | ||
| autoHideDuration={6000} | ||
| onClose={handleClose} | ||
| message={props.text} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| export { default as Login } from "./login"; | ||
| export { default as Signup } from "./Signup"; | ||
| export { default as HostAdmin } from "./HostAdmin"; | ||
| export { default as ManagerRoom } from "./manager_room"; | ||
| export { default as ManagerAdmin } from "./ManagerAdmin"; | ||
| export { default as Dashboard } from "./Dashboard"; | ||
| export { default as Client } from "./Client"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| import * as React from "react"; | ||
| import Box from "@mui/material/Box"; | ||
| import Modal from "@mui/material/Modal"; | ||
| import Button from "@mui/material/Button"; | ||
| import TextField from "@mui/material/TextField"; | ||
| import MenuItem from "@mui/material/MenuItem"; | ||
| import { roomAPI } from "../../services/room.api"; | ||
| import SimpleSnackbar from "../../components/snackbars"; | ||
| const currencies = [ | ||
| { | ||
| value: "available", | ||
| label: "Available", | ||
| }, | ||
| { | ||
| value: "full", | ||
| label: "Full", | ||
| }, | ||
| { | ||
| value: "pending", | ||
| label: "Pending", | ||
| }, | ||
| { | ||
| value: "maintain", | ||
| label: "Maintain", | ||
| }, | ||
| ]; | ||
| const style = { | ||
| position: "absolute", | ||
| top: "50%", | ||
| left: "50%", | ||
| transform: "translate(-50%, -50%)", | ||
| width: 400, | ||
| bgcolor: "background.paper", | ||
| border: "2px solid #000", | ||
| boxShadow: 24, | ||
| pt: 2, | ||
| px: 4, | ||
| pb: 3, | ||
| }; | ||
|
|
||
| export default function CreateModal(props) { | ||
| const [open, setOpen] = React.useState(false); | ||
| const [snackOpen, setsnackOpen] = React.useState(false); | ||
| const [masage, setmasage] = React.useState(""); | ||
| const [name, setname] = React.useState(""); | ||
| const [address, setaddress] = React.useState(""); | ||
| const [capacity, setcapacity] = React.useState(0); | ||
| const [price, setprice] = React.useState(0); | ||
| const [lng, setlng] = React.useState(0); | ||
| const [lat, setlat] = React.useState(0); | ||
| const [status, setstatus] = React.useState("false"); | ||
| const [description, setdescription] = React.useState(""); | ||
| const [image, setimage] = React.useState(""); | ||
| const [rating, setrating] = React.useState(0); | ||
| React.useEffect(() => { | ||
| setOpen(props.show); | ||
| }, [props]); | ||
| const handleClose = () => { | ||
| setOpen(false); | ||
| }; | ||
| const CreateRoom = async () => { | ||
| if ( | ||
| name !== "" && | ||
| address !== "" && | ||
| lng && | ||
| lat && | ||
| status !== "" && | ||
| image !== "" && | ||
| rating | ||
| ) { | ||
| const newRoom = await roomAPI.create({ | ||
| name, | ||
| address, | ||
| capacity, | ||
| price, | ||
| status, | ||
| description, | ||
| image, | ||
| rating, | ||
| location: { lng, lat }, | ||
| is_active: true, | ||
| }); | ||
| setsnackOpen(true); | ||
| if (newRoom ? true : false) { | ||
| setmasage(" Create success"); | ||
| setOpen(!open); | ||
| window.location.reload(false); | ||
| } else { | ||
| setmasage("create fails"); | ||
| } | ||
| } else { | ||
| setsnackOpen(true); | ||
| setmasage(" Check data again"); | ||
| } | ||
| }; | ||
| return ( | ||
| <div> | ||
| <Modal | ||
| open={open} | ||
| onClose={props.onClose} | ||
| aria-labelledby="spring-modal-title" | ||
| aria-describedby="spring-modal-description" | ||
| > | ||
| <Box sx={{ ...style, width: "50%" }}> | ||
| <h2 id="parent-modal-title">Create Room </h2> | ||
| <TextField | ||
| className="col-12" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="Name" | ||
| onChange={(e) => { | ||
| setname(e.target.value); | ||
| }} | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="address" | ||
| onChange={(e) => { | ||
| setaddress(e.target.value); | ||
| }} | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| type="number" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="capacity" | ||
| onChange={(e) => { | ||
| setcapacity(parseInt(e.target.value)); | ||
| }} | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| type="number" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="price" | ||
| onChange={(e) => { | ||
| setprice(parseInt(e.target.value)); | ||
| }} | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| type="number" | ||
| onChange={(e) => { | ||
| setlng(parseInt(e.target.value)); | ||
| }} | ||
| style={{ width: "50%", marginTop: "10px" }} | ||
| label="Longtitude" | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| type="number" | ||
| onChange={(e) => { | ||
| setlat(parseInt(e.target.value)); | ||
| }} | ||
| style={{ width: "50%", marginTop: "10px" }} | ||
| label="Latitude" | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| onChange={(e) => { | ||
| setdescription(e.target.value); | ||
| }} | ||
| label="description" | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="image" | ||
| onChange={(e) => { | ||
| setimage(e.target.value); | ||
| }} | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| type="number" | ||
| onChange={(e) => { | ||
| setrating(parseInt(e.target.value)); | ||
| }} | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="rating" | ||
| variant="outlined" | ||
| /> | ||
| <TextField | ||
| className="col-12" | ||
| select | ||
| onChange={(e) => { | ||
| setstatus(e.target.value); | ||
| }} | ||
| style={{ width: "100%", marginTop: "10px" }} | ||
| label="Status" | ||
| variant="outlined" | ||
| > | ||
| {currencies.map((option) => ( | ||
| <MenuItem key={option.value} value={option.value}> | ||
| {option.label} | ||
| </MenuItem> | ||
| ))} | ||
| </TextField> | ||
| <Button onClick={CreateRoom}>Save</Button> | ||
| </Box> | ||
| </Modal> | ||
| <SimpleSnackbar open={snackOpen} text={masage} /> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.