diff --git a/src/components/Common/InputEditor/InputEditor.jsx b/src/components/Common/InputEditor/InputEditor.jsx
index aa4cab4a..fb0bb141 100644
--- a/src/components/Common/InputEditor/InputEditor.jsx
+++ b/src/components/Common/InputEditor/InputEditor.jsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
-import { InputEditorContainer, InputEditorTheInput } from "./InputEditorElements";
+import { InputEditorContainer, InputEditorTextarea, InputEditorTheInput } from "./InputEditorElements";
-const InputEditor = ({ content, label, onCopyChanges, placeholder, inputType }) => {
+const InputEditor = ({ content, label, onCopyChanges, placeholder, inputType, isTextarea = false }) => {
const [value, setValue] = useState("");
useEffect(() => {
@@ -15,7 +15,11 @@ const InputEditor = ({ content, label, onCopyChanges, placeholder, inputType })
return (
-
+ {isTextarea ? (
+
+ ) : (
+
+ )}
);
};
diff --git a/src/components/Common/InputEditor/InputEditorElements.jsx b/src/components/Common/InputEditor/InputEditorElements.jsx
index fb4059d1..3ef562c4 100644
--- a/src/components/Common/InputEditor/InputEditorElements.jsx
+++ b/src/components/Common/InputEditor/InputEditorElements.jsx
@@ -1,9 +1,9 @@
-import styled from "styled-components";
+import styled, { css } from "styled-components";
export const InputEditorContainer = styled.div`
width: 100%;
`;
-export const InputEditorTheInput = styled.input`
+const InputEditorField = css`
padding: 7px 12px;
color: white;
width: 100%;
@@ -16,6 +16,15 @@ export const InputEditorTheInput = styled.input`
background-color: #090909;
font: 16px "Poppins", sans-serif;
`;
+export const InputEditorTheInput = styled.input`
+ ${InputEditorField}
+`;
+
+export const InputEditorTextarea = styled.textarea`
+ ${InputEditorField}
+ resize: none;
+`;
+
export const InputEditorLabel = styled.h2`
text-transform: capitalize;
text-align: center;
diff --git a/src/components/CommunityEvents/ModifyElements.jsx b/src/components/CommunityEvents/ModifyElements.jsx
index a6a582c6..cd21f4f4 100644
--- a/src/components/CommunityEvents/ModifyElements.jsx
+++ b/src/components/CommunityEvents/ModifyElements.jsx
@@ -17,7 +17,7 @@ export const ModifyTimeLineListContainer = styled.div`
display: flex;
flex-direction: column;
justify-content: space-between;
- align-items: center;
+ align-items: start;
`;
export const DayPickerContainer = styled.div`
border-right: 1px solid #f0f0f0;
@@ -42,7 +42,7 @@ export const DetailsInputEventContainer = styled.div`
export const TimeLineListItem = styled.li`
display: flex;
flex-direction: column;
- height: 150px;
+ height: 200px;
width: 100%;
justify-content: space-around;
border: 3px inset #2e2e2e;
@@ -100,15 +100,13 @@ export const ModifyActionButton = styled.div`
return "#f14844";
}
}};
+ margin-top: ${(props) => props.type === "add" && "10px"};
color: #f8f8f8;
&:hover {
opacity: 0.7;
cursor: pointer;
}
`;
-export const ModifyCancelActionButton = styled.div`
- background: #f14844;
-`;
export const ModifyActionsContainer = styled.div`
display: flex;
flex-direction: column;
diff --git a/src/components/CommunityEvents/ModifyTimeLine.jsx b/src/components/CommunityEvents/ModifyTimeLine.jsx
index cbd3806b..3966a237 100644
--- a/src/components/CommunityEvents/ModifyTimeLine.jsx
+++ b/src/components/CommunityEvents/ModifyTimeLine.jsx
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from "react";
+import { nanoid } from "@reduxjs/toolkit";
import {
ModifyActionsContainer,
@@ -9,41 +10,69 @@ import {
ModifyTimeLineListContainer,
} from "./ModifyElements";
import TimeLineListItemDisplay from "./TimeLineListItemDisplay";
+import { toast } from "react-toastify";
const ModifyTimeLine = ({ eventManageTimelineId, handleCloseChangeMode }) => {
- const [timeLineListItems, setTimeLineListItems] = useState([]);
-
+ const [timeLineListItems, setTimeLineListItems] = useState({});
useEffect(() => {
- setTimeLineListItems([
- {
- name: "",
- description: "",
- topic: "",
- startTime: "",
- endTime: "",
- },
- ]);
+ setTimeLineListItems(() => {
+ const newId = nanoid();
+ return {
+ [newId]: {
+ id: newId,
+ name: "",
+ description: "",
+ topic: "",
+ startTime: "",
+ endTime: "",
+ eventDay: 1,
+ },
+ };
+ });
}, []);
const handleAddListItem = () => {
setTimeLineListItems((prevArray) => {
- return [
+ const newId = nanoid();
+ return {
...prevArray,
- {
+ [newId]: {
+ id: newId,
name: "",
description: "",
topic: "",
startTime: "",
endTime: "",
+ eventDay: 1,
},
- ];
+ };
});
};
- console.log(timeLineListItems);
- const timeLineList = timeLineListItems.map((timeLineListObj, index) => (
-
+ const timeLineList = Object.values(timeLineListItems).map((timeLineListObj) => (
+
));
-
+ const handleSaveTimeline = () => {
+ // validate the every field is not empty
+ let validationError = false;
+ Object.values(timeLineListItems).some((valueObj) => {
+ Object.values(valueObj).some((value) => {
+ if (!value) {
+ validationError = true;
+ }
+ return validationError;
+ });
+ return validationError;
+ });
+ if (validationError) {
+ toast.error("Some of the input fields are empty, fill all the fields and try again");
+ return;
+ }
+ handleCloseChangeMode();
+ };
return (
@@ -53,7 +82,7 @@ const ModifyTimeLine = ({ eventManageTimelineId, handleCloseChangeMode }) => {
-
+
Save
diff --git a/src/components/CommunityEvents/TimeLineListItemDisplay.jsx b/src/components/CommunityEvents/TimeLineListItemDisplay.jsx
index b5ecfe04..35049fa9 100644
--- a/src/components/CommunityEvents/TimeLineListItemDisplay.jsx
+++ b/src/components/CommunityEvents/TimeLineListItemDisplay.jsx
@@ -11,7 +11,13 @@ import InputEditor from "../Common/InputEditor";
import TimePickerDisplay from "./TimePickerDisplay";
import { AiFillClockCircleIcon } from "./CommunityEventsElement";
-const TimeLineListItemDisplay = ({ timeLineListObj }) => {
+const TimeLineListItemDisplay = ({ timeLineListObj, setTimeLineListItems }) => {
+ const handleChangeInput = (label, content) => {
+ setTimeLineListItems((prevTimeLine) => {
+ const updateTimeLineItem = { ...prevTimeLine[timeLineListObj.id], [label]: content };
+ return { ...prevTimeLine, [updateTimeLineItem.id]: { ...updateTimeLineItem } };
+ });
+ };
return (
@@ -20,8 +26,8 @@ const TimeLineListItemDisplay = ({ timeLineListObj }) => {
inputType="text"
label="name"
placeholder="Name / @Username"
- onCopyChanges={() => {}}
- content={""}
+ onCopyChanges={handleChangeInput}
+ content={timeLineListObj.name}
/>
@@ -29,18 +35,18 @@ const TimeLineListItemDisplay = ({ timeLineListObj }) => {
inputType="text"
label="topic"
placeholder="Topic"
- onCopyChanges={() => {}}
- content={""}
+ onCopyChanges={handleChangeInput}
+ content={timeLineListObj.topic}
/>
- {}}>
+
From:
- {}}>
+
To:
@@ -48,9 +54,10 @@ const TimeLineListItemDisplay = ({ timeLineListObj }) => {
{}}
- content={""}
+ placeholder="Description"
+ onCopyChanges={handleChangeInput}
+ content={timeLineListObj.description}
+ isTextarea
/>
);