@@ -12,4 +12,4 @@ const Charts = () => {
);
};
-export default Charts;
+export default Charts;
\ No newline at end of file
From 2cae62dab2a843c966a4590956a3580a805a28db Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:21:57 +0000
Subject: [PATCH 092/141] change_file_extension
# Commit trail:
-> 1a51368a6a75a53edc6525466261de071b630a4e: edit_file
---
frontend/components/Charts/{Charts.jsx => Charts.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Charts/{Charts.jsx => Charts.tsx} (100%)
diff --git a/frontend/components/Charts/Charts.jsx b/frontend/components/Charts/Charts.tsx
similarity index 100%
rename from frontend/components/Charts/Charts.jsx
rename to frontend/components/Charts/Charts.tsx
From 992452c915d4bbebe12d354077cc4d31c7fef70d Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:21:58 +0000
Subject: [PATCH 093/141] edit_file
---
.../Index/Sort/Gain/Select/Select.jsx | 329 +++++++++---------
1 file changed, 157 insertions(+), 172 deletions(-)
diff --git a/frontend/components/Index/Sort/Gain/Select/Select.jsx b/frontend/components/Index/Sort/Gain/Select/Select.jsx
index fb23c654..2d2488e7 100644
--- a/frontend/components/Index/Sort/Gain/Select/Select.jsx
+++ b/frontend/components/Index/Sort/Gain/Select/Select.jsx
@@ -1,172 +1,157 @@
-import styles from "./Select.module.css";
-import { useState, useEffect } from "react";
-
-import useSWR from "swr";
-import axios from "axios";
-
-import { useDispatch, useSelector } from "react-redux";
-import {
- addHeader,
- updateStocks,
- selectCik,
- selectHeaders,
- removeHeader,
- editHeader,
-} from "@/redux/filerSlice";
-
-import { useSortable } from "@dnd-kit/sortable";
-import { CSS } from "@dnd-kit/utilities";
-
-import { font } from "@fonts";
-
-import Picker from "./Picker/Picker";
-import Loading from "components/Loading/Loading";
-
-// const animateLayoutChanges = (args) => {
-// const { isSorting, wasSorting } = args;
-
-// if (isSorting || wasSorting) {
-// return defaultAnimateLayoutChanges(args);
-// }
-
-// return true;
-// };
-
-const server = process.env.NEXT_PUBLIC_SERVER;
-const getFetcher = (url, cik, time) =>
- axios
- .get(url, { params: { cik: cik, time: time } })
- .then((r) => r.data)
- .catch((e) => console.error(e));
-
-const Select = (props) => {
- const propDate = props.date;
- const accessor = propDate.accessor;
- const index = props.index;
- const dispatch = useDispatch();
- const cik = useSelector(selectCik) || false;
- const headers = useSelector(selectHeaders);
-
- const date =
- useSelector((state) =>
- state.filer.dates.find((d) => d.accessor == propDate.accessor)
- ) || propDate;
- const open = date.open;
- const time = date.timestamp;
- const {
- data,
- error,
- isLoading: loading,
- } = useSWR(
- open || cik === false ? null : [server + "/stocks/timeseries", cik, time],
- ([url, cik, time]) => getFetcher(url, cik, time),
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- useEffect(() => {
- if (open) return;
-
- if (data) {
- const timeseries = {};
- data.stocks.forEach((price) => {
- const close = price.close_str;
- const cusip = price.cusip;
- timeseries[cusip] = close;
- });
-
- dispatch(
- updateStocks({
- field: accessor,
- values: timeseries,
- })
- );
- const display = `${date.month}/${date.day}/${date.year}`;
- dispatch(editHeader({ accessor: accessor, display: display }));
- }
- }, [open, data, accessor, dispatch, date]);
-
- const {
- attributes,
- listeners,
- setNodeRef,
- transform,
- transition,
- isDragging,
- } = useSortable({ id: accessor });
- const style = {
- transform: CSS.Transform.toString(transform),
- transition,
- opacity: isDragging ? 0.5 : 1,
- };
-
- const active = headers.find((h) => h.accessor == accessor) ? false : true;
- const handleTable = () => {
- const header = headers.find((h) => h.accessor == accessor);
-
- const display = `${date.month + 1}/${date.day}/${date.year}`;
- const tooltip = `The prices of the stocks at ${date.month + 1}/${
- date.day
- }/${date.year}.`;
- if (header) {
- dispatch(removeHeader(accessor));
- } else {
- dispatch(
- addHeader({
- display,
- sort: accessor,
- tooltip,
- accessor: accessor,
- active: true,
- })
- );
- }
- };
-
- const handleDownload = () => {
- window.open(
- server +
- "/filers/record/timeseries/?" +
- new URLSearchParams({ cik, time }),
- "_blank"
- );
- };
-
- if (error) {
- console.error(e);
- }
-
- return (
-
- {loading ?
: null}
-
-
handleTable()}
- >
- Table
-
-
handleDownload()}
- >
- Download
-
-
- );
-};
-
-export default Select;
+
+import styles from "./Select.module.css";
+import { useState, useEffect } from "react";
+import useSWR from "swr";
+import axios from "axios";
+import { useDispatch, useSelector } from "react-redux";
+import {
+ addHeader,
+ updateStocks,
+ selectCik,
+ selectHeaders,
+ removeHeader,
+ editHeader,
+} from "@/redux/filerSlice";
+import { useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import { font } from "@fonts";
+import Picker from "./Picker/Picker";
+import Loading from "components/Loading/Loading";
+const server = process.env.NEXT_PUBLIC_SERVER;
+const getFetcher = (url: string, cik: string, time: number) =>
+ axios
+ .get(url, { params: { cik: cik, time: time } })
+ .then((r) => r.data)
+ .catch((e) => console.error(e));
+interface SelectProps {
+ date: {
+ accessor: string;
+ open: boolean;
+ timestamp: number;
+ month: number;
+ day: number;
+ year: number;
+ };
+ index: number;
+}
+const Select: React.FC
= (props) => {
+ const propDate = props.date;
+ const accessor = propDate.accessor;
+ const index = props.index;
+ const dispatch = useDispatch();
+ const cik = useSelector(selectCik) || false;
+ const headers = useSelector(selectHeaders);
+ const date =
+ useSelector((state: any) =>
+ state.filer.dates.find((d: any) => d.accessor == propDate.accessor)
+ ) || propDate;
+ const open = date.open;
+ const time = date.timestamp;
+ const {
+ data,
+ error,
+ isLoading: loading,
+ } = useSWR(
+ open || cik === false ? null : [server + "/stocks/timeseries", cik, time],
+ ([url, cik, time]) => getFetcher(url, cik, time),
+ {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ }
+ );
+ useEffect(() => {
+ if (open) return;
+ if (data) {
+ const timeseries: { [key: string]: string } = {};
+ data.stocks.forEach((price: { close_str: string; cusip: string }) => {
+ const close = price.close_str;
+ const cusip = price.cusip;
+ timeseries[cusip] = close;
+ });
+ dispatch(
+ updateStocks({
+ field: accessor,
+ values: timeseries,
+ })
+ );
+ const display = `${date.month}/${date.day}/${date.year}`;
+ dispatch(editHeader({ accessor: accessor, display: display }));
+ }
+ }, [open, data, accessor, dispatch, date]);
+ const {
+ attributes,
+ listeners,
+ setNodeRef,
+ transform,
+ transition,
+ isDragging,
+ } = useSortable({ id: accessor });
+ const style = {
+ transform: CSS.Transform.toString(transform),
+ transition,
+ opacity: isDragging ? 0.5 : 1,
+ };
+ const active = headers.find((h: any) => h.accessor == accessor) ? false : true;
+ const handleTable = () => {
+ const header = headers.find((h: any) => h.accessor == accessor);
+ const display = `${date.month + 1}/${date.day}/${date.year}`;
+ const tooltip = `The prices of the stocks at ${date.month + 1}/${
+ date.day
+ }/${date.year}.`;
+ if (header) {
+ dispatch(removeHeader(accessor));
+ } else {
+ dispatch(
+ addHeader({
+ display,
+ sort: accessor,
+ tooltip,
+ accessor: accessor,
+ active: true,
+ })
+ );
+ }
+ };
+ const handleDownload = () => {
+ window.open(
+ server +
+ "/filers/record/timeseries/?" +
+ new URLSearchParams({ cik, time }),
+ "_blank"
+ );
+ };
+ if (error) {
+ console.error(error);
+ }
+ return (
+
+ {loading ?
: null}
+
+
handleTable()}
+ >
+ Table
+
+
handleDownload()}
+ >
+ Download
+
+
+ );
+};
+export default Select;
From 1e9ba091b3c90431e91458f551f2815d6daa14e1 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:21:59 +0000
Subject: [PATCH 094/141] change_file_extension
# Commit trail:
-> 992452c915d4bbebe12d354077cc4d31c7fef70d: edit_file
---
.../components/Index/Sort/Gain/Select/{Select.jsx => Select.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Index/Sort/Gain/Select/{Select.jsx => Select.tsx} (100%)
diff --git a/frontend/components/Index/Sort/Gain/Select/Select.jsx b/frontend/components/Index/Sort/Gain/Select/Select.tsx
similarity index 100%
rename from frontend/components/Index/Sort/Gain/Select/Select.jsx
rename to frontend/components/Index/Sort/Gain/Select/Select.tsx
From 1fb14b47dddba982e6c3d384f09cf57f09563df8 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:00 +0000
Subject: [PATCH 095/141] edit_file
---
.../Index/Sort/Gain/Select/Picker/Picker.jsx | 357 +++++++++---------
1 file changed, 183 insertions(+), 174 deletions(-)
diff --git a/frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx b/frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx
index 5a23cced..0cec4553 100644
--- a/frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx
+++ b/frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx
@@ -1,174 +1,183 @@
-import styles from "./Picker.module.css";
-import { useState, useEffect } from "react";
-
-import { font } from "@fonts";
-
-import { editDate, openDate } from "@/redux/filerSlice";
-import { useDispatch } from "react-redux";
-
-import CalendarSVG from "./calendar.svg";
-import RightSVG from "./right.svg";
-import LeftSVG from "./left.svg";
-
-const months = [
- { name: "Jan", value: 0 },
- { name: "Feb", value: 1 },
- { name: "Mar", value: 2 },
- { name: "Apr", value: 3 },
- { name: "May", value: 4 },
- { name: "Jun", value: 5 },
- { name: "Jul", value: 6 },
- { name: "Aug", value: 7 },
- { name: "Sep", value: 8 },
- { name: "Oct", value: 9 },
- { name: "Nov", value: 10 },
- { name: "Dec", value: 11 },
-];
-
-const yearRegex = /^-?\d+$/;
-
-const Picker = (props) => {
- const date = props.date || {};
- const year = date.year;
- const open = date.open;
- const dispatch = useDispatch();
-
- const handleDateChange = (e) => {
- const value = e.slice(0, -1);
- const character = e.slice(-1);
-
- let newValue = value;
- if (value.length >= 4) {
- newValue = value.slice(1);
- }
-
- if (yearRegex.test(character)) {
- newValue = newValue + character;
- }
-
- setDateDisplay(newValue);
- };
- const handleBlur = () => {
- setFocus(false);
- if (
- dateDisplay.length === 4 &&
- yearRegex.test(dateDisplay) &&
- dateDisplay > 1899 &&
- dateDisplay < 2100
- ) {
- dispatch(
- editDate({
- type: "year",
- accessor: date.accessor,
- value: dateDisplay,
- })
- );
- }
- };
-
- const [dateDisplay, setDateDisplay] = useState(year);
- const [focus, setFocus] = useState(false);
- useEffect(() => {
- setDateDisplay(year);
- }, [year]);
-
- const month = months[date.month] || months[0];
- const display = `${month.name} ${year}`;
-
- return (
-
-
- dispatch(openDate({ accessor: date.accessor, open: !open }))
- }
- className={styles["date"]}
- >
-
- {display}
-
-
-
-
-
-
- dispatch(
- editDate({
- type: "year",
- accessor: date.accessor,
- value: year - 1,
- })
- )
- }
- >
-
-
- handleDateChange(e.target.value)}
- onFocus={() => setFocus(true)}
- onBlur={() => handleBlur()}
- onKeyDown={(e) => (e.key === "Enter" ? e.target.blur() : null)}
- />
-
- dispatch(
- editDate({
- type: "year",
- accessor: date.accessor,
- value: year + 1,
- })
- )
- }
- >
-
-
-
-
- {months.map((month) => (
-
- dispatch(
- editDate({
- type: "month",
- value: month.value,
- accessor: date.accessor,
- })
- )
- }
- className={[
- styles["month"],
- month.value == date.month ? styles["month-selected"] : "",
- ].join(" ")}
- >
- {month.name}
-
- ))}
-
-
-
- );
-};
-
-export default Picker;
+import styles from "./Picker.module.css";
+import { useState, useEffect, ChangeEvent, FocusEvent, KeyboardEvent } from "react";
+import { font } from "@fonts";
+import { editDate, openDate } from "@/redux/filerSlice";
+import { useDispatch } from "react-redux";
+import CalendarSVG from "./calendar.svg";
+import RightSVG from "./right.svg";
+import LeftSVG from "./left.svg";
+
+interface DateProps {
+ year: number;
+ month: number;
+ open: boolean;
+ accessor: string;
+}
+
+interface PickerProps {
+ date: DateProps;
+}
+
+const months = [
+ { name: "Jan", value: 0 },
+ { name: "Feb", value: 1 },
+ { name: "Mar", value: 2 },
+ { name: "Apr", value: 3 },
+ { name: "May", value: 4 },
+ { name: "Jun", value: 5 },
+ { name: "Jul", value: 6 },
+ { name: "Aug", value: 7 },
+ { name: "Sep", value: 8 },
+ { name: "Oct", value: 9 },
+ { name: "Nov", value: 10 },
+ { name: "Dec", value: 11 },
+];
+
+const yearRegex = /^-?\d+$/;
+
+const Picker: React.FC = (props) => {
+ const date = props.date || {} as DateProps;
+ const year = date.year;
+ const open = date.open;
+ const dispatch = useDispatch();
+
+ const handleDateChange = (e: string) => {
+ const value = e.slice(0, -1);
+ const character = e.slice(-1);
+
+ let newValue = value;
+ if (value.length >= 4) {
+ newValue = value.slice(1);
+ }
+
+ if (yearRegex.test(character)) {
+ newValue = newValue + character;
+ }
+
+ setDateDisplay(newValue);
+ };
+
+ const handleBlur = () => {
+ setFocus(false);
+ if (
+ dateDisplay.length === 4 &&
+ yearRegex.test(dateDisplay) &&
+ parseInt(dateDisplay) > 1899 &&
+ parseInt(dateDisplay) < 2100
+ ) {
+ dispatch(
+ editDate({
+ type: "year",
+ accessor: date.accessor,
+ value: parseInt(dateDisplay),
+ })
+ );
+ }
+ };
+
+ const [dateDisplay, setDateDisplay] = useState(year.toString());
+ const [focus, setFocus] = useState(false);
+ useEffect(() => {
+ setDateDisplay(year.toString());
+ }, [year]);
+
+ const month = months[date.month] || months[0];
+ const display = `${month.name} ${year}`;
+
+ return (
+
+
+ dispatch(openDate({ accessor: date.accessor, open: !open }))
+ }
+ className={styles["date"]}
+ >
+
+ {display}
+
+
+
+
+
+
+ dispatch(
+ editDate({
+ type: "year",
+ accessor: date.accessor,
+ value: year - 1,
+ })
+ )
+ }
+ >
+
+
+ ) => handleDateChange(e.target.value)}
+ onFocus={() => setFocus(true)}
+ onBlur={(e: FocusEvent) => handleBlur()}
+ onKeyDown={(e: KeyboardEvent) => (e.key === "Enter" ? e.currentTarget.blur() : null)}
+ />
+
+ dispatch(
+ editDate({
+ type: "year",
+ accessor: date.accessor,
+ value: year + 1,
+ })
+ )
+ }
+ >
+
+
+
+
+ {months.map((month) => (
+
+ dispatch(
+ editDate({
+ type: "month",
+ value: month.value,
+ accessor: date.accessor,
+ })
+ )
+ }
+ className={[
+ styles["month"],
+ month.value == date.month ? styles["month-selected"] : "",
+ ].join(" ")}
+ >
+ {month.name}
+
+ ))}
+
+
+
+ );
+};
+
+export default Picker;
\ No newline at end of file
From 3ca2dfab7bebece08394047c3c7df16ae520ee8d Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:01 +0000
Subject: [PATCH 096/141] change_file_extension
# Commit trail:
-> 1fb14b47dddba982e6c3d384f09cf57f09563df8: edit_file
---
.../Index/Sort/Gain/Select/Picker/{Picker.jsx => Picker.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Index/Sort/Gain/Select/Picker/{Picker.jsx => Picker.tsx} (100%)
diff --git a/frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx b/frontend/components/Index/Sort/Gain/Select/Picker/Picker.tsx
similarity index 100%
rename from frontend/components/Index/Sort/Gain/Select/Picker/Picker.jsx
rename to frontend/components/Index/Sort/Gain/Select/Picker/Picker.tsx
From 724f3d4146097f65e864552481d398454410b195 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:03 +0000
Subject: [PATCH 097/141] edit_file
---
frontend/components/Navigation/Navigation.jsx | 147 ++++++++++--------
1 file changed, 79 insertions(+), 68 deletions(-)
diff --git a/frontend/components/Navigation/Navigation.jsx b/frontend/components/Navigation/Navigation.jsx
index ac6c06af..58cfb6fa 100644
--- a/frontend/components/Navigation/Navigation.jsx
+++ b/frontend/components/Navigation/Navigation.jsx
@@ -1,68 +1,79 @@
-import styles from "./Navigation.module.css";
-
-import Link from "next/link";
-import { font } from "@fonts";
-
-import Search from "components/Search/Button/Search";
-import Bar from "components/Bar/Bar";
-
-const Item = ({ link, text, tab }) => (
-
-
- {text}
-
-
-);
-
-const server = process.env.NEXT_PUBLIC_SERVER;
-const Navigation = (props) => {
- const variant = props.variant || null;
- return (
- <>
-
-
-
-
-
-
- wallstreet
-
-
- {" "}
- local
-
-
-
- {variant === "home" ? null :
}
-
-
-
- >
- );
-};
-
-export default Navigation;
+import styles from "./Navigation.module.css";
+
+import Link from "next/link";
+import { font } from "@fonts";
+
+import Search from "components/Search/Button/Search";
+import Bar from "components/Bar/Bar";
+
+interface ItemProps {
+ link: string;
+ text: string;
+ tab?: boolean;
+}
+
+const Item: React.FC = ({ link, text, tab }) => (
+
+
+ {text}
+
+
+);
+
+const server = process.env.NEXT_PUBLIC_SERVER;
+
+interface NavigationProps {
+ variant?: "home" | string;
+}
+
+const Navigation: React.FC = (props) => {
+ const variant = props.variant || null;
+ return (
+ <>
+
+
+
+
+
+
+ wallstreet
+
+
+ {" "}
+ local
+
+
+
+ {variant === "home" ? null :
}
+
+
+
+ >
+ );
+};
+
+export default Navigation;
\ No newline at end of file
From 316d77548ff8fa979693c81f497f5168dbf9d689 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:04 +0000
Subject: [PATCH 098/141] change_file_extension
# Commit trail:
-> 724f3d4146097f65e864552481d398454410b195: edit_file
---
frontend/components/Navigation/{Navigation.jsx => Navigation.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Navigation/{Navigation.jsx => Navigation.tsx} (100%)
diff --git a/frontend/components/Navigation/Navigation.jsx b/frontend/components/Navigation/Navigation.tsx
similarity index 100%
rename from frontend/components/Navigation/Navigation.jsx
rename to frontend/components/Navigation/Navigation.tsx
From 4c3fd90db957789ff28f954599e9770d6fa54987 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:05 +0000
Subject: [PATCH 099/141] edit_file
---
.../components/Explorer/Timeline/Timeline.jsx | 23 ++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/frontend/components/Explorer/Timeline/Timeline.jsx b/frontend/components/Explorer/Timeline/Timeline.jsx
index 9315619a..fb3dba74 100644
--- a/frontend/components/Explorer/Timeline/Timeline.jsx
+++ b/frontend/components/Explorer/Timeline/Timeline.jsx
@@ -1,26 +1,25 @@
import styles from "./Timeline.module.css";
import { useState } from "react";
-
import { useDispatch, useSelector } from "react-redux";
import { selectTimeline, setOpen } from "@/redux/filerSlice";
-
import { font, fontLight } from "@fonts";
-
import Analysis from "components/Analysis/Analysis";
import Tip from "components/Tip/Tip";
import Difference from "./Difference/Difference";
import Select from "./Select/Select";
-
-const Timeline = () => {
+import React from "react";
+interface Description {
+ title: string;
+ text: string;
+}
+const Timeline: React.FC = () => {
const dispatch = useDispatch();
const timeline = useSelector(selectTimeline);
-
const open = timeline.open;
- const [description, setDescription] = useState({
+ const [description, setDescription] = useState({
title: "",
text: "",
});
-
return (
@@ -35,16 +34,15 @@ const Timeline = () => {
{description.text}
-
setDescription(desc)}
+ setDescription={(desc: Description) => setDescription(desc)}
/>
{/* setDescription(desc)} /> */}
setDescription(desc)}
+ setDescription={(desc: Description) => setDescription(desc)}
/>
{
);
};
-
-export default Timeline;
+export default Timeline;
\ No newline at end of file
From a6d0a4971b1f7fc6f6b713bea2ae791033bc3e13 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:06 +0000
Subject: [PATCH 100/141] change_file_extension
# Commit trail:
-> 4c3fd90db957789ff28f954599e9770d6fa54987: edit_file
---
.../components/Explorer/Timeline/{Timeline.jsx => Timeline.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/Timeline/{Timeline.jsx => Timeline.tsx} (100%)
diff --git a/frontend/components/Explorer/Timeline/Timeline.jsx b/frontend/components/Explorer/Timeline/Timeline.tsx
similarity index 100%
rename from frontend/components/Explorer/Timeline/Timeline.jsx
rename to frontend/components/Explorer/Timeline/Timeline.tsx
From dd7f2aac977096a1d97aebad2b907ae37ff91bf9 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:14 +0000
Subject: [PATCH 101/141] edit_file
---
.../Timeline/Difference/Difference.jsx | 31 +++++++++++++++----
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/frontend/components/Explorer/Timeline/Difference/Difference.jsx b/frontend/components/Explorer/Timeline/Difference/Difference.jsx
index c7d95937..bce9bd8a 100644
--- a/frontend/components/Explorer/Timeline/Difference/Difference.jsx
+++ b/frontend/components/Explorer/Timeline/Difference/Difference.jsx
@@ -15,14 +15,33 @@ import { font, fontLight } from "components/fonts";
import Headers from "components/Headers/Headers";
import Record from "../Select/Record/Record";
-const Difference = (props) => {
+interface DifferenceProps {
+ setDescription: (description: string) => void;
+}
+
+interface Header {
+ accessor: string;
+ active: boolean;
+}
+
+interface Sort {
+ sold: boolean;
+ na: boolean;
+}
+
+interface DifferenceState {
+ headers: Header[];
+ sort: Sort;
+}
+
+const Difference: React.FC = (props) => {
const dispatch = useDispatch();
- const difference = useSelector(selectDifference);
+ const difference: DifferenceState = useSelector(selectDifference);
const headers = difference.headers;
- const updateHeaders = (h) => dispatch(editDifference({ headers: h }));
- const updateDescription = (d) => props.setDescription(d);
- const updateActivation = (a) =>
+ const updateHeaders = (h: Header[]) => dispatch(editDifference({ headers: h }));
+ const updateDescription = (d: string) => props.setDescription(d);
+ const updateActivation = (a: string) =>
dispatch(
editDifference({
headers: headers.map((h) =>
@@ -73,4 +92,4 @@ const Difference = (props) => {
);
};
-export default Difference;
+export default Difference;
\ No newline at end of file
From b416af1a45ab02cb7fa1610cd4a7a441f904b06f Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:15 +0000
Subject: [PATCH 102/141] change_file_extension
# Commit trail:
-> dd7f2aac977096a1d97aebad2b907ae37ff91bf9: edit_file
---
.../Timeline/Difference/{Difference.jsx => Difference.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/Timeline/Difference/{Difference.jsx => Difference.tsx} (100%)
diff --git a/frontend/components/Explorer/Timeline/Difference/Difference.jsx b/frontend/components/Explorer/Timeline/Difference/Difference.tsx
similarity index 100%
rename from frontend/components/Explorer/Timeline/Difference/Difference.jsx
rename to frontend/components/Explorer/Timeline/Difference/Difference.tsx
From 63bd435de7e16555bb56769d5964eba8d098eaee Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:16 +0000
Subject: [PATCH 103/141] edit_file
---
.../Explorer/Timeline/Select/Record/Record.jsx | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/frontend/components/Explorer/Timeline/Select/Record/Record.jsx b/frontend/components/Explorer/Timeline/Select/Record/Record.jsx
index cb053d39..da704968 100644
--- a/frontend/components/Explorer/Timeline/Select/Record/Record.jsx
+++ b/frontend/components/Explorer/Timeline/Select/Record/Record.jsx
@@ -9,7 +9,14 @@ import DataIcon from "@/public/static/data.svg";
import TableIcon from "@/public/static/csv.svg";
const server = process.env.NEXT_PUBLIC_SERVER;
-const Record = (props) => {
+
+type Props = {
+ variant?: "json" | "csv";
+ selected: { access: string };
+ headers?: { tooltip: string; [key: string]: any }[];
+};
+
+const Record: React.FC = (props) => {
const cik = useSelector(selectCik);
const variant = props.variant || "json";
const selected = props.selected;
@@ -23,6 +30,7 @@ const Record = (props) => {
"_blank"
);
};
+
const handleCSVDownload = () => {
window.open(
server +
@@ -30,11 +38,12 @@ const Record = (props) => {
new URLSearchParams({
cik,
access_number: selected.access,
- headers: JSON.stringify(headers.map(({ tooltip, ...rest }) => rest)),
+ headers: JSON.stringify(headers?.map(({ tooltip, ...rest }) => rest)),
}),
"_blank"
);
};
+
return (
{
);
};
-export default Record;
+export default Record;
\ No newline at end of file
From f7e0004dbeba6119eca5d1494a831e987215fe0e Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:17 +0000
Subject: [PATCH 104/141] change_file_extension
# Commit trail:
-> 63bd435de7e16555bb56769d5964eba8d098eaee: edit_file
---
.../Explorer/Timeline/Select/Record/{Record.jsx => Record.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/Timeline/Select/Record/{Record.jsx => Record.tsx} (100%)
diff --git a/frontend/components/Explorer/Timeline/Select/Record/Record.jsx b/frontend/components/Explorer/Timeline/Select/Record/Record.tsx
similarity index 100%
rename from frontend/components/Explorer/Timeline/Select/Record/Record.jsx
rename to frontend/components/Explorer/Timeline/Select/Record/Record.tsx
From 1255ee082cea3fed15749a8c038a32bf4d5f730d Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:18 +0000
Subject: [PATCH 105/141] edit_file
---
.../components/Recommended/Recommended.jsx | 51 +++++++++++--------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/frontend/components/Recommended/Recommended.jsx b/frontend/components/Recommended/Recommended.jsx
index 5c275ba3..3c1e5cf9 100644
--- a/frontend/components/Recommended/Recommended.jsx
+++ b/frontend/components/Recommended/Recommended.jsx
@@ -1,43 +1,51 @@
import styles from "./Recommended.module.css";
import { useEffect, useState } from "react";
-
import axios from "axios";
-
import Link from "next/link";
-
import { font } from "@fonts";
-
import { convertTitle } from "components/Filer/Info";
const server = process.env.NEXT_PUBLIC_SERVER;
-const Recommended = (props) => {
+
+interface Filer {
+ cik: string;
+ name: string;
+ title?: string;
+}
+
+interface RecommendedProps {
+ variant?: "default" | "homepage";
+ className?: string;
+}
+
+const Recommended: React.FC = (props) => {
const variant = props.variant || "default";
const [show, setShow] = useState(false);
- const [topFilers, setTopFilers] = useState([]);
- const [searchedFilers, setSearchedFilers] = useState([]);
+ const [topFilers, setTopFilers] = useState([]);
+ const [searchedFilers, setSearchedFilers] = useState([]);
+
useEffect(() => {
- topFilers == []
+ topFilers.length === 0
? null
: axios
.get(server + "/filers/top")
.then((r) => r.data)
- .then((data) => setTopFilers(data.filers || null));
- searchedFilers == []
+ .then((data) => setTopFilers(data.filers || []));
+
+ searchedFilers.length === 0
? null
: axios
.get(server + "/filers/searched")
.then((r) => r.data)
- .then((data) => setSearchedFilers(data.filers || null));
+ .then((data) => setSearchedFilers(data.filers || []));
- window.addEventListener(
- "scroll",
- () => {
- setShow(true);
- },
- true
- );
- return () => window.removeEventListener("scroll", () => {}, true);
- }, []);
+ const handleScroll = () => {
+ setShow(true);
+ };
+
+ window.addEventListener("scroll", handleScroll, true);
+ return () => window.removeEventListener("scroll", handleScroll, true);
+ }, [topFilers, searchedFilers]);
return (
{
);
};
-export default Recommended;
+
+export default Recommended;
\ No newline at end of file
From 5eb9bcb7be1c458f5340b245255d6694e4c0c388 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:19 +0000
Subject: [PATCH 106/141] change_file_extension
# Commit trail:
-> 1255ee082cea3fed15749a8c038a32bf4d5f730d: edit_file
---
.../components/Recommended/{Recommended.jsx => Recommended.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Recommended/{Recommended.jsx => Recommended.tsx} (100%)
diff --git a/frontend/components/Recommended/Recommended.jsx b/frontend/components/Recommended/Recommended.tsx
similarity index 100%
rename from frontend/components/Recommended/Recommended.jsx
rename to frontend/components/Recommended/Recommended.tsx
From 35c781cbf95ef9f16671299d79b48761090e04bf Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:24 +0000
Subject: [PATCH 107/141] edit_file
---
frontend/components/Tip/Tip.jsx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/frontend/components/Tip/Tip.jsx b/frontend/components/Tip/Tip.jsx
index 398644cc..be0e3678 100644
--- a/frontend/components/Tip/Tip.jsx
+++ b/frontend/components/Tip/Tip.jsx
@@ -2,7 +2,12 @@ import styles from "./Tip.module.css";
import { fontLight } from "@fonts";
-const Tip = (props) => {
+interface TipProps {
+ top?: number | null;
+ text: string;
+}
+
+const Tip: React.FC = (props) => {
const top = props.top || null;
return (
{
);
};
-export default Tip;
+export default Tip;
\ No newline at end of file
From c846a05a0c5602966ea1f4fcb28985357b2e28e9 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:25 +0000
Subject: [PATCH 108/141] change_file_extension
# Commit trail:
-> 35c781cbf95ef9f16671299d79b48761090e04bf: edit_file
---
frontend/components/Tip/{Tip.jsx => Tip.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Tip/{Tip.jsx => Tip.tsx} (100%)
diff --git a/frontend/components/Tip/Tip.jsx b/frontend/components/Tip/Tip.tsx
similarity index 100%
rename from frontend/components/Tip/Tip.jsx
rename to frontend/components/Tip/Tip.tsx
From 323a7e929c4acca6f4930eca9c0633dde0a7b013 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:26 +0000
Subject: [PATCH 109/141] edit_file
---
.../Charts/Allocation/Allocation.jsx | 25 ++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/frontend/components/Charts/Allocation/Allocation.jsx b/frontend/components/Charts/Allocation/Allocation.jsx
index e898b923..126b00de 100644
--- a/frontend/components/Charts/Allocation/Allocation.jsx
+++ b/frontend/components/Charts/Allocation/Allocation.jsx
@@ -25,7 +25,7 @@ const tooltipStyles = {
const data = cityTemperature.slice(0, 12);
const keys = Object.keys(data[0]).filter((d) => d !== "date");
-const temperatureTotals = data.reduce((allTotals, currentDate) => {
+const temperatureTotals = data.reduce((allTotals: number[], currentDate: any) => {
const totalTemperature = keys.reduce((dailyTotal, k) => {
dailyTotal += Number(currentDate[k]);
return dailyTotal;
@@ -36,28 +36,35 @@ const temperatureTotals = data.reduce((allTotals, currentDate) => {
const parseDate = timeParse("%Y-%m-%d");
const format = timeFormat("%b %d");
-const formatDate = (date) => format(parseDate(date));
+const formatDate = (date: string) => format(parseDate(date) as Date);
// accessors
-const getDate = (d) => d.date;
+const getDate = (d: any) => d.date;
// scales
-const dateScale = scaleBand({
+const dateScale = scaleBand({
domain: data.map(getDate),
padding: 0.2,
});
-const temperatureScale = scaleLinear({
+const temperatureScale = scaleLinear({
domain: [0, Math.max(...temperatureTotals)],
nice: true,
});
-const colorScale = scaleOrdinal({
+const colorScale = scaleOrdinal({
domain: keys,
range: [purple1, purple2, purple3],
});
-let tooltipTimeout;
+let tooltipTimeout: number;
-const Allocation = ({
+interface AllocationProps {
+ width: number;
+ height: number;
+ events?: boolean;
+ margin?: { top: number; right: number; bottom: number; left: number };
+}
+
+const Allocation: React.FC = ({
width,
height,
events = false,
@@ -205,4 +212,4 @@ const Allocation = ({
);
};
-export default Allocation;
+export default Allocation;
\ No newline at end of file
From afbac455bf390f727e57ba1454ec6d162c4bf2a6 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:27 +0000
Subject: [PATCH 110/141] change_file_extension
# Commit trail:
-> 323a7e929c4acca6f4930eca9c0633dde0a7b013: edit_file
---
.../Charts/Allocation/{Allocation.jsx => Allocation.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Charts/Allocation/{Allocation.jsx => Allocation.tsx} (100%)
diff --git a/frontend/components/Charts/Allocation/Allocation.jsx b/frontend/components/Charts/Allocation/Allocation.tsx
similarity index 100%
rename from frontend/components/Charts/Allocation/Allocation.jsx
rename to frontend/components/Charts/Allocation/Allocation.tsx
From 9556fc04b7bcab0f1be7c82c3f51bcab9772cd06 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:28 +0000
Subject: [PATCH 111/141] edit_file
---
frontend/components/Explorer/Explorer.jsx | 35 +++++++++++++----------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/frontend/components/Explorer/Explorer.jsx b/frontend/components/Explorer/Explorer.jsx
index 39223e0c..5fb77f1c 100644
--- a/frontend/components/Explorer/Explorer.jsx
+++ b/frontend/components/Explorer/Explorer.jsx
@@ -23,23 +23,28 @@ import Table from "components/Table/Table";
import Unavailable from "components/Unavailable/Unavailable";
import Timeline from "./Timeline/Timeline";
-const server = process.env.NEXT_PUBLIC_SERVER;
+const server: string | undefined = process.env.NEXT_PUBLIC_SERVER;
-// Most janky code I've ever written. Really, just the worst.
-// I made some mistakes in the infastructure making the stocks table,
-// and now as I repeat the code here, the same mistakes are amplifed
-// greatly. Way too much repitition, partly my own fault, but
-// (I think) mostly due to React's at times terrible data fetching
-// system(s). Libraries help at first, then make it worse later.
-// TLDR: Fix later.
+interface Filing {
+ access_number: string;
+}
-const Explorer = () => {
+interface FilingData {
+ filings: Filing[];
+}
+
+interface Comparison {
+ type: "primary" | "secondary";
+ access: string;
+}
+
+const Explorer: React.FC = () => {
const dispatch = useDispatch();
const cik = useSelector(selectCik);
const primary = useSelector(selectPrimary);
const secondary = useSelector(selectSecondary);
- const filingFetcher = (url, cik) =>
+ const filingFetcher = (url: string, cik: string) =>
axios
.get(url, {
params: {
@@ -47,12 +52,12 @@ const Explorer = () => {
},
})
.then((r) => r.data)
- .then((data) => {
+ .then((data: FilingData) => {
if (data) {
const filings = data.filings;
dispatch(setFilings(filings));
- if (primary.access == "") {
+ if (primary.access === "") {
dispatch(
setComparison({
type: "primary",
@@ -60,7 +65,7 @@ const Explorer = () => {
})
);
}
- if (secondary.access == "") {
+ if (secondary.access === "") {
dispatch(
setComparison({
type: "secondary",
@@ -76,7 +81,7 @@ const Explorer = () => {
.catch((e) => console.error(e));
const { isLoading: loading, error } = useSWR(
cik ? [server + "/filers/filings", cik] : null,
- ([url, cik]) => filingFetcher(url, cik),
+ ([url, cik]: [string, string]) => filingFetcher(url, cik),
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
@@ -179,4 +184,4 @@ const Explorer = () => {
);
};
-export default Explorer;
+export default Explorer;
\ No newline at end of file
From ba4f7176edbbbc9f4a3e54802cca33d4e96e246b Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:29 +0000
Subject: [PATCH 112/141] change_file_extension
# Commit trail:
-> 9556fc04b7bcab0f1be7c82c3f51bcab9772cd06: edit_file
---
frontend/components/Explorer/{Explorer.jsx => Explorer.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/{Explorer.jsx => Explorer.tsx} (100%)
diff --git a/frontend/components/Explorer/Explorer.jsx b/frontend/components/Explorer/Explorer.tsx
similarity index 100%
rename from frontend/components/Explorer/Explorer.jsx
rename to frontend/components/Explorer/Explorer.tsx
From 44c4464d8590fabf6cf4805eef1a02b7c7f7a314 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:30 +0000
Subject: [PATCH 113/141] edit_file
---
frontend/components/Tabs/Tabs.jsx | 36 ++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/frontend/components/Tabs/Tabs.jsx b/frontend/components/Tabs/Tabs.jsx
index a8beb474..6a1bca08 100644
--- a/frontend/components/Tabs/Tabs.jsx
+++ b/frontend/components/Tabs/Tabs.jsx
@@ -7,14 +7,20 @@ import { selectTab, setTab } from "@/redux/filerSlice";
import { font, fontLight } from "@fonts";
-const Tab = (props) => {
- const id = props.id;
- const tab = props.tab;
- const index = props.index + 1;
- const handleTab = props.handleTab;
+import React from "react";
- const length = props.length;
- const hint = props.hint || null;
+interface TabProps {
+ id: string;
+ tab: string;
+ index: number;
+ handleTab: (id: string) => void;
+ length: number;
+ hint?: string | null;
+ title: string;
+}
+
+const Tab: React.FC = (props) => {
+ const { id, tab, index, handleTab, length, hint, title } = props;
return (
{
].join(" ")}
onClick={() => handleTab(id)}
>
- {props.title}
+ {title}
{hint ? (
@@ -38,18 +44,24 @@ const Tab = (props) => {
);
};
-const tabs = [
+interface TabData {
+ title: string;
+ hint: string;
+ id: string;
+}
+
+const tabs: TabData[] = [
{ title: "Stocks", hint: "Table", id: "stocks" },
// { title: "Charts", hint: "Graphs", id: "charts" },
{ title: "Filings", hint: "Comparisons", id: "filings" },
];
-const Tabs = () => {
+const Tabs: React.FC = () => {
const tab = useSelector(selectTab);
const dispatch = useDispatch();
const router = useRouter();
- const handleTab = (value) => {
+ const handleTab = (value: string) => {
router.query.tab = value;
router.push(router);
dispatch(setTab(value));
@@ -73,4 +85,4 @@ const Tabs = () => {
);
};
-export default Tabs;
+export default Tabs;
\ No newline at end of file
From 64c7ac8616c76738445f3e84eacc1d9a68306b3b Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:31 +0000
Subject: [PATCH 114/141] change_file_extension
# Commit trail:
-> 44c4464d8590fabf6cf4805eef1a02b7c7f7a314: edit_file
---
frontend/components/Tabs/{Tabs.jsx => Tabs.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Tabs/{Tabs.jsx => Tabs.tsx} (100%)
diff --git a/frontend/components/Tabs/Tabs.jsx b/frontend/components/Tabs/Tabs.tsx
similarity index 100%
rename from frontend/components/Tabs/Tabs.jsx
rename to frontend/components/Tabs/Tabs.tsx
From 2ab844a2657e23b352d788adf462da05198f80bf Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:33 +0000
Subject: [PATCH 115/141] edit_file
---
frontend/components/Progress/Reload/Reload.jsx | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/frontend/components/Progress/Reload/Reload.jsx b/frontend/components/Progress/Reload/Reload.jsx
index 302fef2b..3f11fb7a 100644
--- a/frontend/components/Progress/Reload/Reload.jsx
+++ b/frontend/components/Progress/Reload/Reload.jsx
@@ -1,12 +1,14 @@
import styles from "./Reload.module.css";
import { useEffect } from "react";
-
import { useRouter } from "next/router";
import { fontLight } from "@fonts";
-
import useEllipsis from "components/Hooks/useEllipsis";
-const Reload = (props) => {
+interface ReloadProps {
+ delay?: number;
+}
+
+const Reload: React.FC = (props) => {
const router = useRouter();
const { ellipsis } = useEllipsis();
useEffect(() => {
@@ -24,4 +26,4 @@ const Reload = (props) => {
);
};
-export default Reload;
+export default Reload;
\ No newline at end of file
From 97293ca2c4f6686a8d3bdb31c9bba37a9446e74e Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:34 +0000
Subject: [PATCH 116/141] change_file_extension
# Commit trail:
-> 2ab844a2657e23b352d788adf462da05198f80bf: edit_file
---
frontend/components/Progress/Reload/{Reload.jsx => Reload.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Progress/Reload/{Reload.jsx => Reload.tsx} (100%)
diff --git a/frontend/components/Progress/Reload/Reload.jsx b/frontend/components/Progress/Reload/Reload.tsx
similarity index 100%
rename from frontend/components/Progress/Reload/Reload.jsx
rename to frontend/components/Progress/Reload/Reload.tsx
From b582ecd9c5a868d81d1dfdd7adf05895f7967455 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:35 +0000
Subject: [PATCH 117/141] edit_file
---
frontend/components/Progress/Console/Console.jsx | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/frontend/components/Progress/Console/Console.jsx b/frontend/components/Progress/Console/Console.jsx
index 2e256e47..356c11b0 100644
--- a/frontend/components/Progress/Console/Console.jsx
+++ b/frontend/components/Progress/Console/Console.jsx
@@ -1,20 +1,24 @@
import styles from "../Progress.module.css";
import { useEffect, useRef } from "react";
-
import { fontLight } from "@fonts";
-
import useEllipsis from "components/Hooks/useEllipsis";
import Loading from "components/Loading/Loading";
-const Console = (props) => {
+interface ConsoleProps {
+ logs: string[];
+ stall?: boolean;
+ loading?: boolean;
+}
+
+const Console: React.FC = (props) => {
const logs = props.logs;
const stall = props.stall || true;
const loading = props.loading || false;
const { ellipsis } = useEllipsis();
- const ref = useRef(null);
+ const ref = useRef(null);
useEffect(() => {
- ref.current.scrollIntoView({ behavior: "smooth", block: "end" });
+ ref.current?.scrollIntoView({ behavior: "smooth", block: "end" });
}, [logs]);
return (
@@ -38,4 +42,4 @@ const Console = (props) => {
);
};
-export default Console;
+export default Console;
\ No newline at end of file
From d727f1621c80013cdd81fd0c8ff5260487db0413 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:36 +0000
Subject: [PATCH 118/141] change_file_extension
# Commit trail:
-> b582ecd9c5a868d81d1dfdd7adf05895f7967455: edit_file
---
frontend/components/Progress/Console/{Console.jsx => Console.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Progress/Console/{Console.jsx => Console.tsx} (100%)
diff --git a/frontend/components/Progress/Console/Console.jsx b/frontend/components/Progress/Console/Console.tsx
similarity index 100%
rename from frontend/components/Progress/Console/Console.jsx
rename to frontend/components/Progress/Console/Console.tsx
From 77872c5e7af3acd5a0adfaa391bef56b073a8822 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:40 +0000
Subject: [PATCH 119/141] edit_file
---
.../Timeline/Select/Picker/Picker.jsx | 27 ++++++++++++-------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx b/frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx
index 666028ef..325b4396 100644
--- a/frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx
+++ b/frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx
@@ -1,9 +1,8 @@
+
import styles from "./Picker.module.css";
import selectStyles from "../Select.module.css";
import { useEffect, useState } from "react";
-
import axios from "axios";
-
import { useDispatch, useSelector } from "react-redux";
import {
selectCik,
@@ -11,16 +10,26 @@ import {
setComparison,
setOpen,
} from "@/redux/filerSlice";
-
import { font, fontLight } from "components/fonts";
const server = process.env.NEXT_PUBLIC_SERVER;
-const Picker = (props) => {
- const selected = props.selected;
- const attributes = props.attributes;
- const picking = props.picking;
- const setPicking = () => props.setPicking();
+interface PickerProps {
+ selected: { type: string };
+ attributes: { text: string; hint: string }[];
+ picking: boolean;
+ setPicking: (picking: boolean) => void;
+}
+
+interface Filing {
+ access_number: string;
+ report_date: number;
+ filing_date: number;
+ market_value?: number;
+}
+
+const Picker: React.FC = (props) => {
+ const { selected, attributes, picking, setPicking } = props;
const cik = useSelector(selectCik);
const filings = useSelector(selectFilings);
const dispatch = useDispatch();
@@ -33,7 +42,7 @@ const Picker = (props) => {
].join(" ")}
>
- {filings.map((filing) => {
+ {filings.map((filing: Filing) => {
const accessNumber = filing.access_number;
const reportDate = new Date(
filing.report_date * 1000
From ae2867fcdc3d4a94edda4caaf1a0522c0e5692e3 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:42 +0000
Subject: [PATCH 120/141] change_file_extension
# Commit trail:
-> 77872c5e7af3acd5a0adfaa391bef56b073a8822: edit_file
---
.../Explorer/Timeline/Select/Picker/{Picker.jsx => Picker.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/Timeline/Select/Picker/{Picker.jsx => Picker.tsx} (100%)
diff --git a/frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx b/frontend/components/Explorer/Timeline/Select/Picker/Picker.tsx
similarity index 100%
rename from frontend/components/Explorer/Timeline/Select/Picker/Picker.jsx
rename to frontend/components/Explorer/Timeline/Select/Picker/Picker.tsx
From 04d7fe4c48eea7f98a584021d18075e0aea709d9 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:43 +0000
Subject: [PATCH 121/141] edit_file
---
frontend/components/Progress/Building/Building.jsx | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/frontend/components/Progress/Building/Building.jsx b/frontend/components/Progress/Building/Building.jsx
index e8d57bdc..580f49aa 100644
--- a/frontend/components/Progress/Building/Building.jsx
+++ b/frontend/components/Progress/Building/Building.jsx
@@ -5,7 +5,11 @@ import { fontLight } from "@fonts";
import Loading from "components/Loading/Loading";
-const Building = (props) => {
+interface BuildingProps {
+ cik: string;
+}
+
+const Building: React.FC
= (props) => {
return (
@@ -22,4 +26,4 @@ const Building = (props) => {
);
};
-export default Building;
+export default Building;
\ No newline at end of file
From a52e04d26493f2e615c2ef7ea13b90f828af49f2 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:44 +0000
Subject: [PATCH 122/141] change_file_extension
# Commit trail:
-> 04d7fe4c48eea7f98a584021d18075e0aea709d9: edit_file
---
.../components/Progress/Building/{Building.jsx => Building.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Progress/Building/{Building.jsx => Building.tsx} (100%)
diff --git a/frontend/components/Progress/Building/Building.jsx b/frontend/components/Progress/Building/Building.tsx
similarity index 100%
rename from frontend/components/Progress/Building/Building.jsx
rename to frontend/components/Progress/Building/Building.tsx
From 147e0e4ee37386b9d8cd9d137f6363f6846ce16d Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:45 +0000
Subject: [PATCH 123/141] edit_file
---
frontend/components/Health/Health.jsx | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/frontend/components/Health/Health.jsx b/frontend/components/Health/Health.jsx
index ef2c98d7..ba1e211a 100644
--- a/frontend/components/Health/Health.jsx
+++ b/frontend/components/Health/Health.jsx
@@ -1,10 +1,11 @@
import { Toaster, toast } from "sonner";
-
import { fontLight } from "@fonts";
-
-const Health = (props) => {
+import React from "react";
+type HealthProps = {
+ health?: boolean;
+};
+const Health: React.FC
= (props) => {
const health = props.health || false;
-
if (health === false) {
setTimeout(() => {
toast.warning(
@@ -12,7 +13,6 @@ const Health = (props) => {
);
}, 1000);
}
-
return (
{
/>
);
};
-
-export default Health;
+export default Health;
\ No newline at end of file
From 18b9767b0b21bd28f3a5563a06e7f004c263369c Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:46 +0000
Subject: [PATCH 124/141] change_file_extension
# Commit trail:
-> 147e0e4ee37386b9d8cd9d137f6363f6846ce16d: edit_file
---
frontend/components/Health/{Health.jsx => Health.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Health/{Health.jsx => Health.tsx} (100%)
diff --git a/frontend/components/Health/Health.jsx b/frontend/components/Health/Health.tsx
similarity index 100%
rename from frontend/components/Health/Health.jsx
rename to frontend/components/Health/Health.tsx
From dc23b6f29549463e9ef9f26c943603507858151d Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:47 +0000
Subject: [PATCH 125/141] edit_file
---
frontend/components/Progress/Progress.jsx | 309 +++++++++++-----------
1 file changed, 149 insertions(+), 160 deletions(-)
diff --git a/frontend/components/Progress/Progress.jsx b/frontend/components/Progress/Progress.jsx
index f0972680..45ca7140 100644
--- a/frontend/components/Progress/Progress.jsx
+++ b/frontend/components/Progress/Progress.jsx
@@ -1,160 +1,149 @@
-import styles from "./Progress.module.css";
-import { useEffect, useReducer, useState } from "react";
-
-import { font } from "@fonts";
-
-import axios from "axios";
-import useSWR from "swr";
-
-import Redirect from "components/Filer/Redirect";
-import Source from "components/Source/Source";
-import Estimation from "./Estimation/Estimation";
-import Console from "./Console/Console";
-
-const server = process.env.NEXT_PUBLIC_SERVER;
-const logFetcher = (url, cik, start) =>
- axios
- .get(url, {
- params: { cik: cik, start: start },
- })
- .then((res) => {
- return { ...res.data, status: res.status };
- })
- .then((data) => data)
- .catch((e) => {
- const status = e.response.status;
- const error = new Error(e.data.message);
-
- error.status = status;
- throw error;
- });
-
-const Progress = (props) => {
- // const [host, setHost] = useState("localhost:3000");
- // useEffect(() => {
- // setHost(window.location.host);
- // }, [host]);
-
- // const [logs, pushLog] = useReducer(
- // (prev, next) => [...prev, ...next],
- // ["Initializing..."]
- // );
-
- // useSWRSubscription(
- // `ws://${host}/api/filers/logs?cik=${props.cik}`,
- // (key, { next }) => {
- // const socket = new WebSocket(key);
- // socket.addEventListener("message", ({ data }) => {
- // pushLog(data.split("\n"));
-
- // if (data.includes("Finished")) {
- // return () => socket.close();
- // }
-
- // return next(null, data);
- // });
- // socket.addEventListener("error", (event) => next(event.error));
- // socket.addEventListener("close", () => {
- // setTimeout(() => {
- // window.location.reload();
- // }, 10 * 1000);
- // });
- // return () => socket.close();
- // }
- // );
- const cik = props.cik;
- const name = props.name || null;
- const persist = props.persist || false;
- const [log, addLogs] = useReducer(
- (prev, next) => {
- if (next.length === 0) {
- return prev;
- }
-
- const logs = [...prev.logs, ...next];
- const length = logs.length;
- if (length > 100) {
- logs.shift();
- }
- return {
- logs: logs,
- count: logs.length,
- wait: false,
- };
- },
- { logs: ["Initializing, this may take a while..."], count: 0 }
- );
- const [wait, setWait] = useState(false);
- const [stop, setStop] = useState(false);
-
- const {
- data,
- isLoading: loading,
- error,
- } = useSWR(
- wait || stop ? null : [server + "/filers/logs", cik, log.count],
- ([url, cik, start]) => logFetcher(url, cik, start),
- { refreshInterval: 10 * 1000 }
- );
-
- useEffect(() => {
- if (data) {
- switch (data.status) {
- case 200:
- addLogs(data.logs || []);
-
- if (persist == false) {
- addLogs(["Filer finished initial load, reloading the page."]);
- setTimeout(() => {
- setStop(true);
- }, 5 * 1000);
- }
-
- break;
- case 201:
- addLogs(data.logs || []);
- addLogs(["Filer finished up, reloading the page."]);
- setStop(true);
- case 202:
- addLogs(data.logs || []);
- break;
- }
- }
- }, [data]);
-
- if (error) {
- switch (error.status) {
- case 503:
- setWait(true);
- setTimeout(() => {
- setWait(false), 15 * 1000;
- });
- break;
- case 404:
- addLogs(["Logs not found, try reloading the page."]);
- break;
- }
- }
-
- return (
- <>
- {stop ? : null}
-
-
-
- Building Filer
-
-
-
- {name ? {name} : null}
-
-
-
-
- {/* View stocks continuously. */}
- {/*persist ? null : */}
- >
- );
-};
-
-export default Progress;
+import styles from "./Progress.module.css";
+import { useEffect, useReducer, useState } from "react";
+
+import { font } from "@fonts";
+
+import axios from "axios";
+import useSWR from "swr";
+
+import Redirect from "components/Filer/Redirect";
+import Source from "components/Source/Source";
+import Estimation from "./Estimation/Estimation";
+import Console from "./Console/Console";
+
+const server = process.env.NEXT_PUBLIC_SERVER;
+
+interface LogFetcherResponse {
+ data: any;
+ status: number;
+ logs?: string[];
+}
+
+const logFetcher = (url: string, cik: string, start: number): Promise =>
+ axios
+ .get(url, {
+ params: { cik: cik, start: start },
+ })
+ .then((res) => {
+ return { ...res.data, status: res.status };
+ })
+ .then((data) => data)
+ .catch((e) => {
+ const status = e.response.status;
+ const error = new Error(e.data.message);
+
+ (error as any).status = status;
+ throw error;
+ });
+
+interface ProgressProps {
+ cik: string;
+ name?: string;
+ persist?: boolean;
+}
+
+interface LogState {
+ logs: string[];
+ count: number;
+ wait: boolean;
+}
+
+const Progress: React.FC = (props) => {
+ const cik = props.cik;
+ const name = props.name || null;
+ const persist = props.persist || false;
+ const [log, addLogs] = useReducer(
+ (prev: LogState, next: string[]) => {
+ if (next.length === 0) {
+ return prev;
+ }
+
+ const logs = [...prev.logs, ...next];
+ const length = logs.length;
+ if (length > 100) {
+ logs.shift();
+ }
+ return {
+ logs: logs,
+ count: logs.length,
+ wait: false,
+ };
+ },
+ { logs: ["Initializing, this may take a while..."], count: 0, wait: false }
+ );
+ const [wait, setWait] = useState(false);
+ const [stop, setStop] = useState(false);
+
+ const {
+ data,
+ isLoading: loading,
+ error,
+ } = useSWR(
+ wait || stop ? null : [server + "/filers/logs", cik, log.count],
+ ([url, cik, start]) => logFetcher(url, cik, start),
+ { refreshInterval: 10 * 1000 }
+ );
+
+ useEffect(() => {
+ if (data) {
+ switch (data.status) {
+ case 200:
+ addLogs(data.logs || []);
+
+ if (persist == false) {
+ addLogs(["Filer finished initial load, reloading the page."]);
+ setTimeout(() => {
+ setStop(true);
+ }, 5 * 1000);
+ }
+
+ break;
+ case 201:
+ addLogs(data.logs || []);
+ addLogs(["Filer finished up, reloading the page."]);
+ setStop(true);
+ case 202:
+ addLogs(data.logs || []);
+ break;
+ }
+ }
+ }, [data]);
+
+ useEffect(() => {
+ if (error) {
+ switch ((error as any).status) {
+ case 503:
+ setWait(true);
+ setTimeout(() => {
+ setWait(false), 15 * 1000;
+ });
+ break;
+ case 404:
+ addLogs(["Logs not found, try reloading the page."]);
+ break;
+ }
+ }
+ }, [error]);
+
+ return (
+ <>
+ {stop ? : null}
+
+
+
+ Building Filer
+
+
+
+ {name ? {name} : null}
+
+
+
+
+ {/* View stocks continuously. */}
+ {/*persist ? null : */}
+ >
+ );
+};
+
+export default Progress;
\ No newline at end of file
From 429c26206d6831012cae0177f3fd4419dadfaa98 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:48 +0000
Subject: [PATCH 126/141] change_file_extension
# Commit trail:
-> dc23b6f29549463e9ef9f26c943603507858151d: edit_file
---
frontend/components/Progress/{Progress.jsx => Progress.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Progress/{Progress.jsx => Progress.tsx} (100%)
diff --git a/frontend/components/Progress/Progress.jsx b/frontend/components/Progress/Progress.tsx
similarity index 100%
rename from frontend/components/Progress/Progress.jsx
rename to frontend/components/Progress/Progress.tsx
From 85cad17c35a709cb0f0040a838647ad8aa4410cb Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:49 +0000
Subject: [PATCH 127/141] edit_file
---
.../Explorer/Timeline/Select/Select.jsx | 37 ++++++++++++++-----
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/frontend/components/Explorer/Timeline/Select/Select.jsx b/frontend/components/Explorer/Timeline/Select/Select.jsx
index 36242f88..78f67b4f 100644
--- a/frontend/components/Explorer/Timeline/Select/Select.jsx
+++ b/frontend/components/Explorer/Timeline/Select/Select.jsx
@@ -1,6 +1,5 @@
import styles from "./Select.module.css";
import { useState } from "react";
-
import { useDispatch, useSelector } from "react-redux";
import {
selectCik,
@@ -8,25 +7,43 @@ import {
selectSecondary,
editComparison,
} from "@/redux/filerSlice";
-
import { font, fontLight } from "components/fonts";
-
import Headers from "components/Headers/Headers";
import Record from "./Record/Record";
import Picker from "./Picker/Picker";
import Source from "components/Source/Source";
-const Select = (props) => {
+interface SelectProps {
+ type: "primary" | "secondary";
+ setDescription: (description: string) => void;
+}
+
+interface Header {
+ accessor: string;
+ active: boolean;
+}
+
+interface Selected {
+ headers: Header[];
+ access: string;
+ report?: { date: string };
+ filing?: { date: string };
+ value: string;
+ sort: { sold: boolean; na: boolean };
+}
+
+const Select: React.FC = (props) => {
const dispatch = useDispatch();
const type = props.type;
const cik = useSelector(selectCik);
- const selected = useSelector(
- type === "secondary" ? selectSecondary : selectPrimary );
+ const selected: Selected = useSelector(
+ type === "secondary" ? selectSecondary : selectPrimary
+ );
const headers = selected.headers;
- const updateHeaders = (h) => dispatch(editComparison({ type, headers: h }));
- const updateDescription = (d) => props.setDescription(d);
- const updateActivation = (a) =>
+ const updateHeaders = (h: Header[]) => dispatch(editComparison({ type, headers: h }));
+ const updateDescription = (d: string) => props.setDescription(d);
+ const updateActivation = (a: string) =>
dispatch(
editComparison({
type,
@@ -130,4 +147,4 @@ const Select = (props) => {
);
};
-export default Select;
+export default Select;
\ No newline at end of file
From fe886e794417c5be1ca80cbae7f0757c55475d2b Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:50 +0000
Subject: [PATCH 128/141] change_file_extension
# Commit trail:
-> 85cad17c35a709cb0f0040a838647ad8aa4410cb: edit_file
---
.../Explorer/Timeline/Select/{Select.jsx => Select.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Explorer/Timeline/Select/{Select.jsx => Select.tsx} (100%)
diff --git a/frontend/components/Explorer/Timeline/Select/Select.jsx b/frontend/components/Explorer/Timeline/Select/Select.tsx
similarity index 100%
rename from frontend/components/Explorer/Timeline/Select/Select.jsx
rename to frontend/components/Explorer/Timeline/Select/Select.tsx
From 0696a9fe1feb8e7d40cb5bb8bcfdaa9e7b7ebcf7 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:53 +0000
Subject: [PATCH 129/141] edit_file
---
frontend/components/Unavailable/Unavailable.jsx | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/frontend/components/Unavailable/Unavailable.jsx b/frontend/components/Unavailable/Unavailable.jsx
index 6329db46..202246ce 100644
--- a/frontend/components/Unavailable/Unavailable.jsx
+++ b/frontend/components/Unavailable/Unavailable.jsx
@@ -6,7 +6,15 @@ import { font } from "@fonts";
import useEllipsis from "components/Hooks/useEllipsis";
-const Unavailable = (props) => {
+import React from "react";
+
+type UnavailableProps = {
+ type?: "stocks" | "loading";
+ cik?: string;
+ text?: string;
+};
+
+const Unavailable: React.FC = (props) => {
const type = props.type || "stocks";
const cik = type == "stocks" ? props.cik : null;
const text = props.text || null;
@@ -25,7 +33,7 @@ const Unavailable = (props) => {
{
);
};
-export default Unavailable;
+export default Unavailable;
\ No newline at end of file
From 6db492d92ced15cd28d984c30e811655ffed2fee Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:22:55 +0000
Subject: [PATCH 130/141] change_file_extension
# Commit trail:
-> 0696a9fe1feb8e7d40cb5bb8bcfdaa9e7b7ebcf7: edit_file
---
.../components/Unavailable/{Unavailable.jsx => Unavailable.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename frontend/components/Unavailable/{Unavailable.jsx => Unavailable.tsx} (100%)
diff --git a/frontend/components/Unavailable/Unavailable.jsx b/frontend/components/Unavailable/Unavailable.tsx
similarity index 100%
rename from frontend/components/Unavailable/Unavailable.jsx
rename to frontend/components/Unavailable/Unavailable.tsx
From bb6d9a452353fb6956302bc6fb62acb6ba243bc4 Mon Sep 17 00:00:00 2001
From: Second Agent <123514301+second-agent[bot]@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:23:11 +0000
Subject: [PATCH 131/141] edit_file
---
frontend/components/Search/Button/Search.jsx | 325 ++++++++++---------
1 file changed, 169 insertions(+), 156 deletions(-)
diff --git a/frontend/components/Search/Button/Search.jsx b/frontend/components/Search/Button/Search.jsx
index 730f4b62..e6086274 100644
--- a/frontend/components/Search/Button/Search.jsx
+++ b/frontend/components/Search/Button/Search.jsx
@@ -1,156 +1,169 @@
-import styles from "./Search.module.css";
-import { useEffect, useState, useRef, useReducer } from "react";
-
-import axios from "axios";
-import useSWR from "swr";
-
-import Link from "next/link";
-import { font } from "@fonts";
-
-import SearchIcon from "@/public/static/search.svg";
-
-const server = process.env.NEXT_PUBLIC_SERVER;
-const fetcher = (url, query, limit) =>
- axios
- .get(url, { params: { q: query, limit } })
- .then((res) => res.data)
- .catch((e) => console.error(e));
-
-const Search = () => {
- const [input, setInput] = useReducer(
- (prev, next) => {
- return { ...prev, ...next };
- },
- {
- results: [],
- search: "",
- focus: false,
- }
- );
- const [show, setShow] = useState(false);
-
- const limit = 10;
- const { data } = useSWR(
- input.search ? [server + "/filers/search", input.search, limit] : null,
- ([url, query, limit]) => fetcher(url, query, limit),
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- useEffect(() => {
- if (data) {
- setInput({ results: data.results });
- } else {
- setInput({ results: [] });
- }
- }, [data]);
-
- return (
- <>
- setShow(true)}
- >
-
-
- {show ? (
- <>
- setShow(false)}
- />
-
- setInput({ search: e.target.value })}
- onFocus={() => setInput({ focus: true })}
- onBlur={() => setInput({ focus: false })}
- autoFocus
- />
-
- {input.search && input.results.length ? (
-
- ) : null}
- >
- ) : null}
- >
- );
-
- // return (
- //
- //
- // setSearchInput(e.target.value)}
- // onFocus={() => setIsFocused(true)}
- // onBlur={() => setIsFocused(false)}
- // />
- //
- //
- //
- // );
-};
-
-export default Search;
+import styles from "./Search.module.css";
+import { useEffect, useState, useRef, useReducer } from "react";
+
+import axios from "axios";
+import useSWR from "swr";
+
+import Link from "next/link";
+import { font } from "@fonts";
+
+import SearchIcon from "@/public/static/search.svg";
+
+const server = process.env.NEXT_PUBLIC_SERVER;
+
+type Result = {
+ cik: string;
+ name: string;
+ tickers: string[];
+};
+
+type InputState = {
+ results: Result[];
+ search: string;
+ focus: boolean;
+};
+
+const fetcher = (url: string, query: string, limit: number) =>
+ axios
+ .get(url, { params: { q: query, limit } })
+ .then((res) => res.data)
+ .catch((e) => console.error(e));
+
+const Search = () => {
+ const [input, setInput] = useReducer(
+ (prev: InputState, next: Partial
) => {
+ return { ...prev, ...next };
+ },
+ {
+ results: [],
+ search: "",
+ focus: false,
+ }
+ );
+ const [show, setShow] = useState(false);
+
+ const limit = 10;
+ const { data } = useSWR(
+ input.search ? [server + "/filers/search", input.search, limit] : null,
+ ([url, query, limit]: [string, string, number]) => fetcher(url, query, limit),
+ {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ }
+ );
+ useEffect(() => {
+ if (data) {
+ setInput({ results: data.results });
+ } else {
+ setInput({ results: [] });
+ }
+ }, [data]);
+
+ return (
+ <>
+ setShow(true)}
+ >
+
+
+ {show ? (
+ <>
+