Skip to content

Commit

Permalink
added planner role
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandan Saurav Panda committed Feb 18, 2024
1 parent 1d176ac commit 163f770
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 1,381 deletions.
7 changes: 6 additions & 1 deletion frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
display: flex;
flex-direction: row;
justify-content: space-between;
width: 20%;
width: 60%;
margin-top: 100px;
}

.table {
width: 60%;
margin-top: 10px;
}
49 changes: 45 additions & 4 deletions frontend/src/components/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ import axios from 'axios';

const Alert = () => {

const [msg, setMsg] = useState("");
// const [msg, setMsg] = useState("");
const [product_id, setProduct] = useState("");
const [plant_id, setPlant] = useState("");
const [validTo, setValidTo] = useState("");

let onClick = () => {
let onListing = () => {
// alert('You clicked'+ msg);
// Validation
if (!product_id || !plant_id || !validTo) {
alert('Fill all mandatory fields');
return;
}

console.log("ValidTo",new Date(validTo).toISOString());
//Get the csrfToken from Approuter
axios.get("/api/ProductPlant_Listing",
{
Expand All @@ -21,6 +30,20 @@ const Alert = () => {
}).then((response) => {
let csrfToken = response.headers['x-csrf-token'];
//Call POST with received csrfToken
axios.post( "/api/productListing",
{
"productPlant": {
"product_id" : product_id,
"plant_id": plant_id,
"validTo": new Date(validTo).toISOString()
}
}, {
headers: {
'X-CSRF-Token': csrfToken
}
}
).catch((error) => {console.log(error);});
//Call POST with received csrfToken
axios.post( "/api/triggerNotification",
{ }, {
headers: {
Expand All @@ -40,14 +63,32 @@ return(
autoComplete="off"
>
<div class="flex-container" >
<TextField
{/* <TextField
required
id="outlined-required"
label="Alert Message"
defaultValue="Sample Alert Body"
value={msg} onChange={(e) => setMsg(e.target.value)}
/> */}
<TextField
required
id="Product_ID"
label="Product ID"
value={product_id} onChange={(e) => setProduct(e.target.value)}
/>
<TextField
required
id="Plant_ID"
label="Plant ID"
value={plant_id} onChange={(e) => setPlant(e.target.value)}
/>
<TextField
required
id="ValidTo"
label="ValidTo(YYYY-MM-DD)"
value={validTo} onChange={(e) => setValidTo(e.target.value)}
/>
<Button title="Send Notification" variant="contained" onClick={onClick}>Send</Button>
<Button title="Run Listing" variant="contained" onClick={onListing}>Run Listing</Button>
</div>
</Box>
)
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/ProdPlantTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,29 @@ const ProdPlantTable = () => {
},[]);

return(

<TableContainer component={Paper}>
<TableContainer component={Paper} class="table">
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Product</TableCell>
<TableCell>Plant</TableCell>
<TableCell>Valid From</TableCell>
<TableCell>Valid To</TableCell>
<TableCell align="right">isListed</TableCell>
</TableRow>
</TableHead>
<TableBody>
{data.map((line) => (
<TableRow
key={`${line.product_id}-${line.plant_id}`}
key={`${line.product_id}-${line.plant_id}-${line.validFrom}`}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
>
<TableCell component="th" scope="line">
{line.product_id}
</TableCell>
<TableCell>{line.plant_id}</TableCell>
<TableCell>{line.validFrom}</TableCell>
<TableCell>{line.validTo}</TableCell>
<TableCell align="right">{line.isListed? "Yes": "No"}</TableCell>
</TableRow>
))}
Expand Down
Loading

0 comments on commit 163f770

Please sign in to comment.