Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GrowBros
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tomato
GrowBros
Commits
c3f30c18
Commit
c3f30c18
authored
1 year ago
by
Blersch Lara
Browse files
Options
Downloads
Patches
Plain Diff
#16
restart branch for clear separation of different branches
parent
e33fdd21
No related branches found
No related tags found
1 merge request
!41
Wishlist frontend
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
growbros-frontend/src/components/DropDownFilter.tsx
+36
-0
36 additions, 0 deletions
growbros-frontend/src/components/DropDownFilter.tsx
growbros-frontend/src/pages/Wunschliste.tsx
+45
-17
45 additions, 17 deletions
growbros-frontend/src/pages/Wunschliste.tsx
with
81 additions
and
17 deletions
growbros-frontend/src/components/DropDownFilter.tsx
0 → 100644
+
36
−
0
View file @
c3f30c18
import
React
from
'
react
'
import
{
useState
}
from
"
react
"
;
function
DropDownFilter
(
props
:
PropsDropDownFilter
)
{
const
options
=
props
.
options
;
const
topic
=
props
.
topic
;
const
[
selectedOption
,
setSelectedOption
]
=
useState
(
""
);
//todo: add another const here for holding the url and sort parameter to filter the plants
const
handleOptionChange
=
(
event
:
any
)
=>
{
setSelectedOption
(
event
.
target
.
value
);
//todo: implement a fetch here to get the filtered plants
};
return
(
<
div
>
<
label
>
{
topic
}
</
label
>
<
select
value
=
{
selectedOption
}
onChange
=
{
handleOptionChange
}
>
<
option
value
=
""
></
option
>
{
options
.
map
((
option
,
index
)
=>
(
<
option
key
=
{
index
}
value
=
{
option
}
>
{
option
}
</
option
>
))
}
</
select
>
</
div
>
);
}
type
PropsDropDownFilter
=
{
options
:
Array
<
string
>
;
topic
:
string
;
};
export
default
DropDownFilter
\ No newline at end of file
This diff is collapsed.
Click to expand it.
growbros-frontend/src/pages/Wunschliste.tsx
+
45
−
17
View file @
c3f30c18
import
{
useEffect
,
useState
}
from
"
react
"
;
import
PlantDetails
from
"
../components/PlantDetails
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
import
PlantCard
from
"
../components/PlantCard.tsx
"
;
import
DropDownFilter
from
"
../components/DropDownFilter.tsx
"
;
function
Wunschliste
()
{
const
[
plants
,
setPlants
]
=
useState
<
any
[]
>
([]);
const
[
error
,
setError
]
=
useState
();
useEffect
(()
=>
{
fetch
(
"
http://localhost:8080/api/v1/
plants
"
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
plants
)
=>
setPlants
(
plants
))
.
catch
((
err
)
=>
setError
(
err
));
fetch
(
"
http://localhost:8080/api/v1/
wishlist
"
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
plants
)
=>
setPlants
(
plants
))
.
catch
((
err
)
=>
setError
(
err
));
},
[
setPlants
]);
const
handleClearWishList
=
async
()
=>
{
if
(
confirm
(
"
Möchtest du wirklich alle Pflanzen aus deiner Wunschliste entfernen?
"
+
"
\n
"
+
"
Diese Aktion kann nicht rückgängig gemacht werden.
"
))
{
useEffect
(()
=>
{
fetch
(
"
http://localhost:8080/api/v1/wishlist/remove/all
"
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
plants
)
=>
setPlants
(
plants
))
.
catch
((
err
)
=>
setError
(
err
));
},
[
setPlants
]);
}
}
return
(
<>
{
error
?
(
<
p
>
Error fetching data
</
p
>
)
:
(
<
ul
style
=
{
{
display
:
"
flex
"
,
gap
:
"
1rem
"
,
width
:
"
100%
"
}
}
>
{
plants
?.
map
((
plant
)
=>
(
<
PlantDetails
plant
=
{
plant
}
key
=
{
plant
.
id
}
/>
))
}
</
ul
>
)
}
</>
<>
<
div
>
<
h2
>
Deine Wunschliste
</
h2
>
<
DropDownFilter
topic
=
{
"
Sortierung der Pflanzen in der Wunschliste
"
}
options
=
{
[
"
neueste zuerst
"
,
"
als nächstes anpflanzbar
"
,
"
jetzt anpflanzbar
"
,
]
}
/>
<
button
onClick
=
{
handleClearWishList
}
>
Wunschliste leeren
</
button
>
</
div
>
{
error
?
(
<
p
>
Error fetching data
</
p
>
)
:
(
<
ul
style
=
{
{
display
:
"
flex
"
,
gap
:
"
1rem
"
,
width
:
"
100%
"
}
}
>
{
plants
?.
map
((
plant
)
=>
(
<
PlantCard
plant
=
{
plant
}
key
=
{
plant
.
id
}
/>
))
}
</
ul
>
)
}
</>
);
}
export
default
Wunschliste
;
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