Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve statistic descriptions #205

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/i18n/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
{
"home": {
"statistics": {
"editorCount": {
"title": "Editor",
"description": "Number of edition done"
},
"contributorCount": {
"title": "Contributor",
"description": "Adding a new product"
},
"photographerCount": {
"title": "Photographer",
"description": "Taking photos for a product"
}
}
},
"questions": {
"category": "category",
"label": "label",
Expand Down Expand Up @@ -210,4 +226,4 @@
"redirect1": "Want to play some games?",
"redirect2": "Click here"
}
}
}
18 changes: 17 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
{
"home": {
"statistics": {
"editorCount": {
"title": "Editor",
"description": "Number of edition done"
},
"contributorCount": {
"title": "Contributor",
"description": "Adding a new product"
},
"photographerCount": {
"title": "Photographer",
"description": "Taking photos for a product"
}
}
},
"questions": {
"category": "category",
"label": "label",
Expand Down Expand Up @@ -210,4 +226,4 @@
"redirect1": "Want to play some games?",
"redirect2": "Click here"
}
}
}
23 changes: 17 additions & 6 deletions src/pages/home/UserData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import Card from "@mui/material/Card";
import CardContent from "@mui/material/CardContent";
import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack";
import { useTranslation } from "react-i18next";

const fetchUserData = async (userName) => {
console.log(userName);

const editorPromise = axios
.get(`https://world.openfoodfacts.org/editor/${userName}.json?fields=count`)
.then(({ data }) => {
Expand Down Expand Up @@ -42,18 +41,30 @@ const fetchUserData = async (userName) => {
photographerPromise,
]);

console.log(editorCount, contributorCount, photographerCount);
return { editorCount, contributorCount, photographerCount };
};

const CountCard = (props) => {
const { translationKey, value } = props;

const { t } = useTranslation();

return (
<Card sx={{ width: 300 }} elevation={3}>
<CardContent>
<Typography sx={{ fontSize: 16 }} color="text.secondary" gutterBottom>
{translationKey}
<Typography
sx={{ fontSize: 18, mb: 0 }}
color="text.primary"
gutterBottom
>
{t(`home.statistics.${translationKey}.title`)}
</Typography>
<Typography
sx={{ fontSize: 15, mb: 1 }}
color="text.secondary"
gutterBottom
>
{t(`home.statistics.${translationKey}.description`)}
</Typography>
<Typography variant="h3" color="text.primary" component="div">
{value.toLocaleString()}
Expand All @@ -74,7 +85,7 @@ const UserData = ({ userName }) => {
})
.catch(() => {});
}, [userName]);
console.log(counts);

return (
<Box sx={{ p: 2, mb: 10 }}>
<Typography component="h3" variant="h5" sx={{ pb: 3 }}>
Expand Down