Skip to content

Commit

Permalink
feat(1530): changed to remote couchdb with caching
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilmhdh authored and deshmukhmayur committed Oct 6, 2021
1 parent 6bc515a commit 6e25807
Show file tree
Hide file tree
Showing 26 changed files with 938 additions and 520 deletions.
29 changes: 16 additions & 13 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"react-hook-form": "^7.10.1",
"react-router-dom": "^6.0.0-beta.0",
"react-scripts": "4.0.3",
"swr": "^1.0.1",
"typescript": "^4.3.2",
"web-vitals": "^2.0.1",
"yup": "^0.32.9"
Expand Down
9 changes: 3 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { BrowserRouter } from 'react-router-dom';

import { PouchDBProvider } from 'context';
import { Router } from './routes';
import './App.scss';

const App = (): JSX.Element => {
return (
<PouchDBProvider>
<BrowserRouter>
<Router />
</BrowserRouter>
</PouchDBProvider>
<BrowserRouter>
<Router />
</BrowserRouter>
);
};

Expand Down
17 changes: 13 additions & 4 deletions src/components/VoteCard/VoteCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, Children as ReactChildren, ReactElement, CSSProperties } from 'react';
import { FC, Children as ReactChildren, ReactElement, CSSProperties, useState } from 'react';

import {
Button,
Expand Down Expand Up @@ -32,6 +32,7 @@ export const VoteCard: FC<Props> & CompoundComponents = ({
hasVoted,
children,
}) => {
const [isVoting, setIsVoting] = useState(false);
const buttonChildren: ReactElement[] = [];

ReactChildren.forEach(children as ReactElement, (child: ReactElement) => {
Expand All @@ -40,6 +41,12 @@ export const VoteCard: FC<Props> & CompoundComponents = ({
}
});

const handleVoteClick = async () => {
setIsVoting(true);
onVoteClick && (await onVoteClick());
setIsVoting(false);
};

return (
<Card>
<CardBody>
Expand All @@ -63,12 +70,14 @@ export const VoteCard: FC<Props> & CompoundComponents = ({
<FlexItem spacer={{ default: 'spacerLg' }}>
<Button
variant="secondary"
onClick={onVoteClick}
onClick={handleVoteClick}
isDanger={hasVoted}
className="pf-u-px-lg pf-u-py-sm"
isLoading={isVoting}
isDisabled={isVoting}
className="pf-u-py-sm"
style={{ '--pf-c-button--after--BorderRadius': '8px' } as CSSProperties}
>
{hasVoted ? 'VOTED' : 'VOTE'}
{isVoting ? 'VOTING' : hasVoted ? 'VOTED' : 'VOTE'}
</Button>
</FlexItem>
<FlexItem spacer={{ default: 'spacerXs' }}>
Expand Down
Loading

0 comments on commit 6e25807

Please sign in to comment.