Skip to content

Commit

Permalink
Merge pull request #327 from GTBitsOfGood/feature/calendarComponent
Browse files Browse the repository at this point in the history
feature/CalendarComponent
  • Loading branch information
thanasis457 authored Jan 4, 2025
2 parents ce43167 + f4f8cdd commit ebb972d
Show file tree
Hide file tree
Showing 8 changed files with 1,042 additions and 32 deletions.
11 changes: 11 additions & 0 deletions src/components/dashboard/AddProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import promiseWithTimeout from "../../functions/promiseWithTimeout";
import { GOOGLE_API_KEY } from "../../config/keys";
import { storage } from "../../store";
import { Store } from "reducers/types";
import { ICalendarEvent } from "./calender-component/CalendarForm";
const { v4: uuidv4 } = require("uuid");

let steps = [
Expand Down Expand Up @@ -163,6 +164,16 @@ function AddProvider(props) {
const validateComponent = (component) => {
const { type, data } = component;
switch (type) {
case "Calendar":
return data.events.every((event: ICalendarEvent) => {
return (
event.eventName.length > 0 &&
event.fromDate.length > 0 &&
event.toDate.length > 0 &&
event.fromTime.length > 0 &&
event.toTime.length > 0
)
});
case "Chart":
switch (data.type) {
case "donut":
Expand Down
45 changes: 41 additions & 4 deletions src/components/dashboard/ContentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Collapsible from "components/collapsible";
import ProviderGallery from "./ProviderGallery";
import EmbedForm from "./embed-component/EmbedForm";
import { SimpleEditor } from "./TextComponent/SimpleEditor";
import CalendarForm from "components/dashboard/calender-component/CalendarForm";

const EditableText = ({ text, setText, isEditing, setIsEditing }) => {
const inputRef = useRef(null);
Expand Down Expand Up @@ -114,6 +115,28 @@ const SectionCard = ({

const getDefaultData = (componentType) => {
switch (componentType) {
case "Calendar":
return {
displayNumber: 5,
events: [{
eventName: "",
fromDate: "",
toDate: "",
fromTime: "",
toTime: "",
isAllDay: false,
isCustom: false,
address: "",
description: "",
repeatDays: [],
customEndDate: "",
customEndOccurrences: 1,
isOn: true,
isAfter: false,
buttonLink: "",
buttonText: "",
}]
};
case "Chart":
return {
type: "donut",
Expand Down Expand Up @@ -190,6 +213,18 @@ const SectionCard = ({

const switchRender = (type, data, i) => {
switch (type) {
case "Calendar":
return (
<CalendarForm
calendarData={data}
setCalendarData={(newData) => {
updateIthComponent(newData, i);
}}
deleteComponent={() => {
deleteIthComponent(i);
}}
></CalendarForm>
);
case "Chart":
return (
<ChartComponentForm
Expand Down Expand Up @@ -336,10 +371,12 @@ const SectionCard = ({

<Dropdown.Menu>
<Dropdown.Item
onClick={() => {
// console.log("")
addComponent("Chart");
}}
onClick={() => addComponent("Calendar")}
>
Calendar
</Dropdown.Item>
<Dropdown.Item
onClick={() => addComponent("Chart")}
>
Chart
</Dropdown.Item>
Expand Down
32 changes: 5 additions & 27 deletions src/components/dashboard/RowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,6 @@ import Button from "react-bootstrap/Button";
import ActionForm from "./ActionForm";
import ContentForm from "./ContentForm";

const galleryData = [
{
title: "testVal1",
description: "testing testing",
imgLink:
"https://images.squarespace-cdn.com/content/v1/54822a56e4b0b30bd821480c/45ed8ecf-0bb2-4e34-8fcf-624db47c43c8/Golden+Retrievers+dans+pet+care.jpeg",
},
{
title: "testVal2",
description: "testing testing",
imgLink:
"https://images.squarespace-cdn.com/content/v1/54822a56e4b0b30bd821480c/45ed8ecf-0bb2-4e34-8fcf-624db47c43c8/Golden+Retrievers+dans+pet+care.jpeg",
},
{
title: "testVal3",
description: "testing testing",
imgLink:
"https://images.squarespace-cdn.com/content/v1/54822a56e4b0b30bd821480c/45ed8ecf-0bb2-4e34-8fcf-624db47c43c8/Golden+Retrievers+dans+pet+care.jpeg",
},
{
title: "testVal4",
description: "testing testing",
imgLink:
"https://images.squarespace-cdn.com/content/v1/54822a56e4b0b30bd821480c/45ed8ecf-0bb2-4e34-8fcf-624db47c43c8/Golden+Retrievers+dans+pet+care.jpeg",
},
];

function validURL(str) {
const pattern = new RegExp(
"^(https?:\\/\\/)?" + // protocol
Expand Down Expand Up @@ -402,6 +375,7 @@ const RowForm = (props) => {
onChange={onTimeChange}
/>
);

case "Tag":
return (
<>
Expand Down Expand Up @@ -429,6 +403,7 @@ const RowForm = (props) => {
)}
</>
);

case "Text":
return (
<>
Expand Down Expand Up @@ -456,6 +431,7 @@ const RowForm = (props) => {
)}
</>
);

case "Toggle":
return (
<>
Expand All @@ -482,6 +458,7 @@ const RowForm = (props) => {
)}
</>
);

case "Actions":
return (
<ActionForm
Expand All @@ -490,6 +467,7 @@ const RowForm = (props) => {
onChange={onActionTableChange}
/>
);

case "Content":
return (
<ContentForm
Expand Down
Loading

0 comments on commit ebb972d

Please sign in to comment.