Skip to content

Commit

Permalink
check check check
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasSJacobsen committed Nov 3, 2020
1 parent 37060ca commit c523dee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/BackOffice/CreateNewEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const CreateNewEvent = ({
},
]
);
const [postTime, setPostTime] = useState(existingEvent.post_time ? existingEvent.post_time : 0);
const [postTime, setPostTime] = useState(existingEvent.post_time ? existingEvent.post_time : "");
const [startTimePosts, setStartTimePosts] = useState(existingEvent.start_time_posts ? existingEvent.start_time_posts : "" );

/** *************************************************************************** */

Expand Down Expand Up @@ -159,6 +160,7 @@ const CreateNewEvent = ({
groups: groups.sort(groupComparator),
posts: posts,
post_time: postTime,
start_time_posts: startTimePosts,
};

if (address.length >= 3) {
Expand Down Expand Up @@ -355,13 +357,15 @@ const CreateNewEvent = ({

{newSubeventPage && (
<EventWithPosts
selectedGroups={groups}
selectedGroups={groups.sort(groupComparator)}
posts={posts}
setPosts={setPosts}
errors={errors}
setErrors={setErrors}
postTime={postTime}
setPostTime={setPostTime}
startTimePosts={startTimePosts}
setStartTimePosts={setStartTimePosts}
/>
)}

Expand Down
24 changes: 20 additions & 4 deletions src/BackOffice/EventWithPosts.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useCallback, useState } from "react";
import React, { useCallback } 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 EventWithPosts = ({ selectedGroups, posts, setPosts, setPostTime, postTime, setStartTimePosts, startTimePosts }) => {
const groupsInUse = posts.map(post => post.startGroup)
const newPost = {
id: uuid(),
title: "",
startGroup: "",
address: "",
googleMaps: "",
timeOnEveryPost: ""
}

const deletePost = (id) => {
Expand All @@ -40,15 +40,31 @@ const EventWithPosts = ({ selectedGroups, posts, setPosts, setPostTime, postTime
<Input
className="time-input"
placeholder="00"
value={postTime }
value={ postTime }
onChange={(_, data) => {
setPostTime(data.value);
}}
type="number"
autoComplete="off"
/>
</Form.Field>
<Form.Field>
<label className="form-field-header">
Når ønsker du at postene skal starte (HH:MM){" "}
</label>
<Input
className=""
placeholder="00:00"
value={startTimePosts}
onChange={(_, data) => {
setStartTimePosts(data.value)
}}
type="string"
autoComplete="off"
/>
</Form.Field>


{/** Vis poster som er lagt til */}
{posts.map((post) => (
<AddPost
Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const calculateEndTime = (startTime, minUsed) => {
}

export const mapTimeOnPosts = (event, sortedPosts) => {
let start_time = event.start_time;
let start_time = event.start_time_posts;
const post_time = event.post_time;

return sortedPosts.map(post => {
Expand Down

0 comments on commit c523dee

Please sign in to comment.