aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/ReviewCard/ReviewCard.tsx17
-rw-r--r--src/containers/Home/Home.tsx7
-rw-r--r--src/containers/Home/ReviewForm.tsx7
-rw-r--r--src/hooks/APIClient.ts2
4 files changed, 25 insertions, 8 deletions
diff --git a/src/components/ReviewCard/ReviewCard.tsx b/src/components/ReviewCard/ReviewCard.tsx
index 2016a5e..ccf051c 100644
--- a/src/components/ReviewCard/ReviewCard.tsx
+++ b/src/components/ReviewCard/ReviewCard.tsx
@@ -4,7 +4,8 @@ import {
Card,
CardContent,
Typography,
- Divider
+ Divider,
+ Chip
} from '@material-ui/core/';
import { Rating } from '@material-ui/lab';
import { Feedback } from 'which-types';
@@ -17,7 +18,13 @@ interface PropTypes {
const useStyles = makeStyles(theme => ({
root: {
- margin: theme.spacing(4, 0, 1, 0)
+ margin: theme.spacing(4, 0, 1, 0),
+ position: 'relative'
+ },
+ versionChip: {
+ position: 'absolute',
+ right: theme.spacing(2),
+ top: theme.spacing(2)
}
}));
@@ -30,6 +37,12 @@ const ReviewCard: React.FC<PropTypes> = ({ feedback }) => {
user={feedback.author}
info={<Rating value={feedback.score} readOnly size="small" />}
/>
+ <Chip
+ size="small"
+ variant="outlined"
+ label={feedback.version}
+ className={classes.versionChip}
+ />
{feedback.contents && (
<>
<Divider />
diff --git a/src/containers/Home/Home.tsx b/src/containers/Home/Home.tsx
index 71b902b..4fd2833 100644
--- a/src/containers/Home/Home.tsx
+++ b/src/containers/Home/Home.tsx
@@ -38,8 +38,9 @@ const useStyles = makeStyles(theme => ({
marginLeft: theme.spacing(2)
},
reviews: {
+ margin: 'auto',
[theme.breakpoints.up('md')]: {
- padding: theme.spacing(0, 10)
+ width: '70%'
}
}
}));
@@ -75,7 +76,7 @@ const Home: React.FC = () => {
);
const FeedbackSection = feedbacks && feedbacks.findIndex(
- (feedback: Feedback) => feedback.author._id === user?._id
+ (feedback: Feedback) => (feedback.author._id === user?._id && feedback.version === release?.version)
) >= 0 ? (
<p>
You have already left feedback for this version.
@@ -88,7 +89,7 @@ const Home: React.FC = () => {
Here you can share your thougts about Which with us!
Note that you can ony leave feedback once per application version (there will be plenty of them later).
</p>
- {isAuthenticated ? <ReviewForm /> : (
+ {isAuthenticated ? <ReviewForm version={release?.version || 'N/A'} /> : (
<>
<p> You must be authorized to leave feedback.</p>
<Button
diff --git a/src/containers/Home/ReviewForm.tsx b/src/containers/Home/ReviewForm.tsx
index b626ce2..32f3b19 100644
--- a/src/containers/Home/ReviewForm.tsx
+++ b/src/containers/Home/ReviewForm.tsx
@@ -7,7 +7,10 @@ import { useSnackbar } from 'notistack';
import { post } from '../../requests';
-const version = 'v1.0.0';
+
+interface PropTypes {
+ version: string;
+}
const useStyles = makeStyles(theme => ({
root: {
@@ -19,7 +22,7 @@ const useStyles = makeStyles(theme => ({
}
}));
-const ReviewForm: React.FC = () => {
+const ReviewForm: React.FC<PropTypes> = ({ version }) => {
const [contents, setContents] = useState<string>('');
const [score, setScore] = useState<number>(0);
const classes = useStyles();
diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts
index 1d4110c..1793843 100644
--- a/src/hooks/APIClient.ts
+++ b/src/hooks/APIClient.ts
@@ -26,7 +26,7 @@ export const useFeedback = (): Response<Feedback[]> => {
return useSWR('/feedback', fetcher);
};
-interface Release {
+export interface Release {
url: string;
description: string;
version: string;