Skip to content

Commit

Permalink
add inventory form
Browse files Browse the repository at this point in the history
  • Loading branch information
bodhisha committed Jun 12, 2020
1 parent 86af5a5 commit 01dc316
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 28 deletions.
146 changes: 146 additions & 0 deletions src/Components/Facility/AddInventoryForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { Button, Card, CardContent, InputLabel } from "@material-ui/core";
import CheckCircleOutlineIcon from '@material-ui/icons/CheckCircleOutline';
import moment from 'moment';
import React, { useCallback, useReducer, useState } from "react";
import { useDispatch } from "react-redux";
import { statusType, useAbortableEffect } from "../../Common/utils";
import { createTriageForm, getTriageDetails } from "../../Redux/actions";
import * as Notification from "../../Utils/Notifications.js";
import { DateInputField, TextInputField } from "../Common/HelperInputFields";
import { Loading } from "../Common/Loading";
import PageTitle from "../Common/PageTitle";
import { PatientStatsModel } from "./models";


const initForm: any = {
inventory_name: "",
inventory_description: "",
inventory_stock: "",
inventory_min_stock: "",
};

const initialState = {
form: { ...initForm },
errors: { ...initForm }
};

const triageFormReducer = (state = initialState, action: any) => {
switch (action.type) {
case "set_form": {
return {
...state,
form: action.form
};
}
case "set_error": {
return {
...state,
errors: action.errors
};
}
default:
return state;
}
};

const goBack = () => {
window.history.go(-1);
};

export const AddInventoryForm = () => {
const dispatchAction: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);



const handleSubmit = async (e: any) => {
e.preventDefault();
};

const handleChange = (e: any) => {
//handlechange
};


if (isLoading) {
return <Loading />;
}

return (<div>
<PageTitle title="Add Inventory" />
<div className="mt-4">
<Card>
<form onSubmit={e => handleSubmit(e)}>
<CardContent>
<div className="mt-2 grid gap-4 grid-cols-1 md:grid-cols-2">
<div>
<InputLabel id="inventory_name_label">Inventory Name</InputLabel>
<TextInputField
name="inventory_name"
variant="outlined"
margin="dense"
type="number"
value=""
onChange={handleChange}
errors=""
/>
</div>
<div>
<InputLabel id="inventory_description_label">Inventory Description</InputLabel>
<TextInputField
name="inventory_description"
variant="outlined"
margin="dense"
type="number"
value=""
onChange={handleChange}
errors=""
/>
</div>
<div>
<InputLabel id="available_stock_label">Available Stock</InputLabel>
<TextInputField
name="available_stock"
variant="outlined"
margin="dense"
type="number"
value=""
onChange={handleChange}
errors=""
/>
</div>
<div>
<InputLabel id="min_stock_label">Minimum Stock Required</InputLabel>
<TextInputField
name="min_stock"
variant="outlined"
margin="dense"
type="number"
value=""
onChange={handleChange}
errors=""
/>
</div>
</div>
<div className="flex justify-between mt-4">
<Button
color="default"
variant="contained"
type="button"
onClick={goBack}
>Cancel</Button>
<Button
color="primary"
variant="contained"
type="submit"
style={{ marginLeft: "auto" }}
startIcon={<CheckCircleOutlineIcon></CheckCircleOutlineIcon>}
onClick={e => handleSubmit(e)}
>Add Inventory</Button>
</div>
</CardContent>
</form>
</Card>
</div>
</div>);
};
11 changes: 11 additions & 0 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ export const FacilityHome = (props: any) => {
Add Triage
</Button>
</Grid>
<Grid item xs={12} className="w3-center">
<Button
fullWidth
variant="contained"
color="primary"
size="small"
onClick={() => navigate(`/facility/${facilityId}/inventory`)}
>
Inventory Management
</Button>
</Grid>
</Grid>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useState } from 'react'
import PageTitle from '../Common/PageTitle'
import AddInventory from './AddInventory';
import { Button } from "@material-ui/core";
import { navigate } from "hookrouter";


