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.
Made changes on my AddDrug component
- Loading branch information
1 parent
a449f66
commit bbbdcab
Showing
7 changed files
with
91 additions
and
256 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 |
---|---|---|
@@ -1,66 +1,65 @@ | ||
import React from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'styled-components' | ||
import styled from 'styled-components'; | ||
|
||
|
||
const AddMedicineForm = ({ id, value, handleMedChange, placeholder, children }) => { | ||
const AddMedicineForm = ({ id, value, handleMedChange, placeholder }) => { | ||
const inputRef = useRef(); | ||
|
||
useEffect(() => { | ||
inputRef.current.focus(); | ||
}, [value]) | ||
}, [value]); | ||
|
||
return ( | ||
<div> | ||
|
||
<StyleInput | ||
type={id === 'expirationDate' ? 'date' : 'text'} | ||
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.string.isRequired, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, // Accept string or number | ||
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 */ | ||
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; | ||
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 */ | ||
} | ||
`; | ||
/* 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
Oops, something went wrong.