Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
project_ss23_gameunity
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
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Yusuf Akgül
project_ss23_gameunity
Commits
c19fbd06
Commit
c19fbd06
authored
1 year ago
by
Serdar D
Browse files
Options
Downloads
Patches
Plain Diff
Search angepasst.
parent
a82ca115
No related branches found
No related tags found
1 merge request
!6
Sort + Search UI
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/Search.tsx
+29
-5
29 additions, 5 deletions
components/Search.tsx
with
29 additions
and
5 deletions
components/Search.tsx
+
29
−
5
View file @
c19fbd06
"
use client
"
import
ArrowCircleRightRoundedIcon
from
'
@mui/icons-material/ArrowCircleRightRounded
'
;
import
ArrowCircleRightRoundedIcon
from
'
@mui/icons-material/ArrowCircleRightRounded
'
;
import
SearchIcon
from
'
@mui/icons-material/Search
'
;
import
SearchIcon
from
'
@mui/icons-material/Search
'
;
import
{
Container
,
IconButton
,
InputAdornment
,
TextField
}
from
'
@mui/material
'
;
import
{
Container
,
IconButton
,
InputAdornment
,
TextField
}
from
'
@mui/material
'
;
import
{
useState
}
from
'
react
'
;
import
{
getGames
}
from
'
@/lib/igdb
'
;
import
{
IGame
}
from
'
@/types/types
'
;
import
Game
from
'
./Game
'
;
export
default
function
Search
()
{
const
[
searchText
,
setSearchText
]
=
useState
(
''
);
const
[
searchResults
,
setSearchResults
]
=
useState
<
IGame
[]
>
([]);
export
default
function
SearchInput
()
{
const
handleSearch
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleSearch
=
(
event
:
{
target
:
{
value
:
any
;
};
})
=>
{
const
searchText
=
event
.
target
.
value
;
const
searchText
=
event
.
target
.
value
;
console
.
log
(
'
Search:
'
,
searchText
);
setSearchText
(
searchText
);
};
const
handleSearchSubmit
=
async
()
=>
{
// Suche der Games durch eigene Sucheingaben.
const
games
=
await
getGames
();
// Funktion um die Games aus Datenbank zu getten
//Es wird geschaut ob gamename(mit to lower Case), dem suchtext (searchText mit to lower case) entspricht.
const
filteredGames
=
games
.
filter
(
game
=>
game
.
name
.
toLowerCase
().
includes
(
searchText
.
toLowerCase
()));
setSearchResults
(
filteredGames
);
};
};
return
(
return
(
...
@@ -14,6 +31,7 @@ export default function SearchInput() {
...
@@ -14,6 +31,7 @@ export default function SearchInput() {
placeholder
=
"Search"
placeholder
=
"Search"
variant
=
"outlined"
variant
=
"outlined"
size
=
"small"
size
=
"small"
value
=
{
searchText
}
onChange
=
{
handleSearch
}
onChange
=
{
handleSearch
}
InputProps
=
{
{
InputProps
=
{
{
startAdornment
:
(
startAdornment
:
(
...
@@ -23,7 +41,8 @@ export default function SearchInput() {
...
@@ -23,7 +41,8 @@ export default function SearchInput() {
),
),
endAdornment
:
(
endAdornment
:
(
<
InputAdornment
position
=
"end"
>
<
InputAdornment
position
=
"end"
>
<
IconButton
edge
=
"end"
aria-label
=
"start search"
>
{
/* Gesucht wird erst wenn auf Suche geklickt wird. */
}
<
IconButton
edge
=
"end"
aria-label
=
"start search"
onClick
=
{
handleSearchSubmit
}
>
<
ArrowCircleRightRoundedIcon
/>
<
ArrowCircleRightRoundedIcon
/>
</
IconButton
>
</
IconButton
>
</
InputAdornment
>
</
InputAdornment
>
...
@@ -33,6 +52,11 @@ export default function SearchInput() {
...
@@ -33,6 +52,11 @@ export default function SearchInput() {
},
},
}
}
}
}
/>
/>
{
/* Anzeigen der Suchergebnisse */
}
{
searchResults
.
map
(
game
=>
(
<
Game
key
=
{
game
.
id
}
id
=
{
game
.
id
}
name
=
{
game
.
name
}
cover
=
{
game
.
cover
}
/>
))
}
</
Container
>
</
Container
>
);
);
};
}
\ No newline at end of file
\ No newline at end of file
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