Skip to content

Commit

Permalink
Fixed speaker data
Browse files Browse the repository at this point in the history
Fixed bad layout - add speaker data in correct format
  • Loading branch information
samad-yar-khan committed Apr 2, 2022
1 parent dc97756 commit d3de9b2
Show file tree
Hide file tree
Showing 11 changed files with 9,670 additions and 59 deletions.
45 changes: 45 additions & 0 deletions app/components/speakerinfotile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Image from "next/image";
import Link from "next/link";
import Styles from "../styles/SpeakerInfotiles.module.css";
import { parseDate, parseTime } from "../lib/dateTime";

export default function SpeakerInfotiles({ data }) {
return (
<>
{data.map((obj) => (
<div
key={obj.id}
className={obj.imageUrl ? Styles.cardWithImage : Styles.card}
>
{obj.imageUrl && (
<Image
src={obj.imageUrl}
width={271}
height={174}
objectFit="cover"
/>
)}
<div className={Styles.card_content}>
<h5 className={Styles.card_heading}>{obj.name}</h5>
{obj.date_time && (
<p className={Styles.talk_timing}>{`${parseDate(
obj.date_time
)} ${parseTime(obj.date_time)}`}</p>
)}
<h6
className={obj.live ? Styles.talk_topic_live : Styles.talk_topic}
>
{obj.talk_topic}
</h6>
<p className={Styles.speaker_bio}>{obj.short_bio}</p>
{obj.live && (
<Link href={obj.confHref}>
<button className={Styles.actionBtn}>Live</button>
</Link>
)}
</div>
</div>
))}
</>
);
}
23 changes: 23 additions & 0 deletions app/lib/dateTime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const parseTime = (myDate) => {
const time = new Date(myDate).toLocaleTimeString("en", {
timeStyle: "short",
hour12: true,
});
return time;
};

export const parseDate = (myDate) => {
let date = new Date(myDate);
let year = date.getFullYear();
let month = date.getMonth() + 1;
let dt = date.getDate();

if (dt < 10) {
dt = "0" + dt;
}
if (month < 10) {
month = "0" + month;
}

return dt + "/" + month + "/" + year;
};
Loading

0 comments on commit d3de9b2

Please sign in to comment.