Skip to content

Commit

Permalink
Merge pull request #326 from GTBitsOfGood/sprint-day/sahi
Browse files Browse the repository at this point in the history
Sprint day/sahi
  • Loading branch information
thanasis457 authored Nov 4, 2024
2 parents a915dab + ec74631 commit ea45ec2
Show file tree
Hide file tree
Showing 14 changed files with 565 additions and 623 deletions.
7 changes: 4 additions & 3 deletions src/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,9 @@ h2 {
display: flex;
flex-direction: column;
font-size: 13px;
padding-left: 15px;
width: 15vw;
padding-left: 0px;
width: fit-content;
white-space: nowrap;
}

.modal-hours-container h5 {
Expand Down Expand Up @@ -1742,7 +1743,7 @@ h2 {
display: flex;
flex-direction: column;
align-items: center;
width: 635px;
width: 800px;
}

.provider-entry {
Expand Down
103 changes: 78 additions & 25 deletions src/components/dashboard/Directory.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,119 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useState, useEffect } from "react";

import { DirectoryItem } from "./DirectoryForm";

import styles from "./Directory.module.css";
interface DirectoryItem {
name: string;
image: string;
description: string;
details: string;
}

const DirectoryCard = ({ directoryItem }: { directoryItem: DirectoryItem }) => {
const [isMobile, setIsMobile] = useState(window.innerWidth < 768);

useEffect(() => {
const handleResize = () => {
setIsMobile(window.innerWidth < 768);
};
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);

return (
<div className={styles.directoryCard}>
<img
className={styles.directoryImage}
src={directoryItem.image}
alt={directoryItem.name}
></img>
<div className={styles.directoryInfo}>
<div
style={{
display: "flex",
flexDirection: isMobile ? "column" : "row",
border: "1px solid #ddd",
borderRadius: "8px",
marginBottom: "16px",
overflow: "hidden",
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
}}
>

<div
style={{
padding: isMobile ? "8px" : "16px",
display: "flex",
flexDirection: "column",
justifyContent: "center",
flex: 1,
}}
>
<div
style={{
fontWeight: "600",
fontSize: "20px",
fontSize: isMobile ? "16px" : "20px",
color: "#226DFF",
marginBottom: "8px",
}}
>
{directoryItem.name}
</div>
<div
style={{
fontWeight: "500",
fontSize: "16px",
fontSize: isMobile ? "14px" : "16px",
color: "#333333",
marginBottom: "8px",
}}
>
{directoryItem.description}
</div>
<div
style={{
fontWeight: "500",
fontSize: "16px",
fontSize: isMobile ? "14px" : "16px",
color: "#226DFF",
}}
>
{directoryItem.details}
</div>
</div>
<img
style={{
width: isMobile ? "100%" : "150px",
height: isMobile ? "auto" : "150px",
objectFit: "cover",
}}
src={directoryItem.image}
alt={directoryItem.name}
/>
</div>
);
};

const Directory = ({ directoryItems }: { directoryItems: DirectoryItem[] }) => {
const isTwoColumn = directoryItems.length > 3;
const [isMobile, setIsMobile] = useState(window.innerWidth < 768);

useEffect(() => {
const handleResize = () => {
setIsMobile(window.innerWidth < 768);
};
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);

return (
<div
className={`${styles.directoryGrid} ${
isTwoColumn ? styles.twoColumn : styles.oneColumn
}`}
style={{
display: "grid",
gridTemplateColumns: isMobile
? "1fr"
: isTwoColumn
? "repeat(2, 1fr)"
: "1fr",
gap: "16px",
}}
>
{directoryItems.map((directoryItem, i) => {
return (
<DirectoryCard
key={i}
directoryItem={directoryItem}
></DirectoryCard>
);
})}
{directoryItems.map((directoryItem, i) => (
<DirectoryCard key={i} directoryItem={directoryItem} />
))}
</div>
);
};
Expand Down
228 changes: 228 additions & 0 deletions src/components/dashboard/GeneralInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
import React, { useEffect, useState } from "react";
import { Col, Row } from "react-bootstrap";
import { FaRegClock } from "react-icons/fa";
import { IoPhonePortraitOutline } from "react-icons/io5";
import { SlGlobe } from "react-icons/sl";
import { TbPlaystationCircle } from "react-icons/tb";

export default function GeneralInfo(props) {
const [isMobile, setIsMobile] = useState(window.innerWidth < 768);
useEffect(() => {
const handleResize = () => {
setIsMobile(window.innerWidth < 768);
};
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
};
}, []);
const infoStyle = {
display: "flex",
alignItems: "center",
marginBottom: "10px",
};

const iconStyle = {
marginRight: "20px",
verticalAlign: "middle",
color: "#226DFF",
};

function calculateHours(props) {
const rows = [];
const startandFinish = [0]; // In pairs, keep track of the starting and ending days with same time
const days = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
];
const abbrevDays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
for (let i = 1; i < 7; i++) {
// not both undefined
if (props.item.hours[days[i]] !== props.item.hours[days[i - 1]]) {
if (
!props.item.hours[days[i]] ||
!props.item.hours[days[i - 1]] ||
props.item.hours[days[i]][0] !==
props.item.hours[days[i - 1]][0] ||
props.item.hours[days[i]][1] !==
props.item.hours[days[i - 1]][1]
) {
startandFinish.push(i - 1);
startandFinish.push(i);
}
}
if (i === 6) {
startandFinish.push(6);
}
}
for (let i = 0; i < startandFinish.length; i += 2) {
const children = [];
if (startandFinish[i] === startandFinish[i + 1]) {
children.push(
<Col className="modal-col-flex-end" sm={5}>
{days[startandFinish[i]]}
</Col>,
);
} else {
const subchild = [
<div>
{abbrevDays[startandFinish[i]]} -{" "}
{abbrevDays[startandFinish[i + 1]]}
</div>,
];
children.push(
<Col className="modal-col-flex-end" sm={5}>
{subchild}
</Col>,
);
}
children.push(
<Col className="modal-col-flex-start">
{props.item.hours[days[startandFinish[i]]]
? props.item.hours[days[startandFinish[i]]].map(
(time, index) =>
formatTime(
props.item.hours[days[startandFinish[i]]],
time,
index,
),
)
: "CLOSED"}
</Col>,
);
rows.push(<Row>{children}</Row>);
}
return rows;
}

function formatTime(arr, time, index) {
if (time == null) {
if (index !== arr.length - 1) {
return <div className="modal-text">CLOSED - </div>;
}
return <div className="modal-text">CLOSED</div>;
}
const seconds = time;
let hours = Math.floor(seconds / 3600);
let mins: string = ((seconds / 60) % 60).toString();
const endtime_ending = hours < 12 ? "AM" : "PM";
hours %= 12;
if (hours === 0) {
hours = 12;
}
if (parseInt(mins) < 10) {
mins = `0${mins}`;
}
const timeformat = `${hours}:${mins}${endtime_ending}`;
if (index !== arr.length - 1) {
return <div className="modal-text">{timeformat} - </div>;
}
return <div className="modal-text">{timeformat}</div>;
}

return (
<>
<div className="description-box">
{props.item.description !== undefined && (
<p
style={{
color: "rgba(148, 142, 142, 0.9)",
fontFamily: "Inter",
fontWeight: "500",
fontSize: "16px",
lineHeight: "19px"
}}
>
{props.item.description}
</p>
)}
</div>
<div style={infoStyle}>
<IoPhonePortraitOutline size={20} style={iconStyle} />
<div>
{" "}
{props.item.phoneNum &&
props.item.phoneNum.join(", ")}
</div>
</div>
<div style={infoStyle}>
{props.item.website && props.item.website[0] && (
<>
{props.item.website[0].startsWith("http") ? (<>
<SlGlobe size={20} style={iconStyle} />
<div>
<a
href={props.item.website[0]}
target="_blank"
rel="noopener noreferrer"
>
p{props.item.website[0]}
</a>
</div>
</>) : (<>
<SlGlobe size={20} style={iconStyle} />
<div>
<a
href={'//' + props.item.website[0]}
target="_blank"
rel="noopener noreferrer"
>
{props.item.website[0]}
</a>
</div></>)}

</>
)}
</div>
<div style={infoStyle}>
<TbPlaystationCircle size={20} style={iconStyle} />
<div>
{" "}
{props.item.address
.toString()
.split(",")
.map((value, index) => {
if (index === 0) {
return (
<div style={{ display: "inline" }}>
{value},
</div>
);
}
if (
index ===
props.item.address.toString().split(",")
.length -
1
) {
return (
<div style={{ display: "inline" }}>
{value}
</div>
);
}
if (index === 1) {
return (
<div
style={{ display: "inline" }}
>{`${value},`}</div>
);
}
return `${value},`;
})}
</div>
</div>
<div style={infoStyle}>
<FaRegClock size={20} style={iconStyle} />
<div className="modal-hours-container">
{props.item.hours && calculateHours(props)}
</div>
</div>
</>
);
}
Loading

0 comments on commit ea45ec2

Please sign in to comment.