Skip to content

Commit

Permalink
Fix dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasSJacobsen committed Nov 3, 2020
1 parent a0f7d86 commit 37060ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/BackOffice/AddPost.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ const AddPost = ({
post,
updateCallback,
deleteCallback,
groupsInUse
}) => {
let groups = selectedGroups.map((group) => ({
const [id] = useState(post.id);
const [title, setTitle] = useState(post.title);
const [startGroup, setStartGroup] = useState(post.startGroup);
const [address, setAddress] = useState(post.address);
const [googleMaps, setGoogleMaps] = useState(post.googleMaps);

let groups = selectedGroups.filter(g => g === startGroup || !groupsInUse.includes(g)).map((group) => ({
text: "Gruppe " + group,
key: "Gruppe " + group,
value: group,
Expand All @@ -24,12 +31,6 @@ const AddPost = ({
value: "-",
});

const [id] = useState(post.id);
const [title, setTitle] = useState(post.title);
const [startGroup, setGroup] = useState(post.startGroup);
const [address, setAddress] = useState(post.address);
const [googleMaps, setGoogleMaps] = useState(post.googleMaps);

// Update post if title, startGroup, address or googleMaps change
useEffect(
() =>
Expand Down Expand Up @@ -70,7 +71,7 @@ const AddPost = ({
search
selection
options={groups}
onChange={(_, data) => setGroup(data.value)}
onChange={(_, data) => setStartGroup(data.value)}
/>
</div>

Expand Down
6 changes: 3 additions & 3 deletions src/BackOffice/EventWithPosts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback } from "react";
import React, { useCallback, useState } from "react";
import AddPost from "./AddPost";
import AddEventButton from "./AddEventButton";
import uuid from "react-uuid";
import { Form, Input } from "semantic-ui-react";


const EventWithPosts = ({ selectedGroups, posts, setPosts, setPostTime, postTime }) => {

const groupsInUse = posts.map(post => post.startGroup)
const newPost = {
id: uuid(),
title: "",
Expand Down Expand Up @@ -35,7 +35,6 @@ const EventWithPosts = ({ selectedGroups, posts, setPosts, setPostTime, postTime

<Form.Field>
<label className="form-field-header">
{" "}
Tid på hver post (minutter){" "}
</label>
<Input
Expand All @@ -58,6 +57,7 @@ const EventWithPosts = ({ selectedGroups, posts, setPosts, setPostTime, postTime
post={post}
updateCallback={updatePost}
deleteCallback={deletePost}
groupsInUse={groupsInUse}
/>
))}
<div className="add-subposts">
Expand Down

0 comments on commit 37060ca

Please sign in to comment.