Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/calendar integration and fixes #336

Merged
merged 5 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/components/dashboard/AddProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,10 @@ function AddProvider(props) {
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
)
return data.events.every((event) => {
const validFields = event.eventName && event.fromDate && event.toDate;
const validTimes = !event.isAllDay ? event.fromTime && event.toTime : true;
return validFields && validTimes;
});
case "Chart":
switch (data.type) {
Expand Down
27 changes: 11 additions & 16 deletions src/components/dashboard/ContentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ const SectionCard = ({
case "Text":
return {
title: "Text",
description: '<p>ex. "Changing lives one bit at a time..."</p>'
}
description:
'<p>ex. "Changing lives one bit at a time..."</p>',
};
default:
return {};
}
Expand Down Expand Up @@ -330,9 +331,7 @@ const SectionCard = ({
}}
onClick={() => {
setSelectedSection(null);
setSections(
sections.filter((_, i) => i !== index)
);
setSections(sections.filter((_, i) => i !== index));
}}
>
Delete Section
Expand All @@ -350,6 +349,7 @@ const SectionCard = ({
lineHeight: "24px",
}}
label={v.type}
defaultState={false}
>
{switchRender(v.type, v.data, i)}
</Collapsible>
Expand All @@ -370,19 +370,13 @@ const SectionCard = ({
</Dropdown.Toggle>

<Dropdown.Menu>
<Dropdown.Item
onClick={() => addComponent("Calendar")}
>
<Dropdown.Item onClick={() => addComponent("Calendar")}>
Calendar
</Dropdown.Item>
<Dropdown.Item
onClick={() => addComponent("Chart")}
>
<Dropdown.Item onClick={() => addComponent("Chart")}>
Chart
</Dropdown.Item>
<Dropdown.Item
onClick={() => addComponent("Directory")}
>
<Dropdown.Item onClick={() => addComponent("Directory")}>
Directory
</Dropdown.Item>
<Dropdown.Item onClick={() => addComponent("Embed")}>
Expand Down Expand Up @@ -431,8 +425,9 @@ const SectionButton = ({
maxWidth: "12px",
borderTopLeftRadius: "8px",
borderBottomLeftRadius: "8px",
backgroundColor: `${isSelected ? "#226DFF" : "transparent"
}`,
backgroundColor: `${
isSelected ? "#226DFF" : "transparent"
}`,
}}
></Col>
<Col
Expand Down
53 changes: 35 additions & 18 deletions src/components/dashboard/RowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const RowForm = (props) => {
}
}

function handleStationNumChange(e) {
const newItem = { ...item, [e.target.name]: [e.target.value] };
setItem(newItem);
// props.setItem(newItem);
}

function onPhoneChange(e) {
let newItem = {};
if (e.target.value.length === 4 && e.target.value[0] === "(") {
Expand Down Expand Up @@ -334,15 +340,26 @@ const RowForm = (props) => {
/>
</Form.Group>
<Form.Group>
<Form.Label >Station #</Form.Label>
<Form.Control
name="stationNum"
type="number"
value={item.stationNum}
onChange={handleInputChange}
placeholder="#"
style={{ width: '100px' }}
/>
<Form.Label>Station #</Form.Label>
<Form.Control
name="stationNum"
type="number"
value={item.stationNum}
onChange={handleStationNumChange}
onBlur={(e) => {
let value = Number(e.target.value);
value = Math.max(value, 0);
const newItem = {
...item,
[e.target.name]: [value],
};
setItem(newItem);
props.setItem(newItem);
}}
placeholder="#"
style={{ width: "100px" }}
min="0"
/>
</Form.Group>
</>
);
Expand All @@ -364,14 +381,14 @@ const RowForm = (props) => {
<Form.Label>{name}</Form.Label>
<MultiSelect
options={options}
selected={item['filters'][key] || []}
selected={item["filters"][key] || []}
onSelectedChanged={(selected) => {
const newItem = {
...item,
['filters']: {
...item['filters'],
["filters"]: {
...item["filters"],
[key]: selected,
}
},
};
setItem(newItem);
}}
Expand All @@ -391,14 +408,14 @@ const RowForm = (props) => {
<Form.Label>{name}</Form.Label>
<Form.Control
as="textarea"
value={item['filters'][key]}
value={item["filters"][key]}
onChange={(e: any) => {
const newItem = {
...item,
['filters']: {
...item['filters'],
[key]: e.target.value
}
["filters"]: {
...item["filters"],
[key]: e.target.value,
},
};
setItem(newItem);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ export default function CalendarEvent({
if (num > 10 || num < 1) return;
handleDisplayNumberChange(num);
}}
style={{ width: "65px" }}
style={{
paddingLeft: "10px",
maxWidth: "60px",
paddingRight: "10px",
}}
/>
</Form.Group>
)}
Expand Down
29 changes: 23 additions & 6 deletions src/components/dashboard/calender-component/CalendarForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,21 @@ export default function CalendarForm({
buttonText: "",
};

const events = calendarData.events;
// const [displayNumber, setDisplayNumber] = useState<number>(
// calendarData.displayNumber
// );

const [displayNumber, setDisplayNumber] = useState<number>(
calendarData.displayNumber
);
const setEvents = (callback) => {
const prevEvents = [...calendarData.events];
const updatedEvents = callback(prevEvents);
setCalendarData({ ...calendarData, events: updatedEvents });
};

const setDisplayNumber = (newDisplayNumber) => {
setCalendarData({ ...calendarData, displayNumber: newDisplayNumber });
};

const { events, displayNumber } = calendarData;

const handleEventDataChange = (
index: number,
Expand Down Expand Up @@ -145,11 +155,18 @@ export default function CalendarForm({
};

return (
<div style={{ width: "100%", margin: "0px" }}>
<div
style={{
width: "100%",
margin: "0px",
display: "flex",
flexDirection: "column",
}}
>
{renderEvents()}
<div style={{ display: "flex", justifyContent: "space-between" }}>
<Button
onClick={() => handleAdd(events.length-1)}
onClick={() => handleAdd(events.length - 1)}
style={{
backgroundColor: "white",
color: "#226DFF",
Expand Down
67 changes: 52 additions & 15 deletions src/components/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,29 @@ function Home({ firebaseAuth, firestore }) {
}
}, [firebaseAuth]);

useEffect(() => {
if (!validateEmail(email) || emailDisabled) setEmailDisabled(false);
else {
setEmailDisabled(true);
setShowEmailBtnModal(true);
}
}, [email]);
// useEffect(() => {
// const validEmail = validateEmail(email);

// // if (!validEmail) {
// // if (emailDisabled) {
// // setEmailDisabled(false); // Only update if necessary
// // }
// // } else {
// // console.log("here");
// // if (!emailDisabled) {
// // setEmailDisabled(true); // Only update if necessary
// // setShowEmailBtnModal(true); // Show the modal for valid email
// // }
// // }
// // if (!validateEmail(email) || emailDisabled) {
// // console.log("here1");
// // setEmailDisabled(false);
// // } else {
// // console.log("here");
// // setEmailDisabled(true);
// // setShowEmailBtnModal(true);
// // }
// }, [email]);

async function handleSubmit() {
const payload = { email };
Expand Down Expand Up @@ -162,6 +178,7 @@ function Home({ firebaseAuth, firestore }) {
<b>complete control</b> over the information and
search filters you present.
</p>
<p>hi {emailDisabled.toString()}</p>
<ul style={{ marginLeft: 20 }}>
<li>Completely free for nonprofits</li>
<li>100% customer satisfaction</li>
Expand All @@ -185,9 +202,32 @@ function Home({ firebaseAuth, firestore }) {
<Form.Control
type="email"
value={email}
onChange={(e) =>
setEmail((e.target as HTMLInputElement).value)
}
onChange={(e) => {
const emailValue = (
e.target as HTMLInputElement
).value;
setEmail(emailValue);
const validEmail =
validateEmail(emailValue);
if (validEmail) {
setEmailDisabled(false);
} else {
setEmailDisabled(true);
}
}}
onInput={(e) => {
const emailValue = (
e.target as HTMLInputElement
).value;
setEmail(emailValue);
const validEmail =
validateEmail(emailValue);
if (validEmail) {
setEmailDisabled(false);
} else {
setEmailDisabled(true);
}
}}
//onClick={addModal}
placeholder="[email protected]"
aria-label="Sign up for our waitlist"
Expand All @@ -207,10 +247,7 @@ function Home({ firebaseAuth, firestore }) {
</Modal>
<InputGroup.Append>
<Button
disabled={
emailDisabled ||
!validateEmail(email)
}
disabled={emailDisabled}
onClick={handleSubmit}
id="emailSignup"
>
Expand Down Expand Up @@ -311,5 +348,5 @@ const mapStateToProps = (state) => ({

export default compose<any>(
withFirestore,
connect(mapStateToProps, null),
connect(mapStateToProps, null)
)(React.memo(Home));
3 changes: 2 additions & 1 deletion src/components/navigation/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
FiBell,
FiPower,
FiMessageCircle,
FiLogOut,
} from "react-icons/fi";
import {
providerRoute,
Expand Down Expand Up @@ -220,7 +221,7 @@ function NavBar(props) {
>
<div className="cell" onClick={props.logout}>
<div className="icon">
<FiPower />
<FiLogOut />
</div>
<div
className={classnames("cell-title", {
Expand Down
Loading