Skip to content

Commit

Permalink
Implemented Add Drug Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriGuerrero committed Dec 1, 2024
1 parent 0fda49d commit a449f66
Show file tree
Hide file tree
Showing 10 changed files with 3,585 additions and 134 deletions.
3,186 changes: 3,065 additions & 121 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
"preview": "vite preview"
},
"dependencies": {
"@chakra-ui/react": "^3.2.1",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"axios": "^1.6.7",
"framer-motion": "^6.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.10.0",
Expand Down
20 changes: 18 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import React, { useState, useEffect } from 'react';


import {
AddDrug,
AddEdit,
AdminAddUser,
Alerts,
Dashboard,
Expand All @@ -17,6 +20,7 @@ import {
HomeLayout,
} from './pages';


const router = createBrowserRouter([
{
path: '/',
Expand Down Expand Up @@ -52,7 +56,11 @@ const router = createBrowserRouter([
},
{
path: '/editdrug',
element: <EditDrug />,
element: <EditDrug />
},
{
path: '/AddEdit',
element: <AddEdit />
},
{
path: '/dispense',
Expand All @@ -76,7 +84,15 @@ const router = createBrowserRouter([
},
]);


const App = () => {
return <RouterProvider router={router} />;

return (
<>
<RouterProvider router={router} />

</>
);
};

export default App;
66 changes: 66 additions & 0 deletions src/components/AddMedicineForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components'


const AddMedicineForm = ({ id, value, handleMedChange, placeholder, children }) => {
const inputRef = useRef();

useEffect(() => {
inputRef.current.focus();
}, [value])

return (
<div>

<StyleInput
type={id === 'expirationDate' ? 'date' : 'text'}
key={id}
id={id}
value={value} // Directly use value passed as a prop
onChange={handleMedChange}
placeholder={placeholder}
ref={inputRef}
/>

</div>
)
}
/*
AddMedicineForm.propTypes = {
id: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
handleMedChange: PropTypes.func.isRequired,
placeholder: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
}
*/

export default AddMedicineForm;

export const FormField = styled.div`
display: flex;
flex-direction: column;
gap: 0.4rem; /* Adjust spacing between label and input */
`;


export const StyleInput = styled.input`
text-size: 1rem;
width: 100%;
border: 1.5px solid #000;
border-radius: 4px;
display: flex;
flex-direction: column;
align-items:flex-start;
padding: 1em;
margin: 0rem;
color: #000;
/* Placeholder text color */
&::placeholder {
color: black; /* Set placeholder text to black */
}
`;
4 changes: 4 additions & 0 deletions src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ body {
line-height: 1;
}

body.active-modal {
overflow: hidden;
}

h1,
h2,
h3,
Expand Down
2 changes: 2 additions & 0 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App.jsx';
import './global.css';


ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
Expand Down
Loading

0 comments on commit a449f66

Please sign in to comment.