Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkalemba committed Oct 1, 2020
2 parents 3b43676 + c094a93 commit 1a0238d
Show file tree
Hide file tree
Showing 7 changed files with 5,240 additions and 6,312 deletions.
14 changes: 5 additions & 9 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"REACT_APP_FIREBASE_MESSAGING_SENDER_ID": "@firebase-messaging-sender-id",
"REACT_APP_FIREBASE_APP_ID": "@firebase-app-id",
"REACT_APP_FIREBASE_MEASUREMENT_ID": "@firebase-measurement-id",
"REACT_APP_STITCH_APP_ID": "@stitch-app-id",
"REACT_APP_STITCH_SERVICE_NAME": "@stitch-service-name",
"REACT_APP_MONGO_DB_NAME": "@mongo-db-name",
"API_KEY": "@api-key"
"API_KEY": "@api-key",
"REACT_APP_DATA_ENDPOINT": "@data-endpoint"
},
"build": {
"env": {
Expand All @@ -23,10 +21,8 @@
"REACT_APP_FIREBASE_MESSAGING_SENDER_ID": "@firebase-messaging-sender-id",
"REACT_APP_FIREBASE_APP_ID": "@firebase-app-id",
"REACT_APP_FIREBASE_MEASUREMENT_ID": "@firebase-measurement-id",
"REACT_APP_STITCH_APP_ID": "@stitch-app-id",
"REACT_APP_STITCH_SERVICE_NAME": "@stitch-service-name",
"REACT_APP_MONGO_DB_NAME": "@mongo-db-name",
"API_KEY": "@api-key"
"API_KEY": "@api-key",
"REACT_APP_DATA_ENDPOINT": "@data-endpoint"
}
}
}
}
6,689 changes: 2,882 additions & 3,807 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{
"name": "korona.ws",
"homepage": "https://korona.ws",
"version": "1.2.10",
"version": "1.2.11",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"baseui": "^9.62.0",
"firebase": "^7.10.0",
"firebase": "^7.21.1",
"i18next": "^19.3.3",
"leaflet": "^1.6.0",
"leaflet.markercluster": "^1.4.1",
"lodash.groupby": "^4.6.0",
"moment": "^2.24.0",
"mongodb-stitch-browser-sdk": "^4.8.0",
"mongodb-stitch-server-sdk": "^4.8.0",
"react": "^16.13.0",
"react-content-loader": "^5.0.2",
"react-dom": "^16.13.0",
"react-i18next": "^11.3.4",
"react-leaflet": "^2.6.1",
"react-leaflet-markercluster": "2.0.0-rc3",
"react-scripts": "3.4.0",
"react-scripts": "^3.4.3",
"recharts": "^2.0.0-beta.1",
"styletron-engine-atomic": "^1.4.6",
"styletron-react": "^5.2.7",
Expand Down Expand Up @@ -64,4 +62,4 @@
"eslint-plugin-prettier": "^3.1.2",
"prettier": "2.0.1"
}
}
}
36 changes: 6 additions & 30 deletions src/components/Layout/Desktop.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
Map,
Figures,
DailyGrowth,
Source,
VoivodeshipsSplit,
Contributors,
} from '..';
import { Map, Figures, DailyGrowth, VoivodeshipsSplit, Contributors } from '..';

import { useStyletron } from 'baseui';
import { Layer } from 'baseui/layer';
Expand All @@ -21,11 +14,11 @@ import { switchLanguage } from '../../helpers/switchLanguage';

import { useTheme } from '../../contexts/ThemeContext';
import { StyledLink } from 'baseui/link';
import { ArrowUpRight } from 'tabler-icons-react';

