Skip to content

Commit

Permalink
fix: pr review - add s and fix date stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
eldu committed Feb 8, 2024
1 parent a4cab04 commit c702ab0
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 34 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@reduxjs/toolkit": "^2.0.1",
"bootstrap": "^5.3.2",
"brown-university-styles": "git+https://github.com/BrownUniversity/brown-university-styles.git",
"date-fns": "^3.3.1",
"firebase": "^10.7.2",
"formik": "^2.4.5",
"lodash": "^4.17.11",
Expand Down
19 changes: 2 additions & 17 deletions src/utils/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import {
query,
limit,
orderBy,
serverTimestamp,
} from 'firebase/firestore';
import { useDispatch } from 'react-redux';
import { useEffect } from 'react';
import { formatISO } from 'date-fns';

import { setPublications } from '../store/slice/appState';

Expand Down Expand Up @@ -45,17 +43,7 @@ export const usePublicationsCollection = () => {
limit(10) // TODO: TEMPORARY. Limiting right now. Set up pagination?
),
(snapshot) => {
const publications = snapshot.docs.map((doc) => {
const data = doc.data();

return {
...data,

// Note: Needed to convert Timestamp type to a serializable type like a string
// Also, formatISO gives the date in ISO format in local time zone by default
updatedAt: formatISO(data.updatedAt.toDate()),
};
});
const publications = snapshot.docs.map((doc) => doc.data());
dispatch(setPublications(publications));
},
(error) => {
Expand All @@ -75,9 +63,6 @@ export const addPublication = async (publication) => {

await setDoc(docRef, {
...publication,

// Firestore automatically replaces serverTimestamp with the server's timestamp
// when the data is written to the database
updatedAt: serverTimestamp(),
updatedAt: Date.now(),
});
};
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as yup from 'yup';
import { Publication } from '../../types';

export const fetchDoi = async (doi: string): Promise<Publication> => {
const res = await fetch(`http://dx.doi.org/${encodeURIComponent(doi)}`, {
const res = await fetch(`https://dx.doi.org/${encodeURIComponent(doi)}`, {
headers: {
Accept: 'application/vnd.citationstyles.csl+json',
},
Expand Down

0 comments on commit c702ab0

Please sign in to comment.