Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
red-giant
dashboard
Commits
009a0be9
Verified
Commit
009a0be9
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Integrate api call.
parent
62964825
No related branches found
No related tags found
2 merge requests
!60
New component to search senior (see #12). Enhance responsiveness and solve #10 and #11
,
!58
Camelize data and insert react-hook-form in autocomplete.
Pipeline
#12645
passed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/Dashboard/ReservationPage/Reservation/SeniorSearch.tsx
+15
-24
15 additions, 24 deletions
...ts/Dashboard/ReservationPage/Reservation/SeniorSearch.tsx
with
15 additions
and
24 deletions
src/components/Dashboard/ReservationPage/Reservation/SeniorSearch.tsx
+
15
−
24
View file @
009a0be9
/* eslint-disable react/jsx-props-no-spreading */
import
React
,
{
FC
,
useEffect
,
useState
}
from
'
react
'
;
import
React
,
{
FC
,
useState
}
from
'
react
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
import
Autocomplete
from
'
@material-ui/lab/Autocomplete
'
;
import
{
getSeniorList
}
from
'
api/getSeniorList
'
;
import
{
CircularProgress
}
from
'
@material-ui/core
'
;
import
{
ResponseProps
}
from
'
api/ResponseProps
'
;
type
DataProps
=
{
lastName
:
string
;
id
:
number
;
};
export
const
SeniorSearch
:
FC
=
()
=>
{
const
[
value
,
setValue
]
=
useState
<
ResponseProps
|
null
>
(
null
);
const
[
lastNameInput
,
setLastNameInput
]
=
useState
<
string
>
(
''
);
const
[
seniors
,
setSeniors
]
=
useState
<
ResponseProps
[]
>
([
{
id
:
0
,
user
:
{
username
:
''
,
firstName
:
''
,
lastName
:
''
,
email
:
''
,
},
},
]);
const
[
seniors
,
setSeniors
]
=
useState
<
ResponseProps
[]
>
([]);
const
handleChange
=
(
newValue
:
string
):
void
=>
{
if
(
newValue
!==
undefined
)
{
const
MIN_SEARCH_LENGTH
=
3
;
if
(
newValue
.
length
>=
MIN_SEARCH_LENGTH
)
getSeniorList
(
newValue
).
then
((
list
)
=>
{
setSeniors
(
list
as
ResponseProps
[]);
console
.
log
(
seniors
);
setSeniors
(
list
);
});
}
};
...
...
@@ -42,17 +24,26 @@ export const SeniorSearch: FC = () => {
value
=
{
value
}
id
=
"senior-searcher"
onInputChange
=
{
(
event
,
newValue
)
=>
handleChange
(
newValue
)
}
options
=
{
seniors
as
ResponseProps
[]
}
onChange
=
{
(
event
,
newValue
)
=>
{
setValue
(
newValue
);
}
}
options
=
{
seniors
}
getOptionSelected
=
{
(
option
,
val
)
=>
option
.
id
===
val
.
id
}
getOptionLabel
=
{
(
option
)
=>
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
({
user
:
true
},
'
user
'
))
{
return
option
.
user
.
email
?
option
.
user
.
email
:
''
;
return
option
.
user
.
lastName
;
}
return
''
;
}
}
renderOption
=
{
(
option
)
=>
(
<>
{
option
.
user
.
firstName
}
{
option
.
user
.
lastName
}
{
option
.
user
.
username
}
</>
)
}
renderInput
=
{
(
params
)
=>
(
<
TextField
{
...
params
}
label
=
"
Asynchronous
"
label
=
"
Search a senior
"
variant
=
"outlined"
InputProps
=
{
{
...
params
.
InputProps
,
...
...
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