export default function Desktop() {
const { t, i18n } = useTranslation();
const [isInfoModalOpen, setIsInfoModalOpen] = useState(false);
const [isSourceModalOpen, setIsSourceModalOpen] = useState(false);
const { useDarkTheme, setUseDarkTheme } = useTheme();
const [css] = useStyletron();

Expand Down Expand Up @@ -157,7 +150,10 @@ export default function Desktop() {
</Button>
<Button
size={SIZE.mini}
onClick={() => setIsSourceModalOpen(true)}
$as='a'
target='_blank'
href='http://bit.ly/covid19-poland'
endEnhancer={() => <ArrowUpRight size={16} />}
overrides={{
BaseButton: {
style: ({ $theme }) => ({
Expand Down Expand Up @@ -250,26 +246,6 @@ export default function Desktop() {
<Contributors />
</ModalBody>
</Modal>
<Modal
onClose={() => setIsSourceModalOpen(false)}
closeable
isOpen={isSourceModalOpen}
animate
role={ROLE.dialog}
overrides={{
Dialog: {
style: ({ $theme }) => ({
borderRadius: $theme.borders.radius200,
}),
},
}}
>
<ModalHeader>{t('source')}</ModalHeader>
<ModalBody>
<Paragraph3>{t('sourceInfo')}</Paragraph3>
<Source />
</ModalBody>
</Modal>
</Block>
</Layer>
</>
Expand Down
27 changes: 4 additions & 23 deletions src/components/Layout/Mobile.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Map, VoivodeshipsSplit, Source, Contributors } from '../../components';
import { Map, VoivodeshipsSplit, Contributors } from '../../components';

import { useStyletron } from 'baseui';
import { Layer } from 'baseui/layer';
Expand Down Expand Up @@ -55,7 +55,6 @@ export default function Mobile() {
} = useData();
const { t, i18n } = useTranslation();
const [isInfoModalOpen, setIsInfoModalOpen] = useState(false);
const [isSourceModalOpen, setIsSourceModalOpen] = useState(false);
const { useDarkTheme, setUseDarkTheme } = useTheme();
const [activeKey, setActiveKey] = useState('0');
const [css, theme] = useStyletron();
Expand Down Expand Up @@ -98,7 +97,9 @@ export default function Mobile() {
},
{
label: t('source'),
onClick: () => setIsSourceModalOpen(true),
onClick: () => {
window.open('http://bit.ly/covid19-poland');
},
},
{
label:
Expand Down Expand Up @@ -374,26 +375,6 @@ export default function Mobile() {
<Contributors />
</ModalBody>
</Modal>
<Modal
onClose={() => setIsSourceModalOpen(false)}
closeable
isOpen={isSourceModalOpen}
animate
role={ROLE.dialog}
overrides={{
Dialog: {
style: ({ $theme }) => ({
borderRadius: $theme.borders.radius200,
}),
},
}}
>
<ModalHeader>{t('source')}</ModalHeader>
<ModalBody>
<Paragraph3>{t('sourceInfo')}</Paragraph3>
<Source />
</ModalBody>
</Modal>
</Block>
</Layer>
</>
Expand Down
37 changes: 2 additions & 35 deletions src/contexts/DataContext.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import React, { createContext, useContext, useState, useEffect } from 'react';

import { connect, db } from '../helpers/stitch';
import { useConnection } from './ConnectionContext';

const COLLECTIONS = [
'voivodeships',
'cases',
'deaths',
'cures',
'hospitalizations',
'quarantines',
'supervisions',
'tests',
];

const DataContext = createContext();

export function DataProvider(props) {
Expand All @@ -35,30 +23,9 @@ export function DataProvider(props) {
}

async function fetchData() {
await connect();
const fetchedData = {};

async function registerCollection(collectionName) {
const collection = db.collection(collectionName);

fetchedData[collectionName] = await collection.find().toArray();

// Set up a watcher
const stream = await collection.watch();

// Watch for the changes
stream.onNext(async () => {
fetchedData[collectionName] = await collection.find().toArray();

setData({
...fetchedData,
});
});
}
const response = await fetch(process.env.REACT_APP_DATA_ENDPOINT);

await Promise.all(
COLLECTIONS.map((collectionName) => registerCollection(collectionName))
);
const fetchedData = await response.json();

setData(fetchedData);
setIsLoading(false);
Expand Down
Loading

1 comment on commit 1a0238d

@vercel
Copy link

@vercel vercel bot commented on 1a0238d Oct 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.