generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from moevm/koroleva/filtration
Add warehouses page, cell page, addition component
- Loading branch information
Showing
13 changed files
with
443 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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,70 @@ | ||
import { useState } from "react"; | ||
import { Button, Form, InputGroup, Modal } from "react-bootstrap"; | ||
|
||
export default function Addition<Type>(props: { handleSend: any, obj: any }) { | ||
const [state, setState] = useState(props.obj); | ||
const [show, setShow] = useState(false); | ||
|
||
function handleShow() { | ||
setShow(true); | ||
} | ||
|
||
function handleClose() { | ||
setShow(false); | ||
} | ||
|
||
function handleSubmit(e: React.ChangeEvent<HTMLFormElement>) { | ||
e.preventDefault(); | ||
const formData = new FormData(e.target); | ||
const formDataObj = Object.fromEntries(formData.entries()); | ||
props.handleSend(formDataObj); | ||
setShow(false); | ||
|
||
} | ||
const data = [] | ||
for (let key in props.obj) { | ||
data.push( | ||
<InputGroup className="mb-3"> | ||
<InputGroup.Text id="basic-addon1">{props.obj[key].name}</InputGroup.Text> | ||
{props.obj[key].type == "b" && <InputGroup.Checkbox name={key} />} | ||
{ | ||
props.obj[key].type == "s" && <Form.Control | ||
placeholder={props.obj[key].name} name={key} | ||
/> | ||
} | ||
{ | ||
props.obj[key].type == "d" && <Form.Control | ||
placeholder={props.obj[key].name} name={key} | ||
/> | ||
} | ||
|
||
</InputGroup> | ||
) | ||
|
||
} | ||
return ( | ||
<> | ||
<Button onClick={handleShow}>Добавить элемент</Button> | ||
<Modal show={show} onHide={handleClose}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Добавление нового элемента</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form onSubmit={handleSubmit}> | ||
{data} | ||
<Button type="submit"> | ||
Добавить | ||
</Button> | ||
|
||
</Form> | ||
</Modal.Body> | ||
</Modal> | ||
</> | ||
) | ||
|
||
} | ||
|
||
// { | ||
// data: "Дата", | ||
// FIO: "Фамилия Имя Отчество" | ||
// } |
This file contains 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 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,35 @@ | ||
import { useState } from "react"; | ||
import { Form, InputGroup } from "react-bootstrap"; | ||
|
||
export default function Filter<Type>(props: { handleSend: any, obj: any }) { | ||
const [state, setState] = useState(props.obj); | ||
const filters = [] | ||
for (let key in props.obj) { | ||
filters.push( | ||
<> | ||
<InputGroup.Text id="basic-addon1">{props.obj[key].name}</InputGroup.Text> | ||
{props.obj[key].type == "b" && <InputGroup.Checkbox/>} | ||
{props.obj[key].type == "s" && <Form.Control | ||
placeholder={props.obj[key].name} | ||
/>} | ||
{props.obj[key].type == "d" && <Form.Control | ||
placeholder={props.obj[key].name} | ||
/>} | ||
|
||
</> | ||
) | ||
|
||
} | ||
return (<> | ||
<InputGroup className="mb-3"> | ||
{filters} | ||
</InputGroup> | ||
|
||
</>) | ||
|
||
} | ||
|
||
// { | ||
// data: "Дата", | ||
// FIO: "Фамилия Имя Отчество" | ||
// } |
This file contains 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 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 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
Oops, something went wrong.