export default function InventoryList() {

Expand All @@ -16,15 +18,25 @@ export default function InventoryList() {
{id: "21", name: "jai", description: "Hey", stock: "100", minStock :"20"},
{id: "3", name: "will", description: "Hey", stock: "100", minStock :"20"},
{id: "4", name: "sss", description: "Hey", stock: "100", minStock :"20"},
{id: "5", name: "bodhi", description: "Hey", stock: "100", minStock :"20"},
{id: "6", name: "bodhi", description: "Hey", stock: "100", minStock :"20"},

]

return (
<div>
<PageTitle title="Inventory" hideBack={true} />
<div className="container mx-auto px-4 sm:px-8">
<div className="py-8">

<Button
variant="contained"
color="primary"
size="small"
// onClick={() => navigate(`/facility/${facilityId}/inventory/add`)}
onClick={() => navigate(`/facility/inventory/add`)}

>
Add Inventory
</Button>
<div className="my-2 flex sm:flex-row flex-col">
<div className="flex flex-row mb-1 sm:mb-0">
<div className="relative">
Expand Down Expand Up @@ -74,19 +86,19 @@ export default function InventoryList() {
<thead>
<tr>
<th
className="px-5 py-3 border-b-2 border-gray-200 bg-green-200 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
className="px-5 py-3 border-b-2 border-gray-200 bg-green-400 text-left text-xs font-semibold text-white uppercase tracking-wider">
Name
</th>
<th
className="px-5 py-3 border-b-2 border-gray-200 bg-green-200 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
className="px-5 py-3 border-b-2 border-gray-200 bg-green-400 text-left text-xs font-semibold text-white uppercase tracking-wider">
Description
</th>
<th
className="px-5 py-3 border-b-2 border-gray-200 bg-green-200 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
className="px-5 py-3 border-b-2 border-gray-200 bg-green-400 text-left text-xs font-semibold text-white uppercase tracking-wider">
Stock
</th>
<th
className="px-5 py-3 border-b-2 border-gray-200 bg-green-200 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
className="px-5 py-3 border-b-2 border-gray-200 bg-green-400 text-left text-xs font-semibold text-white uppercase tracking-wider">
Minimum Stock
</th>
</tr>
Expand Down Expand Up @@ -118,14 +130,6 @@ export default function InventoryList() {
{item.minStock}
</p>
</td>
{/* <td className="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<span
className="relative inline-block px-3 py-1 font-semibold text-green-900 leading-tight">
<span aria-hidden
className="absolute inset-0 bg-green-200 opacity-50 rounded-full"></span>
<span className="relative">Activo</span>
</span>
</td> */}
</tr>

</tbody>
Expand All @@ -138,11 +142,11 @@ export default function InventoryList() {
</span>
<div className="inline-flex mt-2 xs:mt-0">
<button
className="text-sm bg-green-300 hover:bg-green-400 text-gray-800 font-semibold py-2 px-4 rounded-l">
className="text-sm bg-green-400 hover:bg-green-500 text-white font-semibold py-2 px-4 rounded-l">
Prev
</button>
<button
className="text-sm bg-green-300 hover:bg-green-400 text-gray-800 font-semibold py-2 px-4 rounded-r">
className="text-sm bg-green-400 hover:bg-green-500 text-white font-semibold py-2 px-4 rounded-r">
Next
</button>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/Components/Facility/TriageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ export const TriageForm = (props: triageFormProps) => {
variant="outlined"
margin="dense"
type="number"
InputLabelProps={{ shrink: !!state.form.num_patients_visited }}
value={state.form.num_patients_visited}
value=""
onChange={handleChange}
errors={state.errors.num_patients_visited}
errors=""
/>
</div>
<div>
Expand Down
16 changes: 8 additions & 8 deletions src/Router/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import { TreatmentForm } from "../Components/Patient/TreatmentForm";
import ManageUsers from "../Components/Users/ManageUsers";
import { UserAdd } from "../Components/Users/UserAdd";
import AmbulanceOnboarding from "../Components/Ambulance/AmbulanceOnboarding";
import InventoryList from "../Components/Inventory/InventoryList";
import InventoryList from "../Components/Facility/InventoryList";
import {AddInventoryForm} from "../Components/Facility/AddInventoryForm"
const img =
"https://cdn.coronasafe.network/light-logo.svg";
const logoBlack =
Expand Down Expand Up @@ -117,9 +118,14 @@ const routes = {
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily-rounds/:id": ({ facilityId, patientId, consultationId, id }: any) => (
<DailyRoundListDetails facilityId={facilityId} patientId={patientId} consultationId={consultationId} id={id} />
),
"/inventory": () => <InventoryList />,
"/facility/:facilityId/inventory": ({ facilityId }: any) => (<InventoryList />),
"/facility/:facilityId/inventory/add": ({ facilityId }: any) => (<AddInventoryForm />),
"/facility/inventory/add": () => (<AddInventoryForm />),

};



let menus = [
{
title: "Facilities",
Expand All @@ -145,12 +151,6 @@ let menus = [
title: "Users",
link: "/users",
icon: "fas fa-user-friends"
},
{
title: "Inventory",
link:"/inventory",
icon: "fas fa-store"

}
];

Expand Down

0 comments on commit 01dc316

Please sign in to comment.