Feature Owner Home UI#11
Conversation
bab1372 to
d609f4d
Compare
376d67a to
82c1195
Compare
| end | ||
|
|
||
| def club_params | ||
| params.permit(:name, :email, :city, :country, :address, :image, gallery: []) |
There was a problem hiding this comment.
Hi, Could you remove this line please?
There was a problem hiding this comment.
You're right. I'll do it
| }, [setClubs]); | ||
|
|
||
| React.useEffect(() => { | ||
| getSportFields().then(sportFields => { |
There was a problem hiding this comment.
Here you should validate that the active club is different from null for
bring the sports fields for each club and avoid making unnecessary calls to the server:
React.useEffect(() => {
if (activeClub) {
getSportFields(activeClub).then(sportFields => {
setSportFields(sportFields);
});
}
}, [setSportFields]);
| const sportFields = useSportFields(); | ||
| const setClubs = useSetClubs(); | ||
| const setSportFields = useSetSportFields(); | ||
| const [activeClub, setActiveClub] = React.useState(1); |
There was a problem hiding this comment.
I think the default value should be null, because if there are no clubs, it means that there are no sport fields either and when you make the request to get the sports fields it will give error:
const [activeClub, setActiveClub] = React.useState(null);
|
|
||
| React.useEffect(() => { | ||
| getClubs().then(clubs => { | ||
| setClubs(clubs); |
There was a problem hiding this comment.
You could pass the default value of the club(activeClub) here:
React.useEffect(() => {
getClubs().then(clubs => {
setClubs(clubs);
setActiveClub(clubs.length ? clubs[0].id : null)
});
}, [setClubs]);
There was a problem hiding this comment.
Thanks for noticing all of that, I'll change it right now.
This PR adds
ui.jsfile where anyone can create generic styled componentsClose #5
Close #6
Close #7