Skip to content

Commit df81694

Browse files
Merge pull request #265 from Ashuza11/task-07-misleading-toast-message
Task 07: Fix misleading toast message for no data
2 parents 5f4674b + db14908 commit df81694

File tree

7 files changed

+1117
-795
lines changed

7 files changed

+1117
-795
lines changed

package-lock.json

Lines changed: 1106 additions & 788 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/fetchdata.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ const axiosInstance = axios.create({
77
},
88
});
99

10-
const fetchMostVisitedArticlesData = async ({ country, access, year, month, day }) => {
10+
const fetchMostVisitedArticlesData = async ({ country, access, year, month, day, t }) => {
1111
try {
1212
const formattedMonth = month.padStart(2, '0');
1313
const formattedDay = day.padStart(2, '0');
1414
const apiUrl = `https://wikimedia.org/api/rest_v1/metrics/pageviews/top-per-country/${country}/${access}/${year}/${formattedMonth}/${formattedDay}`;
1515
return await axiosInstance.get(apiUrl);
1616
} catch (error) {
17-
toast.error('Aucune donnée trouvée pour les paramètres passées', {
17+
toast.info(t('common.noResultsForFilters'), {
1818
autoClose: 5000,
1919
position: 'bottom-center',
2020
hideProgressBar: true,

src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"exportToJSON": "Export to JSON",
3939
"permanentLink": "Permanent Link",
4040
"linkCopied": "Link copied to clipboard!",
41-
"requestTimeout": "Request timed out. Please try again."
41+
"requestTimeout": "Request timed out. Please try again.",
42+
"noResultsForFilters": "No results found for the selected filters."
4243
},
4344
"article": {
4445
"description": "Description",

src/i18n/locales/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"exportToJSON": "Exportar a JSON",
3939
"permanentLink": "Enlace permanente",
4040
"linkCopied": "¡Enlace copiado al portapapeles!",
41-
"requestTimeout": "La solicitud ha expirado. Por favor, inténtelo de nuevo."
41+
"requestTimeout": "La solicitud ha expirado. Por favor, inténtelo de nuevo.",
42+
"noResultsForFilters": "Ningún resultado encontrado para los filtros seleccionados."
4243
},
4344
"article": {
4445
"description": "Descripción",

src/i18n/locales/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"exportToJSON": "Exporter en JSON",
3939
"permanentLink": "Lien permanent",
4040
"linkCopied": "Lien copié dans le presse-papiers !",
41-
"requestTimeout": "La requête a expiré. Veuillez réessayer."
41+
"requestTimeout": "La requête a expiré. Veuillez réessayer.",
42+
"noResultsForFilters": "Aucun résultat trouvé pour les filtres sélectionnés."
4243
},
4344
"article": {
4445
"description": "Description",

src/i18n/locales/sw.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"exportToJSON": "Hamisha kwa JSON",
3939
"permanentLink": "Kiungo cha kudumu",
4040
"linkCopied": "Kiungo kimekiliwa kwenye clipboard!",
41-
"requestTimeout": "Ombi limeisha. Tafadhali jaribu tena."
41+
"requestTimeout": "Ombi limeisha. Tafadhali jaribu tena.",
42+
"noResultsForFilters": "Hakuna matokeo yaliyopatikana kwa vichungi vilivyochaguliwa."
4243
},
4344
"article": {
4445
"description": "Maelezo",

src/pages/Home.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function App() {
4545
setLoading(true);
4646

4747
try {
48-
const response = await fetchArticles(formData);
48+
const response = await fetchArticles({ ...formData, t });
4949

5050
if (response && response.data && response.data.items && response.data.items.length > 0) {
5151
const trueArticles = await getTrueArticles(

0 commit comments

Comments
 (0)