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 branch 'main' into farkhondeh-dev3
- Loading branch information
Showing
6 changed files
with
533 additions
and
88 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
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,60 @@ | ||
import { useEffect, useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'styled-components'; | ||
|
||
const EditMedicineForm = ({ id, value, handleInputChange, placeholder }) => { | ||
const inputRef = useRef(); | ||
|
||
useEffect(() => { | ||
if (inputRef.current) { | ||
inputRef.current.focus(); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<StyleInput | ||
type={ | ||
id === 'expirationDate' | ||
? 'date' | ||
: ['quantity', 'minAmount'].includes(id) | ||
? 'number' | ||
: 'text' | ||
} | ||
key={id} | ||
id={id} | ||
value={value || ''} | ||
onChange={handleInputChange} | ||
placeholder={placeholder} | ||
ref={inputRef} | ||
/> | ||
); | ||
}; | ||
|
||
EditMedicineForm.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, // Accept string or number | ||
handleInputChange: PropTypes.func, | ||
placeholder: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default EditMedicineForm; | ||
|
||
export const FormField = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
export const StyleInput = styled.input` | ||
width: 100%; | ||
padding: 0.375rem 0.75rem; | ||
border-radius: var(--border-radius); | ||
border: 1px solid var(--grey-300); | ||
color: black; | ||
height: 35px; | ||
text-transform: uppercase; | ||
/* 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.