diff --git a/client/src/components/App.test.js b/client/src/components/App.test.js
deleted file mode 100644
index 1f03afe..0000000
--- a/client/src/components/App.test.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { render, screen } from '@testing-library/react';
-import App from './App';
-
-test('renders learn react link', () => {
- render();
- const linkElement = screen.getByText(/learn react/i);
- expect(linkElement).toBeInTheDocument();
-});
diff --git a/client/src/components/CreateLink.js b/client/src/components/CreateLink.js
index 9b6d85c..d810ff6 100644
--- a/client/src/components/CreateLink.js
+++ b/client/src/components/CreateLink.js
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useHistory } from 'react-router';
import { useMutation, gql } from '@apollo/client';
-import { LINKS_PER_PAGE } from '../constants';
-import { FEED_QUERY } from './LinkList';
+// import { LINKS_PER_PAGE } from '../constants';
+// import { FEED_QUERY } from './LinkList';
const CREATE_LINK_MUTATION = gql`
mutation PostMutation(
@@ -31,34 +31,34 @@ const CreateLink = () => {
description: formState.description,
url: formState.url
},
- update: (cache, { data: { post } }) => {
- const take = LINKS_PER_PAGE;
- const skip = 0;
- const orderBy = { createdAt: 'desc' };
+ // update: (cache, { data: { post } }) => {
+ // const take = LINKS_PER_PAGE;
+ // const skip = 0;
+ // const orderBy = { createdAt: 'desc' };
- const { data } = cache.readQuery({
- query: FEED_QUERY,
- variables: {
- take,
- skip,
- orderBy
- }
- });
+ // const { data } = cache.readQuery({
+ // query: FEED_QUERY,
+ // variables: {
+ // take,
+ // skip,
+ // orderBy
+ // }
+ // });
- cache.writeQuery({
- query: FEED_QUERY,
- data: {
- feed: {
- links: [post, ...data.feed.links]
- }
- },
- variables: {
- take,
- skip,
- orderBy
- }
- });
- },
+ // cache.writeQuery({
+ // query: FEED_QUERY,
+ // data: {
+ // feed: {
+ // links: [post, ...data.feed.links]
+ // }
+ // },
+ // variables: {
+ // take,
+ // skip,
+ // orderBy
+ // }
+ // });
+ // },
onCompleted: () => history.push('/new/1')
});
diff --git a/client/src/components/Header.js b/client/src/components/Header.js
index 6087837..eddbb18 100644
--- a/client/src/components/Header.js
+++ b/client/src/components/Header.js
@@ -9,48 +9,30 @@ const Header = () => {
return (
-
Hacker News
-
- new
-
+
News
+
Top
|
-
- top
-
+
New
|
-
- search
-
+
Search
{authToken && (
)}
{authToken ? (
-
{
+
{
localStorage.removeItem(AUTH_TOKEN);
history.push(`/`);
}}
>
- logout
+ Logout
) : (
-
- login
-
+
Login
)}
diff --git a/client/src/components/Link.js b/client/src/components/Link.js
index 9657f80..3fe2e34 100644
--- a/client/src/components/Link.js
+++ b/client/src/components/Link.js
@@ -1,8 +1,8 @@
import React from 'react';
import { useMutation, gql } from '@apollo/client';
-import { AUTH_TOKEN, LINKS_PER_PAGE } from '../constants';
+import { AUTH_TOKEN } from '../constants';
import { timeDifferenceForDate } from '../utils'
-import { FEED_QUERY } from './LinkList'
+// import { FEED_QUERY } from './LinkList'
const VOTE_MUTATION = gql`
mutation VoteMutation($linkId: ID!) {
@@ -24,45 +24,38 @@ const VOTE_MUTATION = gql`
}
`;
-const take = LINKS_PER_PAGE;
-const skip = 0;
-const orderBy = { createdAt: 'desc' };
-
const Link = (props) => {
const { link } = props;
const authToken = localStorage.getItem(AUTH_TOKEN);
- const take = LINKS_PER_PAGE;
- const skip = 0;
- const orderBy = { createdAt: 'desc' };
const [vote] = useMutation(VOTE_MUTATION, {
variables: {
linkId: link.id
},
- update(cache, { data: { vote } }) {
- const { feed } = cache.readQuery({
- query: FEED_QUERY
- });
+ // update(cache, { data: { vote } }) {
+ // const { feed } = cache.readQuery({
+ // query: FEED_QUERY
+ // });
- const updatedLinks = feed.links.map((feedLink) => {
- if (feedLink.id === link.id) {
- return {
- ...feedLink,
- votes: [...feedLink.votes, vote]
- };
- }
- return feedLink;
- });
+ // const updatedLinks = feed.links.map((feedLink) => {
+ // if (feedLink.id === link.id) {
+ // return {
+ // ...feedLink,
+ // votes: [...feedLink.votes, vote]
+ // };
+ // }
+ // return feedLink;
+ // });
- cache.writeQuery({
- query: FEED_QUERY,
- data: {
- feed: {
- links: updatedLinks
- }
- }
- });
- }
+ // cache.writeQuery({
+ // query: FEED_QUERY,
+ // data: {
+ // feed: {
+ // links: updatedLinks
+ // }
+ // }
+ // });
+ // }
});
return (
@@ -70,19 +63,13 @@ const Link = (props) => {
{props.index + 1}.
{authToken && (
-
- ▲
-
+
▲
)}
{link.description} ({link.url})
-
+
{authToken && (
{link.votes.length} votes, submitted by{' '}
diff --git a/client/src/components/LinkList.js b/client/src/components/LinkList.js
index 2a20b8f..4cf17b0 100644
--- a/client/src/components/LinkList.js
+++ b/client/src/components/LinkList.js
@@ -75,8 +75,6 @@ const LinkList = () => {
pageIndexParams[pageIndexParams.length - 1]
);
- console.log(pageIndexParams.length, page);
-
const pageIndex = page ? (page - 1) * LINKS_PER_PAGE : 0;
const {
@@ -88,8 +86,6 @@ const LinkList = () => {
variables: getQueryVariables(isNewPage, page)
});
- // const { data } = useQuery(FEED_QUERY);
-
const getLinksToRender = (isNewPage, data) => {
if (isNewPage) {
return data.feed.links;
diff --git a/client/src/components/Search.js b/client/src/components/Search.js
index a8cb691..166fd71 100644
--- a/client/src/components/Search.js
+++ b/client/src/components/Search.js
@@ -6,7 +6,6 @@ import Link from './Link';
const FEED_SEARCH_QUERY = gql`
query FeedSearchQuery($filter: String!) {
feed(filter: $filter) {
- id
links {
id
url
diff --git a/client/src/setupTests.js b/client/src/setupTests.js
deleted file mode 100644
index 8f2609b..0000000
--- a/client/src/setupTests.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// jest-dom adds custom jest matchers for asserting on DOM nodes.
-// allows you to do things like:
-// expect(element).toHaveTextContent(/react/i)
-// learn more: https://github.com/testing-library/jest-dom
-import '@testing-library/jest-dom';
diff --git a/server/prisma/dev.db b/server/prisma/dev.db
index 2dad153..5c9b516 100644
Binary files a/server/prisma/dev.db and b/server/prisma/dev.db differ