generated from Code-the-Dream-School/react-node-practicum-front-template
-
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 #21 from Code-the-Dream-School/6-implement-addedit…
…-drug-modal Implemented Add Drug Modal
- Loading branch information
Showing
7 changed files
with
3,415 additions
and
129 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
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 }) => { | ||
const inputRef = useRef(); | ||
|
||
useEffect(() => { | ||
inputRef.current.focus(); | ||
}, [value]); | ||
|
||
return ( | ||
<div> | ||
<StyleInput | ||
type={ | ||
id === 'expirationDate' | ||
? 'date' | ||
: ['quantity', 'minAmount', 'lotNumber', 'ndcNumber'].includes(id) | ||
? 'number' | ||
: '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.oneOfType([PropTypes.string, PropTypes.number]).isRequired, // Accept string or number | ||
handleMedChange: PropTypes.func.isRequired, | ||
placeholder: PropTypes.string.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 */ | ||
} | ||
`; |
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 |
---|---|---|
|
@@ -73,6 +73,10 @@ body { | |
line-height: 1; | ||
} | ||
|
||
body.active-modal { | ||
overflow: hidden; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
|
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.