Skip to content

Commit

Permalink
fixed escaped comma
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyubibrahimi committed May 3, 2024
1 parent e50c466 commit 2a7eaf9
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 34 deletions.
6 changes: 3 additions & 3 deletions packages/web/components/Alerts/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default function AlertSignUp({ onSignUpComplete }: AlertSignUpProps) {
<div className={styles["alert-sign-up"]}>
<form onSubmit={handleSubmit}>
<label htmlFor="email" className={styles["label"]}>
Sign up to receive alerts about new ordinances on first reading at city
council.
Sign up to receive alerts about new ordinances on first reading at
city council.
</label>
<input
ref={emailInputRef}
Expand Down Expand Up @@ -83,4 +83,4 @@ export default function AlertSignUp({ onSignUpComplete }: AlertSignUpProps) {
</form>
</div>
);
}
}
5 changes: 4 additions & 1 deletion packages/web/components/Card/BetaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ const BetaCard = ({ card }: { card: ICard }) => {
{isYouTubeURL(thumbnail?.source_url) && (
<iframe
id="ytplayer"
src={getYouTubeEmbedUrl(thumbnail?.source_url, thumbnail?.source_timestamp)}
src={getYouTubeEmbedUrl(
thumbnail?.source_url,
thumbnail?.source_timestamp
)}
frameBorder="0"
className="h-64 w-full lg:h-96"
></iframe>
Expand Down
15 changes: 11 additions & 4 deletions packages/web/components/Card/Citation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { getYouTubeEmbedUrl, getYouTubeThumbnail, isYouTubeURL } from "@/lib/utils";
import {
getYouTubeEmbedUrl,
getYouTubeThumbnail,
isYouTubeURL,
} from "@/lib/utils";
import moment from "moment";
import "./Citation.css";

Expand All @@ -23,7 +27,8 @@ const Citation = ({
...otherMetadata
} = originalCitation;

const isYoutube = source_url && isYouTubeURL(source_url) && getYouTubeThumbnail(source_url);
const isYoutube =
source_url && isYouTubeURL(source_url) && getYouTubeThumbnail(source_url);
const isUrlAvailable = source_url && source_url !== "url not available";

return (
Expand All @@ -33,7 +38,9 @@ const Citation = ({
}`}
>
<div>
<p className="font-bold lg:text-lg">#{index + 1}: {title}</p>
<p className="font-bold lg:text-lg">
#{index + 1}: {title}
</p>
<p className="text-black">{moment(publishedAt).fromNow()}</p>
</div>

Expand Down Expand Up @@ -75,4 +82,4 @@ const Citation = ({
);
};

export default Citation;
export default Citation;
2 changes: 1 addition & 1 deletion packages/web/components/HomeBanner/HomeBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function HomeBanner() {
<div className="md:grow"></div>
<div className="md:w-3/4 md:max-w-2xl">
<h1 className="text-lg font-bold">
What is New Orleans' City Council doing about
What is New Orleans&apos; City Council doing about
</h1>
<h2 className="mt-3 text-4xl">
<span className="bg-brighter-blue text-secondary">{word}?</span>
Expand Down
62 changes: 38 additions & 24 deletions packages/web/components/HomeResults/QueryResult.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useEffect, useState } from "react";
import { ICard } from "@/lib/api";
import { CARD_SHOW_PATH } from "@/lib/paths";
import { supabase } from "@/lib/supabase/supabaseClient";
import Link from "next/link";
import moment from "moment";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
import { getThumbnail, getYouTubeEmbedUrl, isYouTubeURL } from "@/lib/utils";
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import moment from "moment";
import Link from "next/link";
import { useEffect, useState } from "react";
import CardActions from "../Card/CardActions";
import { ICard } from "@/lib/api";
import { CARD_SHOW_PATH } from "@/lib/paths";
import styles from "./homeresults.module.scss";

const MAX_CHARACTERS_PREVIEW = 20000;
Expand Down Expand Up @@ -45,30 +45,36 @@ export default function QueryResult({ card }: { card: ICard }) {
const [isLoading, setIsLoading] = useState(initialLoadingState);
const [responses, setResponses] = useState(card.responses || []);

const prettyCreatedAt = !!createdAt && new Date(createdAt) < new Date()
? moment(createdAt).fromNow()
: moment().fromNow();
const prettyCreatedAt =
!!createdAt && new Date(createdAt) < new Date()
? moment(createdAt).fromNow()
: moment().fromNow();
const thumbnail = getThumbnail(citations || []);

useEffect(() => {
let intervalId: NodeJS.Timeout | null = null;

if (isLoading) {
intervalId = setInterval(() => {
setMsgIndex(prevIndex => (prevIndex + 1) % LOADING_MESSAGES.length);
setMsgIndex((prevIndex) => (prevIndex + 1) % LOADING_MESSAGES.length);
}, 2500);
}

const channel = supabase.channel(`cards:id=eq.${card.id}`)
.on("postgres_changes", { event: "UPDATE", schema: "public" }, (payload) => {
if (payload.new.id === card.id && payload.new.responses) {
const newResponses = payload.new.responses;
if (JSON.stringify(newResponses) !== JSON.stringify(responses)) {
setResponses(newResponses);
setIsLoading(false);
const channel = supabase
.channel(`cards:id=eq.${card.id}`)
.on(
"postgres_changes",
{ event: "UPDATE", schema: "public" },
(payload) => {
if (payload.new.id === card.id && payload.new.responses) {
const newResponses = payload.new.responses;
if (JSON.stringify(newResponses) !== JSON.stringify(responses)) {
setResponses(newResponses);
setIsLoading(false);
}
}
}
})
)
.subscribe();

return () => {
Expand All @@ -77,8 +83,9 @@ export default function QueryResult({ card }: { card: ICard }) {
};
}, [card.id, isLoading, responses]);

const combinedResponses = responses.map(r => r.response).join(" ");
const previewText = combinedResponses.split(" ").slice(0, 100).join(" ") + "...";
const combinedResponses = responses.map((r) => r.response).join(" ");
const previewText =
combinedResponses.split(" ").slice(0, 100).join(" ") + "...";

const CardBody = () => (
<Link href={`${CARD_SHOW_PATH}/${card.id}`}>
Expand All @@ -96,7 +103,10 @@ export default function QueryResult({ card }: { card: ICard }) {
{isYouTubeURL(thumbnail?.source_url) && (
<iframe
id="ytplayer"
src={getYouTubeEmbedUrl(thumbnail?.source_url, thumbnail?.source_timestamp)}
src={getYouTubeEmbedUrl(
thumbnail?.source_url,
thumbnail?.source_timestamp
)}
frameBorder="0"
className="h-64 w-full lg:h-96"
></iframe>
Expand All @@ -117,10 +127,14 @@ export default function QueryResult({ card }: { card: ICard }) {

return (
<div id={isLoading ? "loading" : "loaded"} className={styles.card}>
<div className={`my-6 space-y-4 rounded-lg bg-blue p-6 text-primary ${isLoading ? "border-4 border-dashed border-yellow-500" : ""}`}>
<div
className={`my-6 space-y-4 rounded-lg bg-blue p-6 text-primary ${
isLoading ? "border-4 border-dashed border-yellow-500" : ""
}`}
>
<CardBody />
<CardActions card={card} />
</div>
</div>
);
}
}
2 changes: 1 addition & 1 deletion packages/web/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ export function getYouTubeEmbedUrl(
}

return `https://www.youtube.com/embed/${videoId}?autoplay=0&start=${startTime}`;
}
}

0 comments on commit 2a7eaf9

Please sign in to comment.