Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-jams
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-jams
Commits
c5030217
Commit
c5030217
authored
1 year ago
by
Léo Banno-Cloutier
Browse files
Options
Downloads
Patches
Plain Diff
jams-react-client: can now use CountrySelect
Change-Id: I8a0a6841d68480e1931e1e84e8d21915fd74d950
parent
15d57dc0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jams-react-client/src/components/CountrySelect/CountrySelect.js
+8
-14
8 additions, 14 deletions
...eact-client/src/components/CountrySelect/CountrySelect.js
with
8 additions
and
14 deletions
jams-react-client/src/components/CountrySelect/CountrySelect.js
+
8
−
14
View file @
c5030217
...
...
@@ -6,7 +6,6 @@ import { makeStyles } from "@mui/styles";
import
i18next
from
"
i18next
"
;
function
countryToFlag
(
isoCode
)
{
console
.
log
(
"
isoCode:
"
,
isoCode
);
return
isoCode
.
toUpperCase
()
.
replace
(
/./g
,
(
char
)
=>
String
.
fromCodePoint
(
char
.
charCodeAt
(
0
)
+
127397
));
...
...
@@ -22,30 +21,25 @@ const useStyles = makeStyles({
},
});
export
default
function
CountrySelect
(
props
)
{
export
default
function
CountrySelect
(
{
setFieldValue
,
handleBlur
}
)
{
const
classes
=
useStyles
();
return
(
<
Autocomplete
id
=
"
country-select
"
options
=
{
countries
}
classes
=
{{
option
:
classes
.
option
,
}}
classes
=
{{
option
:
classes
.
option
}}
onChange
=
{(
e
,
value
)
=>
{
value
!=
null
?
props
.
setFieldValue
(
"
country
"
,
value
.
code
)
:
props
.
setFieldValue
(
"
country
"
,
""
);
?
setFieldValue
(
"
country
"
,
value
.
code
)
:
setFieldValue
(
"
country
"
,
""
);
}}
autoHighlight
getOptionLabel
=
{(
option
)
=>
countryToFlag
(
option
.
code
)
+
"
"
+
option
.
label
}
renderOption
=
{(
option
)
=>
(
<
React
.
Fragment
>
renderOption
=
{(
props
,
option
)
=>
(
<
Box
component
=
"
li
"
{...
props
}
>
<
span
>
{
countryToFlag
(
option
.
code
)}
<
/span
>
{
option
.
label
}
<
/
React.Fragment
>
<
/
Box
>
)}
renderInput
=
{(
params
)
=>
(
<
TextField
...
...
@@ -53,7 +47,7 @@ export default function CountrySelect(props) {
label
=
{
i18next
.
t
(
"
choose_a_country
"
,
"
Choose a country
"
)}
name
=
"
country
"
variant
=
"
outlined
"
onBlur
=
{
props
.
handleBlur
}
onBlur
=
{
handleBlur
}
inputProps
=
{{
...
params
.
inputProps
,
autoComplete
:
"
country
"
,
// disable autocomplete and autofill
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment