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

Redux solution #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 3 additions & 12 deletions frontend/components/Explorer/Explorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@ import axios from "axios";
import useSWR from "swr";

import { useDispatch, useSelector } from "react-redux";
import {
selectCik,
selectPrimary,
setFilings,
setComparison,
selectSecondary,
editComparison,
editSort,
setFilingCount,
} from "@/redux/filerSlice";

import useFilingStocks from "components/Hooks/useFilingStocks";
import Loading from "components/Loading/Loading";
import Table from "components/Table/Table";
import Unavailable from "components/Unavailable/Unavailable";
import Timeline from "./Timeline/Timeline";
import { editComparison, editSort, selectFilings, selectPrimary, selectSecondary, setComparison, setFilingCount } from "@/redux/timelineSlice";
import { selectCik } from "@/redux/generalSlice";

const server = process.env.NEXT_PUBLIC_SERVER;

Expand Down Expand Up @@ -51,7 +42,7 @@ const Explorer = () => {
if (data) {
const filings = data.filings;

dispatch(setFilings(filings));
dispatch(selectFilings(filings));
if (primary.access == "") {
dispatch(
setComparison({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@ import styles from "../Select/Select.module.css";
import { useState } from "react";

import { useDispatch, useSelector } from "react-redux";
import {
selectPrimary,
selectSecondary,
selectDifference,
editComparison,
editDifference,
} from "@/redux/filerSlice";

import { font, fontLight } from "components/fonts";

import Headers from "components/Headers/Headers";
import Record from "../Select/Record/Record";
import { editDifference, selectDifference } from "@/redux/differenceSlice";

const Difference = (props) => {
const dispatch = useDispatch();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import styles from "./Picker.module.css";

import { useDispatch, useSelector } from "react-redux";
import { selectFilings, setComparison } from "@/redux/filerSlice";

import { fontLight } from "components/fonts";
import { selectFilings, setComparison } from "@/redux/timelineSlice";

const Picker = (props) => {
const selected = props.selected;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import styles from "./Record.module.css";

import { useSelector } from "react-redux";
import { selectCik } from "@/redux/filerSlice";

import { font } from "components/fonts";

import DataIcon from "@/public/static/data.svg";
import TableIcon from "@/public/static/csv.svg";
import { selectCik } from "@/redux/generalSlice";

const server = process.env.NEXT_PUBLIC_SERVER;
const Record = (props) => {
Expand Down
8 changes: 2 additions & 6 deletions frontend/components/Explorer/Timeline/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import styles from "./Select.module.css";
import { useState } from "react";

import { useDispatch, useSelector } from "react-redux";
import {
selectCik,
selectPrimary,
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";
import { editComparison, selectPrimary, selectSecondary } from "@/redux/timelineSlice";
import { selectCik } from "@/redux/generalSlice";

const Select = (props) => {
const dispatch = useDispatch();
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Explorer/Timeline/Timeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ 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";
import { selectTimeline } from "@/redux/timelineSlice";

const Timeline = () => {
const dispatch = useDispatch();
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import axios from "axios";
import Head from "next/head";

import { useDispatch } from "react-redux";
import { setCik, setTab } from "@/redux/filerSlice";

import { font } from "@fonts";

import Expand from "components/Expand/Expand";
import Source from "components/Source/Source";
import Building from "components/Progress/Building/Building";
import { convertTitle } from "components/Filer/Info";
import { setCik, setTab } from "@/redux/generalSlice";

const server = process.env.NEXT_PUBLIC_SERVER;
const fetcher = (url, cik) =>
Expand Down
14 changes: 1 addition & 13 deletions frontend/components/Index/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@ import axios from "axios";
import Error from "next/error";

import { useDispatch, useSelector } from "react-redux";
import {
setStocks,
setCount,
setOffset,
setPagination,
sortHeader,
selectCik,
selectPagination,
selectStocks,
selectSort,
selectHeaders,
} from "@/redux/filerSlice";

import useStocks from "components/Hooks/useStocks";
import Analysis from "components/Analysis/Analysis";
import Table from "components/Table/Table";
import Sort from "./Sort/Sort";
import { selectCik, selectHeaders, selectPagination, selectSort, selectStocks, setCount, setOffset, setPagination, setStocks, sortHeader } from "@/redux/generalSlice";

const server = process.env.NEXT_PUBLIC_SERVER;
const Index = () => {
Expand Down
10 changes: 1 addition & 9 deletions frontend/components/Index/Sort/Filter/Filter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ import styles from "./Filter.module.css";
import { useState } from "react";

import { useDispatch, useSelector } from "react-redux";
import {
selectHeaders,
selectSold,
selectNa,
sortSold,
sortNa,
activateHeader,
setHeaders,
} from "@/redux/filerSlice";

import { font, fontLight } from "@fonts";

import Tip from "components/Tip/Tip";
import Headers from "components/Headers/Headers";
import { activateHeader, selectHeaders, selectNa, selectSold, setHeaders, sortNa, sortSold } from "@/redux/generalSlice";

const Filter = () => {
const headers = useSelector(selectHeaders);
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Index/Sort/Gain/Droppable/Plus.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styles from "../Gain.module.css";

import { useDispatch } from "react-redux";
import { newDate } from "@/redux/filerSlice";

import { useDroppable } from "@dnd-kit/core";

import PlusSVG from "./plus.svg";
import { newDate } from "@/redux/generalSlice";

const Plus = (props) => {
const event = props.event;
Expand Down
1 change: 0 additions & 1 deletion frontend/components/Index/Sort/Gain/Droppable/Trash.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styles from "../Gain.module.css";
import { useDroppable } from "@dnd-kit/core";

import { useDispatch } from "react-redux";
import { removeDate } from "@/redux/filerSlice";

import TrashSVG from "./trash.svg";

Expand Down
8 changes: 1 addition & 7 deletions frontend/components/Index/Sort/Gain/Gain.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import styles from "./Gain.module.css";
import { useReducer } from "react";

import {
selectDates,
updateDates,
newDate,
openDate,
removeDate,
} from "@/redux/filerSlice";
import { useDispatch, useSelector } from "react-redux";

import {
Expand All @@ -29,6 +22,7 @@ import Select from "./Select/Select";
import Plus from "./Droppable/Plus";
import Trash from "./Droppable/Trash";
import Tip from "components/Tip/Tip";
import { newDate, openDate, removeDate, selectDates, updateDates } from "@/redux/generalSlice";

const Gain = () => {
const dates = useSelector(selectDates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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";
import { editDate, openDate } from "@/redux/generalSlice";

const months = [
{ name: "Jan", value: 0 },
Expand Down
11 changes: 2 additions & 9 deletions frontend/components/Index/Sort/Gain/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ 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";
Expand All @@ -21,6 +13,7 @@ import { font } from "@fonts";

import Picker from "./Picker/Picker";
import Loading from "components/Loading/Loading";
import { addHeader, editHeader, removeHeader, selectCik, selectHeaders, updateStocks } from "@/redux/generalSlice";

// const animateLayoutChanges = (args) => {
// const { isSorting, wasSorting } = args;
Expand Down Expand Up @@ -49,7 +42,7 @@ const Select = (props) => {

const date =
useSelector((state) =>
state.filer.dates.find((d) => d.accessor == propDate.accessor)
state.general.dates.find((d) => d.accessor == propDate.accessor)
) || propDate;
const open = date.open;
const time = date.timestamp;
Expand Down
3 changes: 1 addition & 2 deletions frontend/components/Index/Sort/Record/Record.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import styles from "./Record.module.css";

import { useSelector } from "react-redux";
import { selectCik, selectHeaders } from "@/redux/filerSlice";

import Link from "next/link";

import { font } from "@fonts";

import DataIcon from "@/public/static/data.svg";
import TableIcon from "@/public/static/csv.svg";
import { selectCik, selectHeaders } from "@/redux/generalSlice";

const server = process.env.NEXT_PUBLIC_SERVER;
const Record = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Tabs/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import styles from "./Tabs.module.css";
import { useRouter } from "next/router";

import { useDispatch, useSelector } from "react-redux";
import { selectTab, setTab } from "@/redux/filerSlice";

import { font, fontLight } from "@fonts";
import { selectTab, setTab } from "@/redux/generalSlice";

const Tab = (props) => {
const id = props.id;
Expand Down
10 changes: 6 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/pages/filers/[cik].jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";

import { Provider } from "react-redux";
import { wrapper } from "@/redux/store";
import { wrapper } from "@/redux/new_store";

import Layout from "components/Layouts/Layout";
import Info from "components/Filer/Info";
Expand Down
Loading