-
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.
- Loading branch information
1 parent
66c82a4
commit 53f9657
Showing
3 changed files
with
107 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {useEffect, useState} from "react"; | ||
import callApi from "../../apis/GatewayApi.js"; | ||
import InputAutocomplete from "./core/InputAutocomplete.jsx"; | ||
import PropTypes from "prop-types"; | ||
import {Select, SelectItem} from "@nextui-org/react"; | ||
import {useController} from "react-hook-form"; | ||
|
||
const typeJoin = [ | ||
{key: "joinGame", label: "Join game"}, | ||
{key: "viewGame", label: "View game"}, | ||
]; | ||
|
||
const InputSelectTypeJoinGame = (props) => { | ||
const { | ||
field, | ||
fieldState: { invalid, isTouched, isDirty , error}, | ||
formState: { touchedFields, dirtyFields } | ||
} = useController({ | ||
name: props.name, | ||
control: props.control, | ||
rules: props.rules, | ||
}); | ||
|
||
console.log(field.value) | ||
|
||
const handleChangeValue = (value) => { | ||
field.onChange(value) | ||
} | ||
|
||
return <Select | ||
// react form hook | ||
onChange={handleChangeValue} | ||
onBlur={field.onBlur} | ||
ref={field.ref} | ||
|
||
// nextUI | ||
isInvalid={!!error} | ||
errorMessage={error?.message} | ||
|
||
size={'sm'} | ||
variant={'flat'} | ||
|
||
selectedKeys={[field.value]} | ||
> | ||
{typeJoin.map((type) => ( | ||
<SelectItem key={type.key}>{type.label}</SelectItem> | ||
))} | ||
</Select> | ||
|
||
} | ||
|
||
export default InputSelectTypeJoinGame; |
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