Fakultas Ilmu Komputer UI

Commit 46543cbc authored by Nurul Srianda Putri's avatar Nurul Srianda Putri
Browse files

[REFACTOR] refactor dropdown to set employee data

parent fd81c5f7
Pipeline #72110 failed with stages
in 4 minutes and 49 seconds
......@@ -2,12 +2,14 @@ import {useState} from 'react'
import DropdownIcon from '../../assets/dropdown-icon.svg'
import DropdownArrow from '../../assets/dropdown.svg'
import {dataEmployee} from '../../data/employee'
import PropTypes from 'prop-types'
const EmployeeDropdown = () => {
const [selectedValue, setSelectedValue] = useState('')
const EmployeeDropdown = ({setEmployeeData}) => {
const [selectedValue, setSelectedValue] = useState(null)
const [showDropdown, setShowDropdown] = useState(false)
const selectValue = (value) => {
setEmployeeData(value)
setSelectedValue(value)
setShowDropdown(false)
}
......@@ -21,7 +23,7 @@ const EmployeeDropdown = () => {
<div className="flex flex-row items-center">
<img src={DropdownIcon} className="mr-3" />
<p className="reguler-text" data-testid="selected-value">
{selectedValue === '' ? 'Pilih salah satu' : selectedValue}
{selectedValue ? selectedValue : 'Pilih salah satu'}
</p>
</div>
<img src={DropdownArrow} />
......@@ -46,4 +48,8 @@ const EmployeeDropdown = () => {
)
}
EmployeeDropdown.propTypes = {
setEmployeeData: PropTypes.func,
}
export default EmployeeDropdown
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment