From 6e71f97acf3ddb172317ed23033ec9971a1f9728 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 15:47:11 +0530 Subject: [PATCH 01/26] folder restructure --- public/locales/en/errors.json | 0 public/locales/{en.json => en/translation.json} | 0 public/locales/fr/errors.json | 0 public/locales/{fr.json => fr/translation.json} | 0 public/locales/hi/errors.json | 0 public/locales/{hi.json => hi/translation.json} | 0 public/locales/sp/errors.json | 0 public/locales/{sp.json => sp/translation.json} | 0 public/locales/zh/errors.json | 0 public/locales/{zh.json => zh/translation.json} | 0 src/utils/i18nForTest.ts | 2 +- 11 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 public/locales/en/errors.json rename public/locales/{en.json => en/translation.json} (100%) create mode 100644 public/locales/fr/errors.json rename public/locales/{fr.json => fr/translation.json} (100%) create mode 100644 public/locales/hi/errors.json rename public/locales/{hi.json => hi/translation.json} (100%) create mode 100644 public/locales/sp/errors.json rename public/locales/{sp.json => sp/translation.json} (100%) create mode 100644 public/locales/zh/errors.json rename public/locales/{zh.json => zh/translation.json} (100%) diff --git a/public/locales/en/errors.json b/public/locales/en/errors.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/en.json b/public/locales/en/translation.json similarity index 100% rename from public/locales/en.json rename to public/locales/en/translation.json diff --git a/public/locales/fr/errors.json b/public/locales/fr/errors.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/fr.json b/public/locales/fr/translation.json similarity index 100% rename from public/locales/fr.json rename to public/locales/fr/translation.json diff --git a/public/locales/hi/errors.json b/public/locales/hi/errors.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/hi.json b/public/locales/hi/translation.json similarity index 100% rename from public/locales/hi.json rename to public/locales/hi/translation.json diff --git a/public/locales/sp/errors.json b/public/locales/sp/errors.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/sp.json b/public/locales/sp/translation.json similarity index 100% rename from public/locales/sp.json rename to public/locales/sp/translation.json diff --git a/public/locales/zh/errors.json b/public/locales/zh/errors.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/zh.json b/public/locales/zh/translation.json similarity index 100% rename from public/locales/zh.json rename to public/locales/zh/translation.json diff --git a/src/utils/i18nForTest.ts b/src/utils/i18nForTest.ts index 527b96b5f9..7ea4c55536 100644 --- a/src/utils/i18nForTest.ts +++ b/src/utils/i18nForTest.ts @@ -4,7 +4,7 @@ import LanguageDetector from 'i18next-browser-languagedetector'; import HttpApi from 'i18next-http-backend'; import { languageArray } from './languages'; -import translationEnglish from '../../public/locales/en.json'; +import translationEnglish from '../../public/locales/en/translation.json'; i18n .use(LanguageDetector) From ae93cce9fc83f938cd3481fd9916da2fdbf1aad7 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 16:04:37 +0530 Subject: [PATCH 02/26] namespace added --- src/utils/i18n.ts | 4 +++- src/utils/i18nForTest.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index 6fb7cd4ff0..3aafbd843d 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -10,6 +10,8 @@ i18n .use(LanguageDetector) .use(HttpApi) .init({ + ns: ['translation', 'errors', 'common'], + defaultNS: 'translation', fallbackLng: 'en', supportedLngs: languageArray, detection: { @@ -17,7 +19,7 @@ i18n caches: ['cookie'], }, backend: { - loadPath: '/locales/{{lng}}.json', + loadPath: '/locales/{{lng}}/{{ns}}.json', }, // debug: true, }); diff --git a/src/utils/i18nForTest.ts b/src/utils/i18nForTest.ts index 7ea4c55536..929e830e2c 100644 --- a/src/utils/i18nForTest.ts +++ b/src/utils/i18nForTest.ts @@ -11,6 +11,8 @@ i18n .use(HttpApi) .use(initReactI18next) .init({ + ns: ['translation', 'errors', 'common'], + defaultNS: 'translation', fallbackLng: 'en', supportedLngs: languageArray, detection: { From dfa6b2b1985e4774116bc237050347f4238aa968 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 16:58:59 +0530 Subject: [PATCH 03/26] fix for 'register' common --- public/locales/en/common.json | 14 +++ public/locales/en/errors.json | 6 ++ public/locales/en/translation.json | 92 +++---------------- public/locales/fr/common.json | 0 public/locales/fr/translation.json | 12 +-- public/locales/hi/common.json | 0 public/locales/sp/common.json | 0 public/locales/zh/common.json | 0 .../core/AddOnRegister/AddOnRegister.tsx | 3 +- .../EventListCard/EventListCard.tsx | 2 + .../EventListCard/EventListCardModals.tsx | 4 +- .../LoginPortalToggle/LoginPortalToggle.tsx | 6 +- .../UserPortal/EventCard/EventCard.tsx | 5 +- src/components/UserPortal/Login/Login.tsx | 7 +- .../UserPortal/Register/Register.tsx | 7 +- src/screens/LoginPage/LoginPage.tsx | 13 +-- src/utils/errorHandler.tsx | 21 +++-- 17 files changed, 80 insertions(+), 112 deletions(-) create mode 100644 public/locales/en/common.json create mode 100644 public/locales/fr/common.json create mode 100644 public/locales/hi/common.json create mode 100644 public/locales/sp/common.json create mode 100644 public/locales/zh/common.json diff --git a/public/locales/en/common.json b/public/locales/en/common.json new file mode 100644 index 0000000000..e66b881ed3 --- /dev/null +++ b/public/locales/en/common.json @@ -0,0 +1,14 @@ +{ + "loading": "Loading...", + "admin": "ADMIN", + "user": "USER", + "superadmin": "SUPERADMIN", + "logout": "Logout", + "login": "Login", + "register": "Register", + "menu": "Menu", + "users": "Users", + "requests": "Requests", + "OR": "OR", + "cancel": "Cancel" +} diff --git a/public/locales/en/errors.json b/public/locales/en/errors.json index e69de29bb2..47dfbff9b5 100644 --- a/public/locales/en/errors.json +++ b/public/locales/en/errors.json @@ -0,0 +1,6 @@ +{ + "talawaApiUnavailable": "Talawa-API service is unavailable!. Is it running? Check your network connectivity too.", + "notFound": "Not found", + "unknownError": "An unknown error occurred. Please try again later. {{msg}}", + "notAuthorised": "Sorry! you are not Authorised!" +} diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 97d63a5073..58d57c0572 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -3,9 +3,7 @@ "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", "talawa_portal": "Talawa Admin Portal", - "login": "Login", "userLogin": "User Login", - "register": "Register", "firstName": "First Name", "lastName": "Last Name", "email": "Email", @@ -22,23 +20,16 @@ "enterEmail": "Enter Email", "enterPassword": "Enter Password", "doNotOwnAnAccount": "Do not own an account?", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "captchaError": "Captcha Error!", "Please_check_the_captcha": "Please, check the captcha.", "Something_went_wrong": "Something went wrong, Please try after sometime.", "passwordMismatches": "Password and Confirm password mismatches.", "fillCorrectly": "Fill all the Details Correctly.", - "notAuthorised": "Sorry! you are not Authorised!", - "notFound": "User not found!", "successfullyRegistered": "Successfully Registered. Please wait until you will be approved.", - "OR": "OR", - "admin": "ADMIN", - "user": "USER", "lowercase_check": "Atleast one lowercase letter", "uppercase_check": "Atleast one uppercase letter", "numeric_value_check": "Atleaset one numeric value", "special_char_check": "Atleast one special character", - "loading": "Loading...", "selectOrg": "Select an organization", "afterRegister": "Successfully registered. Please wait for admin to approve your request." }, @@ -46,8 +37,6 @@ "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", "talawa_portal": "Talawa Admin Portal", - "login": "Login", - "register": "Register", "firstName": "First Name", "lastName": "Last Name", "email": "Email", @@ -59,19 +48,14 @@ "enterEmail": "Enter Email", "enterPassword": "Enter Password", "doNotOwnAnAccount": "Do not own an account?", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "captchaError": "Captcha Error!", "Please_check_the_captcha": "Please, check the captcha.", "Something_went_wrong": "Something went wrong, Please try after sometime.", "passwordMismatches": "Password and Confirm password mismatches.", "fillCorrectly": "Fill all the Details Correctly.", - "notAuthorised": "Sorry! you are not Authorised!", - "notFound": "User not found!", "successfullyRegistered": "Successfully Registered. Please wait until you will be approved.", "userLogin": "User Login", "afterRegister": "Successfully registered. Please wait for admin to approve your request.", - "OR": "OR", - "loading": "Loading...", "selectOrg": "Select an organization" }, "latestEvents": { @@ -86,23 +70,16 @@ }, "listNavbar": { "talawa_portal": "Talawa Admin Portal", - "roles": "Roles", - "requests": "Requests", - "logout": "Logout" + "roles": "Roles" }, "leftDrawer": { "talawaAdminPortal": "Talawa Admin Portal", - "menu": "Menu", "my organizations": "My Organizations", - "users": "Users", "requests": "Membership Requests", - "communityProfile": "Community Profile", - "logout": "Logout" + "communityProfile": "Community Profile" }, "leftDrawerOrg": { "talawaAdminPortal": "Talawa Admin Portal", - "menu": "Menu", - "logout": "Logout", "talawa_portal": "Talawa Admin Portal", "Dashboard": "Dashboard", "People": "People", @@ -153,7 +130,6 @@ "Latest": "Latest", "Earliest": "Earliest", "filter": "Filter", - "cancel": "Cancel", "noOrgErrorTitle": "Organizations Not Found", "sampleOrgDuplicate": "Only one sample organization allowed", "noOrgErrorDescription": "Please create an organization through dashboard", @@ -163,7 +139,6 @@ "goToStore": "Go to Plugin Store", "enableEverything": "Enable Everything", "noResultsFoundFor": "No results found for", - "OR": "OR", "sampleOrgSuccess": "Sample Organization Successfully Created" }, "orgListCard": { @@ -196,7 +171,6 @@ "users": { "title": "Talawa Roles", "searchByName": "Search By Name", - "users": "Users", "name": "Name", "email": "Email", "joined_organizations": "Joined Organizations", @@ -221,8 +195,6 @@ "noOrgError": "Organizations not found, please create an organization through dashboard", "roleUpdated": "Role Updated.", "noResultsFoundFor": "No results found for ", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", - "cancel": "Cancel", "admins": "Admins", "members": "Members", "joinNow": "Join Now", @@ -252,15 +224,13 @@ "posts": "Posts", "events": "Events", "blockedUsers": "Blocked Users", - "requests": "Requests", "viewAll": "View All", "upcomingEvents": "Upcoming Events", "noUpcomingEvents": "No Upcoming Events", "latestPosts": "Latest Posts", "noPostsPresent": "No Posts Present", "membershipRequests": "Membership requests", - "noMembershipRequests": "No Membership requests present", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "noMembershipRequests": "No Membership requests present" }, "organizationPeople": { "title": "Talawa Members", @@ -269,7 +239,6 @@ "filterByEvent": "Filter by Event", "members": "Members", "admins": "Admins", - "users": "Users", "searchName": "Enter Name", "searchevent": "Enter Event", "searchFullName": "Enter Full Name", @@ -291,14 +260,12 @@ "enterConfirmPassword": "Enter your password to confirm", "organization": "Organization", "create": "Create", - "cancel": "Cancel", "invalidDetailsMessage": "Please enter valid details." }, "userListCard": { "joined": "Joined", "addAdmin": "Add Admin", - "addedAsAdmin": "User is added as admin.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "addedAsAdmin": "User is added as admin." }, "orgAdminListCard": { "joined": "Joined", @@ -307,8 +274,7 @@ "removeAdminMsg": "Do you want to remove this admin?", "no": "No", "yes": "Yes", - "adminRemoved": "The admin is removed.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "adminRemoved": "The admin is removed." }, "orgPeopleListCard": { "joined": "Joined", @@ -317,8 +283,7 @@ "removeMemberMsg": "Do you want to remove this member?", "no": "No", "yes": "Yes", - "memberRemoved": "The Member is removed", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "memberRemoved": "The Member is removed" }, "organizationEvents": { "title": "Events", @@ -346,7 +311,6 @@ "searchEventName": "Search Event Name", "eventType": "Event Type", "eventCreated": "Congratulations! The Event is created.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "customRecurrence": "Custom Recurrence", "repeatsEvery": "Repeats Every", "repeatsOn": "Repeats On", @@ -406,7 +370,6 @@ "description": "Description", "startDate": "Start Date", "endDate": "End Date", - "registerEvent": "Register", "alreadyRegistered": "Already registered", "startTime": "Start Time", "endTime": "End Time", @@ -419,7 +382,6 @@ "eventDetails": "Event Details", "eventDeleted": "Event deleted successfully.", "eventUpdated": "Event updated successfully.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "thisInstance": "This Instance", "thisAndFollowingInstances": "This & Following Instances", "allInstances": "All Instances", @@ -533,7 +495,6 @@ "postDes": "What do you to talk about?", "Title": "Title", "Text": "Text", - "cancel": "Cancel", "searchBy": "Search By", "Oldest": "Oldest First", "Latest": "Latest First", @@ -581,8 +542,7 @@ "postDeleted": "Post deleted successfully.", "postUpdated": "Post Updated successfully.", "tag": " Your browser does not support the video tag", - "pin": "Pin Post", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "pin": "Pin Post" }, "blockUnblockUser": { "title": "Block/Unblock User", @@ -597,7 +557,6 @@ "orgName": "Enter Name", "blockedSuccessfully": "User blocked successfully", "Un-BlockedSuccessfully": "User Un-Blocked successfully", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "allMembers": "All Members", "blockedUsers": "Blocked Users", "searchByFirstName": "Search By First Name", @@ -626,7 +585,6 @@ "userOtp": "e.g. 12345", "password": "Password", "emailNotRegistered": "Email is not registered.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "errorSendingMail": "Error in sending mail.", "passwordMismatches": "Password and Confirm password mismatches.", "passwordChanges": "Password changes successfully.", @@ -676,7 +634,6 @@ "deleteOrganization": "Delete Organization", "deleteSampleOrganization": "Delete Sample Organization", "deleteMsg": "Do you want to delete this organization?", - "cancel": "Cancel", "confirmDelete": "Confirm Delete", "longDelOrgMsg": "By clicking on Delete Organization button the organization will be permanently deleted along with its events, tags and all related data.", "successfullyDeletedSampleOrganization": "Successfully deleted sample Organization" @@ -691,15 +648,13 @@ "admin": "Admin", "superAdmin": "Superadmin", "displayImage": "Display Image", - "saveChanges": "Save Changes", - "cancel": "Cancel" + "saveChanges": "Save Changes" }, "userPasswordUpdate": { "previousPassword": "Previous Password", "newPassword": "New Password", "confirmNewPassword": "Confirm New Password", - "saveChanges": "Save Changes", - "cancel": "Cancel" + "saveChanges": "Save Changes" }, "orgDelete": { "deleteOrg": "Delete Org" @@ -708,8 +663,7 @@ "joined": "Joined", "accept": "Accept", "reject": "Reject", - "memberAdded": "it is accepted", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "memberAdded": "it is accepted" }, "orgUpdate": { "name": "Name", @@ -729,8 +683,7 @@ "isVisibleInSearch": "Visible in Search", "saveChanges": "Save Changes", "enterNameOrganization": "Enter Organization Name", - "successfulUpdated": "Organization updated successfully", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." + "successfulUpdated": "Organization updated successfully" }, "addOnRegister": { "addNew": "Add New", @@ -739,7 +692,6 @@ "creatorName": "Creator Name", "pluginDesc": "Plugin Description", "close": "Close", - "register": "Register", "pName": "Ex: Donations", "cName": "Ex: john Doe", "pDesc": "This Plugin enables UI for" @@ -801,12 +753,10 @@ "membershipRequests": "Membership requests", "adminForEvents": "Admin for events", "addedAsAdmin": "User is added as admin.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Kindly check your network connection and wait for a while.", "password": "Password", "userType": "User Type", "admin": "Admin", - "superAdmin": "Superadmin", - "cancel": "Cancel" + "superAdmin": "Superadmin" }, "userLogin": { "login": "Login", @@ -816,14 +766,11 @@ "enterEmail": "Enter your email address", "password": "Password", "enterPassword": "Enter your password", - "register": "Register", "invalidDetailsMessage": "Please enter a valid email and password.", "notAuthorised": "Sorry! you are not Authorised!", - "invalidCredentials": "Entered credentials are incorrect. Please enter valid credentials.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Kindly check your network connection and wait for a while." + "invalidCredentials": "Entered credentials are incorrect. Please enter valid credentials." }, "userRegister": { - "register": "Register", "firstName": "First Name", "enterFirstName": "Enter your first name", "lastName": "Last Name", @@ -838,8 +785,7 @@ "login": "Login", "afterRegister": "Successfully registered. Please wait for admin to approve your request.", "passwordNotMatch": "Password doesn't match. Confirm Password and try again.", - "invalidDetailsMessage": "Please enter valid details.", - "talawaApiUnavailable": "Talawa-API service is unavailable. Kindly check your network connection and wait for a while." + "invalidDetailsMessage": "Please enter valid details." }, "userNavbar": { "talawa": "Talawa", @@ -850,7 +796,6 @@ "donate": "Donate", "settings": "Settings", "language": "Language", - "logout": "Logout", "close": "Close" }, "userOrganizations": { @@ -869,12 +814,8 @@ "noOrganizations": "You haven't joined any organization yet.", "viewAll": "View all", "talawaUserPortal": "Talawa User Portal", - "menu": "Menu", "my organizations": "My Organizations", - "users": "Users", - "requests": "Requests", "communityProfile": "Community Profile", - "logout": "Logout", "settings": "Settings" }, "organizationSidebar": { @@ -986,7 +927,6 @@ "recurring": "Recurring Event", "startTime": "Start Time", "endTime": "End Time", - "cancel": "Cancel", "create": "Create", "listView": "List View", "calendarView": "Calendar View", @@ -1011,8 +951,7 @@ "starts": "Starts", "ends": "Ends", "creator": "Creator", - "alreadyRegistered": "Already registered", - "register": "Register" + "alreadyRegistered": "Already registered" }, "advertisement": { "title": "Advertisements", @@ -1124,7 +1063,6 @@ "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter Confirm Password", "organization": "Organization", - "cancel": "Cancel", "create": "Create", "invalidDetailsMessage": "Please provide all required details.", "passwordNotMatch": "Passwords do not match.", diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index ef9eed6c96..a3e4460594 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -22,7 +22,6 @@ "enterEmail": "entrez l'e-mail", "enterPassword": "Entrer le mot de passe", "doNotOwnAnAccount": "Vous n'avez pas de compte ?", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau.", "captchaError": "Erreur de captcha !", "Please_check_the_captcha": "Veuillez vérifier le captcha.", "Something_went_wrong": "Quelque chose s'est mal passé, veuillez réessayer plus tard.", @@ -57,7 +56,6 @@ "enterEmail": "Entrez l'e-mail", "enterPassword": "Entrez le mot de passe", "doNotOwnAnAccount": "Vous n'avez pas de compte ?", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau.", "captchaError": "Erreur de captcha !", "Please_check_the_captcha": "Veuillez vérifier le captcha.", "Something_went_wrong": "Quelque chose s'est mal passé, veuillez réessayer ultérieurement.", @@ -213,7 +211,6 @@ "filter": "Filtre", "roleUpdated": "Rôle mis à jour.", "noResultsFoundFor": "Aucun résultat trouvé pour ", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau.", "cancel": "Annuler", "admins": "Administrateurs", "members": "Membres", @@ -255,8 +252,7 @@ "latestPosts": "Derniers messages", "noPostsPresent": "Aucune publication présente", "membershipRequests": "Demandes d'adhésion", - "noMembershipRequests": "Aucune demande d'adhésion", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau." + "noMembershipRequests": "Aucune demande d'adhésion" }, "organizationPeople": { "title": "Membres Talawa", @@ -293,8 +289,7 @@ "userListCard": { "joined": "Inscrit", "addAdmin": "Ajouter un administrateur", - "addedAsAdmin": "L'utilisateur est ajouté en tant qu'administrateur.", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau." + "addedAsAdmin": "L'utilisateur est ajouté en tant qu'administrateur." }, "orgAdminListCard": { "joined": "Inscrit", @@ -303,8 +298,7 @@ "removeAdminMsg": "Voulez-vous supprimer cet administrateur ?", "no": "Non", "yes": "Oui", - "adminRemoved": "L'administrateur est supprimé.", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau." + "adminRemoved": "L'administrateur est supprimé." }, "orgPeopleListCard": { "joined": "Inscrit", diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/sp/common.json b/public/locales/sp/common.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx index f808d223e8..49363fae49 100644 --- a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx +++ b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx @@ -18,6 +18,7 @@ interface InterfaceFormStateTypes { function addOnRegister(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'addOnRegister' }); + const { t: tCommon } = useTranslation('common'); const { orgId: currentUrl } = useParams(); const navigate = useNavigate(); @@ -141,7 +142,7 @@ function addOnRegister(): JSX.Element { onClick={handleRegister} data-testid="addonregisterBtn" > - {t('register')} + {tCommon('register')} diff --git a/src/components/EventListCard/EventListCard.tsx b/src/components/EventListCard/EventListCard.tsx index cdcfabcde2..9d89647ee1 100644 --- a/src/components/EventListCard/EventListCard.tsx +++ b/src/components/EventListCard/EventListCard.tsx @@ -37,6 +37,7 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'eventListCard', }); + const { t: tCommon } = useTranslation('common'); const [eventModalIsOpen, setEventModalIsOpen] = useState(false); @@ -75,6 +76,7 @@ function eventListCard(props: InterfaceEventListCardProps): JSX.Element { eventModalIsOpen={eventModalIsOpen} hideViewModal={hideViewModal} t={t} + tCommon={tCommon} /> ); diff --git a/src/components/EventListCard/EventListCardModals.tsx b/src/components/EventListCard/EventListCardModals.tsx index 69c102910c..fe6cb22d1e 100644 --- a/src/components/EventListCard/EventListCardModals.tsx +++ b/src/components/EventListCard/EventListCardModals.tsx @@ -47,6 +47,7 @@ interface InterfaceEventListCardModalProps { eventModalIsOpen: boolean; hideViewModal: () => void; t: (key: string) => string; + tCommon: (key: string) => string; } function EventListCardModals({ @@ -54,6 +55,7 @@ function EventListCardModals({ eventModalIsOpen, hideViewModal, t, + tCommon, }: InterfaceEventListCardModalProps): JSX.Element { const { refetchEvents } = eventListCardProps; @@ -673,7 +675,7 @@ function EventListCardModals({ onClick={registerEventHandler} data-testid="registerEventBtn" > - {t('registerEvent')} + {tCommon('register')} ))} diff --git a/src/components/LoginPortalToggle/LoginPortalToggle.tsx b/src/components/LoginPortalToggle/LoginPortalToggle.tsx index 359cfd577a..c1feb9f4da 100644 --- a/src/components/LoginPortalToggle/LoginPortalToggle.tsx +++ b/src/components/LoginPortalToggle/LoginPortalToggle.tsx @@ -12,7 +12,7 @@ interface InterfaceLoginPortalToggleProps { function loginPortalToggle({ onToggle, }: InterfaceLoginPortalToggleProps): JSX.Element { - const { t } = useTranslation('translation', { keyPrefix: 'loginPage' }); + const { t: tCommon } = useTranslation('common'); const [activeRole, setActiveRole] = useState<'admin' | 'user'>('admin'); const handleNavLinkClick = (role: 'admin' | 'user'): void => { @@ -28,7 +28,7 @@ function loginPortalToggle({ to="/" onClick={() => handleNavLinkClick('admin')} > - {t('admin')} + {tCommon('admin')} @@ -37,7 +37,7 @@ function loginPortalToggle({ to="/" onClick={() => handleNavLinkClick('user')} > - {t('user')} + {tCommon('user')} diff --git a/src/components/UserPortal/EventCard/EventCard.tsx b/src/components/UserPortal/EventCard/EventCard.tsx index 20c08bab2b..d062aa4b7b 100644 --- a/src/components/UserPortal/EventCard/EventCard.tsx +++ b/src/components/UserPortal/EventCard/EventCard.tsx @@ -39,6 +39,7 @@ function eventCard(props: InterfaceEventCardProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'userEventCard', }); + const { t: tCommon } = useTranslation('common'); const { getItem } = useLocalStorage(); const userId = getItem('userId'); const creatorName = `${props.creator.firstName} ${props.creator.lastName}`; @@ -62,7 +63,7 @@ function eventCard(props: InterfaceEventCardProps): JSX.Element { setIsRegistered(true); toast.success(`Successfully registered for ${props.title}`); } - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ toast.error(error); } @@ -120,7 +121,7 @@ function eventCard(props: InterfaceEventCardProps): JSX.Element { ) : ( )} diff --git a/src/components/UserPortal/Login/Login.tsx b/src/components/UserPortal/Login/Login.tsx index 9fd40c3615..6cfe07aaca 100644 --- a/src/components/UserPortal/Login/Login.tsx +++ b/src/components/UserPortal/Login/Login.tsx @@ -19,6 +19,7 @@ interface InterfaceLoginProps { export default function login(props: InterfaceLoginProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'userLogin' }); + const { t: tCommon } = useTranslation('common'); const navigate = useNavigate(); @@ -52,7 +53,7 @@ export default function login(props: InterfaceLoginProps): JSX.Element { setItem('token', data.login.accessToken); setItem('userId', data.login.user._id); navigate('/user/organizations'); - } catch (error: any) { + } catch (error: unknown) { errorHandler(t, error); } } @@ -127,7 +128,7 @@ export default function login(props: InterfaceLoginProps): JSX.Element { onClick={handleLogin} data-testid="loginBtn" > - {t('login')} + {tCommon('login')}
); diff --git a/src/components/UserPortal/Register/Register.tsx b/src/components/UserPortal/Register/Register.tsx index f67674b4f8..a67f827736 100644 --- a/src/components/UserPortal/Register/Register.tsx +++ b/src/components/UserPortal/Register/Register.tsx @@ -20,6 +20,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { const { setCurrentMode } = props; const { t } = useTranslation('translation', { keyPrefix: 'userRegister' }); + const { t: tCommon } = useTranslation('common'); const handleModeChangeToLogin = (): void => { setCurrentMode('login'); @@ -70,7 +71,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { password: '', confirmPassword: '', }); - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -116,7 +117,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { return ( <> -

{t('register')}

+

{tCommon('register')}

{t('firstName')}
@@ -203,7 +204,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { onClick={handleRegister} data-testid="registerBtn" > - {t('register')} + {tCommon('register')}
diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index 834232fb8a..b92c74cd07 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -37,6 +37,7 @@ import { Autocomplete, TextField } from '@mui/material'; const loginPage = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'loginPage' }); + const { t: tCommon } = useTranslation('common'); const navigate = useNavigate(); const { getItem, setItem } = useLocalStorage(); @@ -418,7 +419,7 @@ const loginPage = (): JSX.Element => { >

- {role === 'admin' ? t('login') : t('userLogin')} + {role === 'admin' ? tCommon('login') : t('userLogin')}

{t('email')}
@@ -502,11 +503,11 @@ const loginPage = (): JSX.Element => { value="Login" data-testid="loginBtn" > - {t('login')} + {tCommon('login')}

- {t('OR')} + {tCommon('OR')}
@@ -530,7 +531,7 @@ const loginPage = (): JSX.Element => { >

- {t('register')} + {tCommon('register')}

@@ -839,7 +840,7 @@ const loginPage = (): JSX.Element => { value="Register" data-testid="registrationBtn" > - {t('register')} + {tCommon('register')}

diff --git a/src/utils/errorHandler.tsx b/src/utils/errorHandler.tsx index 508284db5a..1bc2aa8151 100644 --- a/src/utils/errorHandler.tsx +++ b/src/utils/errorHandler.tsx @@ -1,17 +1,24 @@ import type { TFunction } from 'react-i18next'; import { toast } from 'react-toastify'; +import i18n from './i18n'; /* This function is used to handle api errors in the application. It takes in the error object and displays the error message to the user. If the error is due to the Talawa API being unavailable, it displays a custom message. */ -export const errorHandler = ( - t: TFunction<'translation', string>, - error: any, -): void => { - if (error?.message === 'Failed to fetch') { - toast.error(t('talawaApiUnavailable')); +export const errorHandler = (a: unknown, error: unknown): void => { + const t: TFunction = i18n.getFixedT(null, 'errors'); + if (error instanceof Error) { + switch (error.message) { + case 'Failed to fetch': + console.log(error); + toast.error(t('talawaApiUnavailable')); + break; + // Add more cases as needed + default: + toast.error(error.message); + } } else { - toast.error(error?.message); + toast.error(t('unknownError', { msg: error })); } }; From 0c3d2f33ca037c104d146a384811379436e99c13 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 18:53:30 +0530 Subject: [PATCH 04/26] feat: Update screens to use tCommon for localization --- public/locales/en/common.json | 1 + public/locales/en/translation.json | 6 +-- .../AdvertisementEntry/AdvertisementEntry.tsx | 16 ++----- .../AdvertisementRegister.tsx | 10 ++-- src/components/DeleteOrg/DeleteOrg.tsx | 3 +- src/components/LeftDrawer/LeftDrawer.tsx | 7 ++- .../LeftDrawerOrg/LeftDrawerOrg.tsx | 3 +- src/components/OrgListCard/OrgListCard.tsx | 5 +- .../OrgProfileFieldSettings.tsx | 5 +- .../UserPasswordUpdate/UserPasswordUpdate.tsx | 9 ++-- src/components/UserPortal/Login/Login.tsx | 2 +- .../OrganizationCard/OrganizationCard.tsx | 17 ++++--- .../OrganizationNavbar/OrganizationNavbar.tsx | 9 ++-- .../UserPortal/Register/Register.tsx | 2 +- .../UserPortal/UserNavbar/UserNavbar.tsx | 3 +- .../UserPortal/UserSidebar/UserSidebar.tsx | 5 +- .../UserSidebarOrg/UserSidebarOrg.tsx | 3 +- src/screens/LoginPage/LoginPage.tsx | 4 +- src/screens/OrgList/OrgList.tsx | 46 ++++++++++--------- src/screens/OrgList/OrganizationModal.tsx | 4 +- src/screens/OrgPost/OrgPost.tsx | 13 ++++-- .../OrganizationDashboard.tsx | 27 ++++++----- .../OrganizationPeople/OrganizationPeople.tsx | 7 ++- src/screens/Users/Users.tsx | 9 ++-- 24 files changed, 121 insertions(+), 95 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index e66b881ed3..49787b114b 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -1,5 +1,6 @@ { "loading": "Loading...", + "admins": "Admins", "admin": "ADMIN", "user": "USER", "superadmin": "SUPERADMIN", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 58d57c0572..be0bd6166f 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -142,7 +142,6 @@ "sampleOrgSuccess": "Sample Organization Successfully Created" }, "orgListCard": { - "admins": "Admins", "members": "Members", "manage": "Manage", "sampleOrganization": "Sample Organization" @@ -195,7 +194,6 @@ "noOrgError": "Organizations not found, please create an organization through dashboard", "roleUpdated": "Role Updated.", "noResultsFoundFor": "No results found for ", - "admins": "Admins", "members": "Members", "joinNow": "Join Now", "visit": "Visit", @@ -220,7 +218,6 @@ "deleteThisOrganization": "Delete This Organization", "statistics": "Statistics", "members": "Members", - "admins": "Admins", "posts": "Posts", "events": "Events", "blockedUsers": "Blocked Users", @@ -238,7 +235,6 @@ "filterByLocation": "Filter by Location", "filterByEvent": "Filter by Event", "members": "Members", - "admins": "Admins", "searchName": "Enter Name", "searchevent": "Enter Event", "searchFullName": "Enter Full Name", @@ -970,7 +966,7 @@ "addNew": "Create new advertisement", "EXname": "Ex. Cookie Shop", "EXlink": "Ex. http://yourwebsite.com/photo", - "register": "Create Advertisement", + "createAdvertisement": "Create Advertisement", "close": "Close ", "deleteAdvertisement": "Delete Advertisement", "deleteAdvertisementMsg": "Do you want to remove this advertisement?", diff --git a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx index c6faa21de8..7c9fa915cb 100644 --- a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx +++ b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx @@ -10,14 +10,6 @@ import AdvertisementRegister from '../AdvertisementRegister/AdvertisementRegiste import MoreVertIcon from '@mui/icons-material/MoreVert'; import { toast } from 'react-toastify'; -type Ad = { - _id: string; - name: string; - type: 'BANNER' | 'MENU' | 'POPUP'; - mediaUrl: string; - endDate: string; // Assuming it's a string in the format 'yyyy-MM-dd' - startDate: string; // Assuming it's a string in the format 'yyyy-MM-dd' -}; interface InterfaceAddOnEntryProps { id: string; name: string; @@ -26,7 +18,7 @@ interface InterfaceAddOnEntryProps { organizationId: string; startDate: Date; endDate: Date; - setAfter: any; + setAfter: React.Dispatch>; } function advertisementEntry({ id, @@ -64,8 +56,10 @@ function advertisementEntry({ toast.error('Advertisement Deleted'); setButtonLoading(false); setAfter(null); - } catch (error: any) { - toast.error(error.message); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + } setButtonLoading(false); } }; diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index 8261c304f2..bb49c09f95 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -24,7 +24,7 @@ interface InterfaceAddOnRegisterProps { advertisementMediaEdit?: string; endDateEdit?: Date; startDateEdit?: Date; - setAfter: any; + setAfter: React.Dispatch>; } interface InterfaceFormStateTypes { name: string; @@ -198,8 +198,10 @@ function advertisementRegister({ handleClose(); setAfter(null); } - } catch (error: any) { - toast.error(error.message); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + } } }; return ( @@ -374,7 +376,7 @@ function advertisementRegister({ onClick={handleRegister} data-testid="addonregister" > - {t('register')} + {t('createAdvertisement')} ) : ( )} diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx index 02f44a55d7..3150b94666 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx @@ -28,6 +28,7 @@ const leftDrawerOrg = ({ setHideDrawer, }: InterfaceLeftDrawerProps): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'leftDrawerOrg' }); + const { t: tCommon } = useTranslation('common'); const [showDropdown, setShowDropdown] = React.useState(false); const [organization, setOrganization] = @@ -126,7 +127,7 @@ const leftDrawerOrg = ({ {/* Options List */}
- {t('menu')} + {tCommon('menu')}
{targets.map(({ name, url }, index) => { return url ? ( diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index ef1e5efeba..bacd03e432 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -50,6 +50,7 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgListCard', }); + const { t: tCommon } = useTranslation('common'); return ( <> @@ -83,8 +84,8 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {
)}
- {t('admins')}: {admins.length}      {' '} - {t('members')}: {members.length} + {tCommon('admins')}: {admins.length}     +   {t('members')}: {members.length}
diff --git a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx b/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx index 59acd2cf83..e778b4d35b 100644 --- a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx +++ b/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx @@ -19,10 +19,11 @@ export interface InterfaceCustomFieldData { name: string; } -const OrgProfileFieldSettings = (): any => { +const OrgProfileFieldSettings = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'orgProfileField', }); + const { t: tCommon } = useTranslation('common'); const [customFieldData, setCustomFieldData] = useState({ @@ -75,7 +76,7 @@ const OrgProfileFieldSettings = (): any => { } }; - if (loading) return

Loading... {t('loading')}

; + if (loading) return

Loading... {tCommon('loading')}

; if (error) return

{error.message}

; return ( diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx index cbb771be0e..b4c31be33d 100644 --- a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx +++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx @@ -17,6 +17,7 @@ const UserUpdate: React.FC< const { t } = useTranslation('translation', { keyPrefix: 'userPasswordUpdate', }); + const { t: tCommon } = useTranslation('common'); const [formState, setFormState] = React.useState({ previousPassword: '', newPassword: '', @@ -55,9 +56,11 @@ const UserUpdate: React.FC< window.location.reload(); }, 2000); } - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error.toString()); + if (error instanceof Error) { + toast.error(error.toString()); + } } }; @@ -143,7 +146,7 @@ const UserUpdate: React.FC< value="cancelchanges" onClick={cancelUpdate} > - {t('cancel')} + {tCommon('cancel')}
diff --git a/src/components/UserPortal/Login/Login.tsx b/src/components/UserPortal/Login/Login.tsx index 6cfe07aaca..67126ddb2a 100644 --- a/src/components/UserPortal/Login/Login.tsx +++ b/src/components/UserPortal/Login/Login.tsx @@ -81,7 +81,7 @@ export default function login(props: InterfaceLoginProps): JSX.Element { return ( <> -

{t('login')}

+

{tCommon('login')}

{t('emailAddress')}
diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx index 1d83eeac15..11e4d622b8 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx @@ -54,6 +54,7 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'users', }); + const { t: tCommon } = useTranslation('common'); const navigate = useNavigate(); @@ -94,12 +95,14 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { toast.success(t('orgJoined')); } refetch(); - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ - if (error.message === 'User is already a member') { - toast.error(t('AlreadyJoined')); - } else { - toast.error(t('errorOccured')); + if (error instanceof Error) { + if (error.message === 'User is already a member') { + toast.error(t('AlreadyJoined')); + } else { + toast.error(t('errorOccured')); + } } } } @@ -150,8 +153,8 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element {
)}
- {t('admins')}: {props.admins?.length}     -   {t('members')}: {props.members?.length} + {tCommon('admins')}: {props.admins?.length}   +     {t('members')}: {props.members?.length}
diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx index 7ecde0f275..bf48efa548 100644 --- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx +++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx @@ -30,10 +30,13 @@ function organizationNavbar(props: InterfaceNavbarProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'userNavbar', }); + const { t: tCommon } = useTranslation('common'); const navigate = useNavigate(); - const [organizationDetails, setOrganizationDetails]: any = React.useState({}); + const [organizationDetails, setOrganizationDetails] = React.useState<{ + name: string; + }>({ name: '' }); // const dropDirection: DropDirection = screen.width > 767 ? 'start' : 'down'; const dropDirection: DropDirection = 'start'; @@ -59,7 +62,7 @@ function organizationNavbar(props: InterfaceNavbarProps): JSX.Element { const userName = getItem('name'); React.useEffect(() => { if (data) { - setOrganizationDetails(data.organizationsConnection[0]); + setOrganizationDetails({ name: data.organizationsConnection[0].name }); } }, [data]); @@ -229,7 +232,7 @@ function organizationNavbar(props: InterfaceNavbarProps): JSX.Element { onClick={handleLogout} data-testid={`logoutBtn`} > - {t('logout')} + {tCommon('logout')} diff --git a/src/components/UserPortal/Register/Register.tsx b/src/components/UserPortal/Register/Register.tsx index a67f827736..42a9ea9b8c 100644 --- a/src/components/UserPortal/Register/Register.tsx +++ b/src/components/UserPortal/Register/Register.tsx @@ -214,7 +214,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { className={styles.loginText} data-testid="setLoginBtn" > - {t('login')} + {tCommon('login')} diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.tsx index d724c6b777..7135684ef6 100644 --- a/src/components/UserPortal/UserNavbar/UserNavbar.tsx +++ b/src/components/UserPortal/UserNavbar/UserNavbar.tsx @@ -20,6 +20,7 @@ function userNavbar(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'userNavbar', }); + const { t: tCommon } = useTranslation('common'); const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN); @@ -106,7 +107,7 @@ function userNavbar(): JSX.Element { {t('settings')} - {t('logout')} + {tCommon('logout')} diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.tsx index d7c362a5b2..5e91ff8b8e 100644 --- a/src/components/UserPortal/UserSidebar/UserSidebar.tsx +++ b/src/components/UserPortal/UserSidebar/UserSidebar.tsx @@ -17,6 +17,7 @@ const userSidebar = ({ setHideDrawer, }: InterfaceUserSidebarProps): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'userSidebarOrg' }); + const { t: tCommon } = useTranslation('common'); const handleLinkClick = (): void => { if (window.innerWidth <= 820) { @@ -38,7 +39,9 @@ const userSidebar = ({ >

{t('talawaUserPortal')}

-
{t('menu')}
+
+ {tCommon('menu')} +
{({ isActive }) => ( diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx index 03fbbd9c4f..7d78d3765e 100644 --- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx +++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx @@ -28,6 +28,7 @@ const UserSidebarOrg = ({ setHideDrawer, }: InterfaceUserSidebarOrgProps): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'userSidebarOrg' }); + const { t: tCommon } = useTranslation('common'); const [showDropdown, setShowDropdown] = React.useState(false); const [organization, setOrganization] = @@ -126,7 +127,7 @@ const UserSidebarOrg = ({ {/* Options List */}
- {t('menu')} + {tCommon('menu')}
{targets.map(({ name, url }, index) => { return url ? ( diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index b92c74cd07..3fbb33d91c 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -844,7 +844,7 @@ const loginPage = (): JSX.Element => {

- {t('OR')} + {tCommon('OR')}
diff --git a/src/screens/OrgList/OrgList.tsx b/src/screens/OrgList/OrgList.tsx index 7382aedd38..b052308f2b 100644 --- a/src/screens/OrgList/OrgList.tsx +++ b/src/screens/OrgList/OrgList.tsx @@ -32,6 +32,7 @@ import OrganizationModal from './OrganizationModal'; function orgList(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgList' }); + const { t: tCommon } = useTranslation('common'); const [dialogModalisOpen, setdialogModalIsOpen] = useState(false); const [dialogRedirectOrgId, setDialogRedirectOrgId] = useState(''); @@ -108,12 +109,6 @@ function orgList(): JSX.Element { error: errorList, refetch: refetchOrgs, fetchMore, - }: { - data: InterfaceOrgConnectionType | undefined; - loading: boolean; - error?: Error | undefined; - refetch: any; - fetchMore: any; } = useQuery(ORGANIZATION_CONNECTION_LIST, { variables: { first: perPageResult, @@ -234,7 +229,7 @@ function orgList(): JSX.Element { }); toggleModal(); } - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -269,9 +264,11 @@ function orgList(): JSX.Element { }); }; - const handleSearchByEnter = (e: any): void => { + const handleSearchByEnter = ( + e: React.KeyboardEvent, + ): void => { if (e.key === 'Enter') { - const { value } = e.target; + const { value } = e.currentTarget; handleSearch(value); } }; @@ -461,24 +458,28 @@ function orgList(): JSX.Element { } > {userData && superAdmin - ? orgsData?.organizationsConnection.map((item) => { - return ( -
- -
- ); - }) - : userData && - adminFor.length > 0 && - orgsData?.organizationsConnection.map((item) => { - if (isAdminForCurrentOrg(item)) { + ? orgsData?.organizationsConnection.map( + (item: InterfaceOrgConnectionInfoType) => { return (
); - } - })} + }, + ) + : userData && + adminFor.length > 0 && + orgsData?.organizationsConnection.map( + (item: InterfaceOrgConnectionInfoType) => { + if (isAdminForCurrentOrg(item)) { + return ( +
+ +
+ ); + } + }, + )} {isLoading && ( <> @@ -525,6 +526,7 @@ function orgList(): JSX.Element { setFormState={setFormState} createOrg={createOrg} t={t} + tCommon={tCommon} userData={userData} triggerCreateSampleOrg={triggerCreateSampleOrg} /> diff --git a/src/screens/OrgList/OrganizationModal.tsx b/src/screens/OrgList/OrganizationModal.tsx index 7be39cc246..cf10c993b9 100644 --- a/src/screens/OrgList/OrganizationModal.tsx +++ b/src/screens/OrgList/OrganizationModal.tsx @@ -43,6 +43,7 @@ interface InterfaceOrganizationModalProps { setFormState: (state: React.SetStateAction) => void; createOrg: (e: ChangeEvent) => Promise; t: (key: string) => string; + tCommon: (key: string) => string; userData: InterfaceUserType | undefined; triggerCreateSampleOrg: () => void; } @@ -58,6 +59,7 @@ const OrganizationModal: React.FC = ({ setFormState, createOrg, t, + tCommon, triggerCreateSampleOrg, }) => { // function to update the state of the parameters inside address. @@ -297,7 +299,7 @@ const OrganizationModal: React.FC = ({

- {t('OR')} + {tCommon('OR')}
{(adminFor.length > 0 || superAdmin) && (
diff --git a/src/screens/OrgPost/OrgPost.tsx b/src/screens/OrgPost/OrgPost.tsx index 677394e618..29b7de0614 100644 --- a/src/screens/OrgPost/OrgPost.tsx +++ b/src/screens/OrgPost/OrgPost.tsx @@ -47,6 +47,7 @@ function orgPost(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgPost', }); + const { t: tCommon } = useTranslation('common'); document.title = t('title'); const [postmodalisOpen, setPostModalIsOpen] = useState(false); @@ -95,7 +96,11 @@ function orgPost(): JSX.Element { }; loading: boolean; error?: ApolloError; - refetch: any; + refetch: (filterData?: { + id: string | undefined; + title_contains: string | null; + text_contains: string | null; + }) => void; } = useQuery(ORGANIZATION_POST_LIST, { variables: { id: currentUrl, @@ -167,7 +172,7 @@ function orgPost(): JSX.Element { }); setPostModalIsOpen(false); } - } catch (error: any) { + } catch (error: unknown) { errorHandler(t, error); } }; @@ -201,7 +206,7 @@ function orgPost(): JSX.Element { } }; - const handleSearch = (e: any): void => { + const handleSearch = (e: React.ChangeEvent): void => { const { value } = e.target; const filterData = { id: currentUrl, @@ -539,7 +544,7 @@ function orgPost(): JSX.Element { onClick={(): void => hideInviteModal()} data-testid="closeOrganizationModal" > - {t('cancel')} + {tCommon('cancel')}
diff --git a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx index 49363fae49..9f88775265 100644 --- a/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx +++ b/src/components/AddOn/core/AddOnRegister/AddOnRegister.tsx @@ -135,7 +135,7 @@ function addOnRegister(): JSX.Element { onClick={handleClose} data-testid="addonclose" > - {t('close')} + {tCommon('close')} {formStatus === 'register' ? (
@@ -278,7 +279,7 @@ const OrgActionItemCategories = (): any => { data-testid="formSubmitButton" > {modalType === 'Create' - ? t('createButton') + ? tCommon('create') : t('updateActionItemCategory')} diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index 17fa9fb94a..edbd4e4560 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -172,6 +172,7 @@ export default function orgPostCard( const { t } = useTranslation('translation', { keyPrefix: 'orgPostCard', }); + const { t: tCommon } = useTranslation('common'); const [deletePostMutation] = useMutation(DELETE_POST_MUTATION); const [updatePostMutation] = useMutation(UPDATE_POST_MUTATION); @@ -191,7 +192,7 @@ export default function orgPostCard( window.location.reload(); }); } - } catch (error: any) { + } catch (error: unknown) { errorHandler(t, error); } }; @@ -231,8 +232,10 @@ export default function orgPostCard( window.location.reload(); }, 2000); } - } catch (error: any) { - toast.error(error.message); + } catch (error: unknown) { + if (error instanceof Error) { + toast.error(error.message); + } } }; @@ -441,7 +444,7 @@ export default function orgPostCard( onClick={(): void => setMenuVisible(false)} data-testid="closebtn" > - {t('close')} + {tCommon('close')}
@@ -620,7 +623,7 @@ export default function orgPostCard( data-testid="closeOrganizationModal" type="button" > - {t('close')} + {tCommon('close')}
From 62397e7d2519cf5af4c263880c88d253f1ec1a8f Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 22:17:11 +0530 Subject: [PATCH 06/26] feat: Update screens to use tCommon for localization --- public/locales/en/common.json | 3 ++- public/locales/en/translation.json | 6 ++---- src/components/EventListCard/EventListCardModals.tsx | 1 + src/components/RecurrenceOptions/CustomRecurrenceModal.tsx | 4 +++- src/components/RecurrenceOptions/RecurrenceOptions.tsx | 3 +++ src/screens/OrganizationEvents/OrganizationEvents.tsx | 2 ++ 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 7b1d90ba13..a58f5f08c6 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -13,5 +13,6 @@ "OR": "OR", "cancel": "Cancel", "close": "Close", - "create": "Create" + "create": "Create", + "done": "Done" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index cb6212cb42..1ef1cd8576 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -312,8 +312,7 @@ "never": "Never", "on": "On", "after": "After", - "occurences": "occurences", - "done": "Done" + "occurences": "occurences" }, "organizationActionItems": { "actionItemCategory": "Action Item Category", @@ -383,8 +382,7 @@ "never": "Never", "on": "On", "after": "After", - "occurences": "occurences", - "done": "Done" + "occurences": "occurences" }, "funds": { "title": "Funds", diff --git a/src/components/EventListCard/EventListCardModals.tsx b/src/components/EventListCard/EventListCardModals.tsx index fe6cb22d1e..b33587c6b4 100644 --- a/src/components/EventListCard/EventListCardModals.tsx +++ b/src/components/EventListCard/EventListCardModals.tsx @@ -619,6 +619,7 @@ function EventListCardModals({ setRecurrenceRuleState={setRecurrenceRuleState} popover={popover} t={t} + tCommon={tCommon} /> )} diff --git a/src/components/RecurrenceOptions/CustomRecurrenceModal.tsx b/src/components/RecurrenceOptions/CustomRecurrenceModal.tsx index 890caaabdb..6867e5262f 100644 --- a/src/components/RecurrenceOptions/CustomRecurrenceModal.tsx +++ b/src/components/RecurrenceOptions/CustomRecurrenceModal.tsx @@ -35,6 +35,7 @@ interface InterfaceCustomRecurrenceModalProps { state: React.SetStateAction, ) => void; t: (key: string) => string; + tCommon: (key: string) => string; } const CustomRecurrenceModal: React.FC = ({ @@ -45,6 +46,7 @@ const CustomRecurrenceModal: React.FC = ({ hideCustomRecurrenceModal, setCustomRecurrenceModalIsOpen, t, + tCommon }) => { const { recurrenceStartDate, @@ -386,7 +388,7 @@ const CustomRecurrenceModal: React.FC = ({ data-testid="customRecurrenceSubmitBtn" onClick={handleCustomRecurrenceSubmit} > - {t('done')} + {tCommon('done')} diff --git a/src/components/RecurrenceOptions/RecurrenceOptions.tsx b/src/components/RecurrenceOptions/RecurrenceOptions.tsx index cf93410dab..f3a4e61226 100644 --- a/src/components/RecurrenceOptions/RecurrenceOptions.tsx +++ b/src/components/RecurrenceOptions/RecurrenceOptions.tsx @@ -19,6 +19,7 @@ interface InterfaceRecurrenceOptionsProps { ) => void; popover: JSX.Element; t: (key: string) => string; + tCommon: (key: string) => string; } const RecurrenceOptions: React.FC = ({ @@ -27,6 +28,7 @@ const RecurrenceOptions: React.FC = ({ setRecurrenceRuleState, popover, t, + tCommon, }) => { const [customRecurrenceModalIsOpen, setCustomRecurrenceModalIsOpen] = useState(false); @@ -220,6 +222,7 @@ const RecurrenceOptions: React.FC = ({ hideCustomRecurrenceModal={hideCustomRecurrenceModal} setCustomRecurrenceModalIsOpen={setCustomRecurrenceModalIsOpen} t={t} + tCommon={tCommon} /> ); diff --git a/src/screens/OrganizationEvents/OrganizationEvents.tsx b/src/screens/OrganizationEvents/OrganizationEvents.tsx index 0bf561381f..fc5436048d 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.tsx @@ -44,6 +44,7 @@ function organizationEvents(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'organizationEvents', }); + const { t: tCommon } = useTranslation('common'); const { getItem } = useLocalStorage(); @@ -470,6 +471,7 @@ function organizationEvents(): JSX.Element { setRecurrenceRuleState={setRecurrenceRuleState} popover={popover} t={t} + tCommon={tCommon} /> )} From c5b2a9db2ca6ed7a5969feb453590b4988d3dd81 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 22:34:09 +0530 Subject: [PATCH 07/26] feat: Update screens to use tCommon for localization - yes no --- public/locales/en/common.json | 4 +++- public/locales/en/translation.json | 22 +------------------ .../ActionItems/ActionItemsContainer.tsx | 2 ++ .../AdvertisementEntry/AdvertisementEntry.tsx | 5 +++-- .../EventListCard/EventListCardModals.tsx | 8 +++---- .../EventActionItems/EventActionItems.tsx | 5 +++-- .../OrgAdminListCard/OrgAdminListCard.tsx | 5 +++-- .../OrgPeopleListCard/OrgPeopleListCard.tsx | 5 +++-- src/components/OrgPostCard/OrgPostCard.tsx | 4 ++-- .../FundCampaignPledge/FundCampaignPledge.tsx | 2 ++ .../FundCampaignPledge/PledgeDeleteModal.tsx | 6 +++-- .../ActionItemDeleteModal.tsx | 6 +++-- .../CampaignDeleteModal.tsx | 6 +++-- .../OrganizationFundCampagins.tsx | 2 ++ 14 files changed, 40 insertions(+), 42 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index a58f5f08c6..ffa5d3c692 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -14,5 +14,7 @@ "cancel": "Cancel", "close": "Close", "create": "Create", - "done": "Done" + "done": "Done", + "yes": "Yes", + "no": "No" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 1ef1cd8576..73b583c006 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -266,8 +266,6 @@ "remove": "Remove", "removeAdmin": "Remove Admin", "removeAdminMsg": "Do you want to remove this admin?", - "no": "No", - "yes": "Yes", "adminRemoved": "The admin is removed." }, "orgPeopleListCard": { @@ -275,8 +273,6 @@ "remove": "Remove", "removeMember": "Remove Member", "removeMemberMsg": "Do you want to remove this member?", - "no": "No", - "yes": "Yes", "memberRemoved": "The Member is removed" }, "organizationEvents": { @@ -333,7 +329,6 @@ "editActionItem": "Edit Action Item", "isCompleted": "Completed", "latest": "Latest", - "no": "No", "noActionItems": "No Action Items", "options": "Options", "preCompletionNotes": "Pre Completion Notes", @@ -347,15 +342,12 @@ "successfulCreation": "Action Item created successfully", "successfulUpdation": "Action Item updated successfully", "successfulDeletion": "Action Item deleted successfully", - "title": "Action Items", - "yes": "Yes" + "title": "Action Items" }, "eventListCard": { "location": "Event Location", "deleteEvent": "Delete Event", "deleteEventMsg": "Do you want to remove this event?", - "no": "No", - "yes": "Yes", "editEvent": "Edit Event", "eventTitle": "Title", "description": "Description", @@ -401,8 +393,6 @@ "fundCreate": "Create Fund", "fundUpdate": "Update Fund", "fundDelete": "Delete Fund", - "no": "No", - "yes": "Yes", "manageFund": "Manage Fund", "searchFullName": "Search By Name", "filter": "Filter", @@ -436,8 +426,6 @@ "updateCampaign": "Update Fund Campaign", "manageCampaign": "Manage Fund Campaign", "deleteCampaign": "Delete Fund Campaign", - "no": "No", - "yes": "Yes", "currency": "Currency", "selectCurrency": "Select Currency", "filter": "Filter", @@ -462,8 +450,6 @@ "amount": "Amount", "editPledge": "Edit Pledge", "deletePledgeMsg": "Are you sure you want to delete this pledge?", - "no": "No", - "yes": "Yes", "noPledges": "No Pledges Found" }, "orgPost": { @@ -517,8 +503,6 @@ "edit": "Edit Post", "deletePost": "Delete Post", "deletePostMsg": "Do you want to remove this post?", - "no": "No", - "yes": "Yes", "editPost": "Edit Post", "postTitle": "Title", "postTitle1": "Edit title of the post", @@ -958,8 +942,6 @@ "createAdvertisement": "Create Advertisement", "deleteAdvertisement": "Delete Advertisement", "deleteAdvertisementMsg": "Do you want to remove this advertisement?", - "no": "No", - "yes": "Yes", "view": "View", "edit": "Edit", "editAdvertisement": "Edit Advertisement", @@ -1065,8 +1047,6 @@ "editActionItem": "Edit Action Item", "deleteActionItem": "Delete Action Item", "deleteActionItemMsg": "Do you want to remove this action item?", - "yes": "Yes", - "no": "No", "successfulDeletion": "Action Item deleted successfully", "successfulCreation": "Action Item created successfully", "successfulUpdation": "Action Item updated successfully", diff --git a/src/components/ActionItems/ActionItemsContainer.tsx b/src/components/ActionItems/ActionItemsContainer.tsx index 733591d9b2..0cb799c212 100644 --- a/src/components/ActionItems/ActionItemsContainer.tsx +++ b/src/components/ActionItems/ActionItemsContainer.tsx @@ -42,6 +42,7 @@ function actionItemsContainer({ const { t } = useTranslation('translation', { keyPrefix: 'organizationActionItems', }); + const { t: tCommon } = useTranslation('common'); const [actionItemPreviewModalIsOpen, setActionItemPreviewModalIsOpen] = useState(false); @@ -453,6 +454,7 @@ function actionItemsContainer({ deleteActionItemHandler={deleteActionItemHandler} toggleDeleteModal={toggleDeleteModal} t={t} + tCommon={tCommon} /> ); diff --git a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx index 7c9fa915cb..0b75f8e2ff 100644 --- a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx +++ b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx @@ -31,6 +31,7 @@ function advertisementEntry({ setAfter, }: InterfaceAddOnEntryProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'advertisement' }); + const { t: tCommon } = useTranslation('common'); const [buttonLoading, setButtonLoading] = useState(false); const [dropdown, setDropdown] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false); @@ -158,7 +159,7 @@ function advertisementEntry({ diff --git a/src/components/EventListCard/EventListCardModals.tsx b/src/components/EventListCard/EventListCardModals.tsx index b33587c6b4..f0f253e136 100644 --- a/src/components/EventListCard/EventListCardModals.tsx +++ b/src/components/EventListCard/EventListCardModals.tsx @@ -730,7 +730,7 @@ function EventListCardModals({ onClick={toggleRecurringEventUpdateModal} data-testid="eventUpdateOptionsModalCloseBtn" > - {t('no')} + {tCommon('no')} @@ -796,7 +796,7 @@ function EventListCardModals({ onClick={toggleDeleteModal} data-testid="eventDeleteModalCloseBtn" > - {t('no')} + {tCommon('no')} diff --git a/src/components/EventManagement/EventActionItems/EventActionItems.tsx b/src/components/EventManagement/EventActionItems/EventActionItems.tsx index d23cfd3bee..26273c213d 100644 --- a/src/components/EventManagement/EventActionItems/EventActionItems.tsx +++ b/src/components/EventManagement/EventActionItems/EventActionItems.tsx @@ -33,6 +33,7 @@ function eventActionItems(props: { eventId: string }): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'eventActionItems', }); + const { t: tCommon } = useTranslation('common'); const [actionItemCreateModalIsOpen, setActionItemCreateModalIsOpen] = useState(false); @@ -533,7 +534,7 @@ function eventActionItems(props: { eventId: string }): JSX.Element { onClick={toggleDeleteModal} data-testid="actionItemDeleteModalCloseBtn" > - {t('no')} + {tCommon('no')} diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.tsx index 6d60af9338..9afb47000d 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.tsx @@ -23,6 +23,7 @@ function orgAdminListCard(props: InterfaceOrgPeopleListCardProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgAdminListCard', }); + const { t: tCommon } = useTranslation('common'); const removeAdmin = async (): Promise => { try { @@ -55,14 +56,14 @@ function orgAdminListCard(props: InterfaceOrgPeopleListCardProps): JSX.Element { {t('removeAdminMsg')} diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx index 7e696e62db..781443847b 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx @@ -25,6 +25,7 @@ function orgPeopleListCard( const { t } = useTranslation('translation', { keyPrefix: 'orgPeopleListCard', }); + const { t: tCommon } = useTranslation('common'); const removeMember = async (): Promise => { try { @@ -59,7 +60,7 @@ function orgPeopleListCard( {t('removeMemberMsg')} diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index edbd4e4560..83092555b9 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -463,7 +463,7 @@ export default function orgPostCard( {t('deletePostMsg')} diff --git a/src/screens/FundCampaignPledge/FundCampaignPledge.tsx b/src/screens/FundCampaignPledge/FundCampaignPledge.tsx index fbaeeaa96c..171fc8b62e 100644 --- a/src/screens/FundCampaignPledge/FundCampaignPledge.tsx +++ b/src/screens/FundCampaignPledge/FundCampaignPledge.tsx @@ -38,6 +38,7 @@ const fundCampaignPledge = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'pledges', }); + const { t: tCommon } = useTranslation('common'); const [modalState, setModalState] = useState<{ [key in Modal]: boolean }>({ [Modal.CREATE]: false, @@ -341,6 +342,7 @@ const fundCampaignPledge = (): JSX.Element => { hideDeletePledgeModal={() => closeModal(Modal.DELETE)} deletePledgeHandler={deleteHandler} t={t} + tCommon={tCommon} /> ); diff --git a/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx b/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx index b6bc9fb20e..2cc7fdeaff 100644 --- a/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx +++ b/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx @@ -7,12 +7,14 @@ interface InterfaceDeletePledgeModal { hideDeletePledgeModal: () => void; deletePledgeHandler: () => Promise; t: (key: string) => string; + tCommon: (key: string) => string; } const PledgeDeleteModal: React.FC = ({ deletePledgeModalIsOpen, hideDeletePledgeModal, deletePledgeHandler, t, + tCommon, }) => { return ( <> @@ -41,14 +43,14 @@ const PledgeDeleteModal: React.FC = ({ onClick={deletePledgeHandler} data-testid="deleteyesbtn" > - {t('yes')} + {tCommon('yes')} diff --git a/src/screens/OrganizationActionItems/ActionItemDeleteModal.tsx b/src/screens/OrganizationActionItems/ActionItemDeleteModal.tsx index bdb63dad07..53b93ba9e5 100644 --- a/src/screens/OrganizationActionItems/ActionItemDeleteModal.tsx +++ b/src/screens/OrganizationActionItems/ActionItemDeleteModal.tsx @@ -7,6 +7,7 @@ interface InterfaceActionItemCreateModalProps { deleteActionItemHandler: () => Promise; toggleDeleteModal: () => void; t: (key: string) => string; + tCommon: (key: string) => string; } const ActionItemPreviewModal: React.FC = ({ @@ -14,6 +15,7 @@ const ActionItemPreviewModal: React.FC = ({ deleteActionItemHandler, toggleDeleteModal, t, + tCommon, }) => { return ( <> @@ -40,7 +42,7 @@ const ActionItemPreviewModal: React.FC = ({ onClick={toggleDeleteModal} data-testid="actionItemDeleteModalCloseBtn" > - {t('no')} + {tCommon('no')} diff --git a/src/screens/OrganizationFundCampaign/CampaignDeleteModal.tsx b/src/screens/OrganizationFundCampaign/CampaignDeleteModal.tsx index 97146c4bc9..58351e1d1d 100644 --- a/src/screens/OrganizationFundCampaign/CampaignDeleteModal.tsx +++ b/src/screens/OrganizationFundCampaign/CampaignDeleteModal.tsx @@ -7,12 +7,14 @@ interface InterfaceDeleteCampaignModal { hideDeleteCampaignModal: () => void; deleteCampaignHandler: () => Promise; t: (key: string) => string; + tCommon: (key: string) => string; } const CampaignDeleteModal: React.FC = ({ campaignDeleteModalIsOpen, hideDeleteCampaignModal, deleteCampaignHandler, t, + tCommon, }) => { return ( <> @@ -36,14 +38,14 @@ const CampaignDeleteModal: React.FC = ({ onClick={deleteCampaignHandler} data-testid="deleteyesbtn" > - {t('yes')} + {tCommon('yes')} diff --git a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx index 254616affc..dd7aeee1e0 100644 --- a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx +++ b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx @@ -57,6 +57,7 @@ const orgFundCampaign = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'fundCampaign', }); + const { t: tCommon } = useTranslation('common'); const navigate = useNavigate(); const { fundId: currentUrl, orgId: orgId } = useParams(); @@ -437,6 +438,7 @@ const orgFundCampaign = (): JSX.Element => { hideDeleteCampaignModal={hideDeleteCampaignModal} deleteCampaignHandler={deleteCampaignHandler} t={t} + tCommon={tCommon} /> ); From 4886d130d3749098d0de956930e4e53117655b0d Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 22:40:57 +0530 Subject: [PATCH 08/26] feat: Update screens to use tCommon for localization - saveChanges --- public/locales/en/common.json | 3 ++- public/locales/en/translation.json | 11 ++--------- .../AdvertisementRegister/AdvertisementRegister.tsx | 2 +- .../OrgProfileFieldSettings.tsx | 2 +- src/components/OrgUpdate/OrgUpdate.tsx | 5 +++-- .../UserPasswordUpdate/UserPasswordUpdate.tsx | 2 +- src/screens/MemberDetail/MemberDetail.tsx | 3 ++- src/screens/UserPortal/Settings/Settings.tsx | 5 +++-- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index ffa5d3c692..b4036bd107 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -16,5 +16,6 @@ "create": "Create", "done": "Done", "yes": "Yes", - "no": "No" + "no": "No", + "saveChanges": "Save Changes" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 73b583c006..5a5d03796d 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -619,14 +619,12 @@ "userType": "User Type", "admin": "Admin", "superAdmin": "Superadmin", - "displayImage": "Display Image", - "saveChanges": "Save Changes" + "displayImage": "Display Image" }, "userPasswordUpdate": { "previousPassword": "Previous Password", "newPassword": "New Password", - "confirmNewPassword": "Confirm New Password", - "saveChanges": "Save Changes" + "confirmNewPassword": "Confirm New Password" }, "orgDelete": { "deleteOrg": "Delete Org" @@ -653,7 +651,6 @@ "displayImage": "Display Image", "userRegistrationRequired": "User Registration Required", "isVisibleInSearch": "Visible in Search", - "saveChanges": "Save Changes", "enterNameOrganization": "Enter Organization Name", "successfulUpdated": "Organization updated successfully" }, @@ -716,7 +713,6 @@ "personalDetailsHeading": "Profile Details", "appLanguageCode": "Choose Language", "delete": "Delete User", - "saveChanges": "Save Changes", "pluginCreationAllowed": "Plugin creation allowed", "joined": "Joined", "created": "Created", @@ -836,7 +832,6 @@ "state": "City/State", "country": "Country", "resetChanges": "Reset Changes", - "saveChanges": "Save Changes", "profileDetails": "Profile Details", "deleteUserMessage": "By clicking on Delete User button your user will be permanently deleted along with its events, tags and all related data.", "copyLink": "Copy Profile Link", @@ -945,7 +940,6 @@ "view": "View", "edit": "Edit", "editAdvertisement": "Edit Advertisement", - "saveChanges": "Save Changes", "endOfResults": "End of results" }, "userChat": { @@ -963,7 +957,6 @@ "customFieldName": "Field Name", "enterCustomFieldName": "Enter Field name", "customFieldType": "Field Type", - "saveChanges": "Save Changes", "Remove Custom Field": "Remove Custom Field", "fieldSuccessMessage": "Field added successfully", "fieldRemovalSuccess": "Field removed successfully" diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index 33156eea01..1e7572928b 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -385,7 +385,7 @@ function advertisementRegister({ onClick={handleUpdate} data-testid="addonupdate" > - {t('saveChanges')} + {tCommon('saveChanges')} )} diff --git a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx b/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx index e778b4d35b..5e3aef276c 100644 --- a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx +++ b/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx @@ -161,7 +161,7 @@ const OrgProfileFieldSettings = (): JSX.Element => { className={styles.saveButton} data-testid="saveChangesBtn" > - {t('saveChanges')} + {tCommon('saveChanges')} diff --git a/src/components/OrgUpdate/OrgUpdate.tsx b/src/components/OrgUpdate/OrgUpdate.tsx index b19ba4af92..179b8d70e5 100644 --- a/src/components/OrgUpdate/OrgUpdate.tsx +++ b/src/components/OrgUpdate/OrgUpdate.tsx @@ -66,6 +66,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'orgUpdate', }); + const { t: tCommon } = useTranslation('common'); const { data, @@ -130,7 +131,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { refetch({ id: orgId }); toast.success(t('successfulUpdated')); } - } catch (error: any) { + } catch (error: unknown) { errorHandler(t, error); } }; @@ -332,7 +333,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { value="savechanges" onClick={onSaveChangesClicked} > - {t('saveChanges')} + {tCommon('saveChanges')} diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx index b4c31be33d..78fea1df53 100644 --- a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx +++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx @@ -138,7 +138,7 @@ const UserUpdate: React.FC< value="savechanges" onClick={loginLink} > - {t('saveChanges')} + {tCommon('saveChanges')} diff --git a/src/screens/UserPortal/Settings/Settings.tsx b/src/screens/UserPortal/Settings/Settings.tsx index 160137d07d..93bfab4a78 100644 --- a/src/screens/UserPortal/Settings/Settings.tsx +++ b/src/screens/UserPortal/Settings/Settings.tsx @@ -26,6 +26,7 @@ export default function settings(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'settings', }); + const { t: tCommon } = useTranslation('common'); const [hideDrawer, setHideDrawer] = useState(null); @@ -85,7 +86,7 @@ export default function settings(): JSX.Element { const userFullName = `${userDetails.firstName} ${userDetails.lastName}`; setItem('name', userFullName); } - } catch (error: any) { + } catch (error: unknown) { errorHandler(t, error); } }; @@ -568,7 +569,7 @@ export default function settings(): JSX.Element { data-testid="updateUserBtn" className={`${styles.cardButton}`} > - {t('saveChanges')} + {tCommon('saveChanges')} From 1beebb36b21741564fdbddd603c6ecfb4d59abf0 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Tue, 21 May 2024 22:54:14 +0530 Subject: [PATCH 09/26] feat: Update screens to use tCommon for localization - email, name, pass --- public/locales/en/common.json | 5 ++++- public/locales/en/translation.json | 14 ------------- src/components/UserPortal/Login/Login.tsx | 2 +- .../UserPortal/Register/Register.tsx | 2 +- src/screens/BlockUser/BlockUser.tsx | 17 ++++++++------- src/screens/ForgotPassword/ForgotPassword.tsx | 21 +++++++++++-------- src/screens/LoginPage/LoginPage.tsx | 14 +++++++------ src/screens/MemberDetail/MemberDetail.tsx | 4 ++-- src/screens/Requests/Requests.tsx | 5 +++-- src/screens/Users/Users.tsx | 4 ++-- 10 files changed, 43 insertions(+), 45 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index b4036bd107..c608649f00 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -17,5 +17,8 @@ "done": "Done", "yes": "Yes", "no": "No", - "saveChanges": "Save Changes" + "saveChanges": "Save Changes", + "email": "Email", + "name": "Name", + "password": "Password" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 5a5d03796d..9639abfb14 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -6,7 +6,6 @@ "userLogin": "User Login", "firstName": "First Name", "lastName": "Last Name", - "email": "Email", "password": "Password", "atleast_8_char_long": "Atleast 8 Character long", "atleast_6_char_long": "Atleast 6 Character long", @@ -39,7 +38,6 @@ "talawa_portal": "Talawa Admin Portal", "firstName": "First Name", "lastName": "Last Name", - "email": "Email", "password": "Password", "atleast_8_char_long": "Atleast 8 Character long", "Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.", @@ -103,9 +101,7 @@ "orgList": { "title": "Talawa Organizations", "you": "You", - "name": "Name", "designation": "Designation", - "email": "Email", "searchByName": "Search By Name", "my organizations": "My Organizations", "createOrganization": "Create Organization", @@ -152,8 +148,6 @@ "requests": { "title": "Membership Requests", "sl_no": "Sl. No.", - "name": "Name", - "email": "Email", "accept": "Accept", "reject": "Reject", "searchRequests": "Search membership requests", @@ -169,8 +163,6 @@ "users": { "title": "Talawa Roles", "searchByName": "Search By Name", - "name": "Name", - "email": "Email", "joined_organizations": "Joined Organizations", "blocked_organizations": "Blocked Organizations", "orgJoinedBy": "Organizations Joined By", @@ -521,8 +513,6 @@ "pageName": "Block/Unblock", "searchByName": "Search By Name", "listOfUsers": "List of Users who spammed", - "name": "Name", - "email": "Email", "block_unblock": "Block/Unblock", "unblock": "UnBlock", "block": "Block", @@ -613,7 +603,6 @@ "userUpdate": { "firstName": "First Name", "lastName": "Last Name", - "email": "Email", "password": "Password", "appLanguageCode": "Default Language", "userType": "User Type", @@ -636,7 +625,6 @@ "memberAdded": "it is accepted" }, "orgUpdate": { - "name": "Name", "description": "Description", "location": "Location", "address": "Address", @@ -690,7 +678,6 @@ "organizations": "Organizations", "events": "Events", "role": "Role", - "email": "Email", "createdOn": "Created on", "main": "Main", "firstName": "First name", @@ -1001,7 +988,6 @@ "venueTitleError": "Venue title cannot be empty!", "venueCapacityError": "Capacity must be a positive number!", "searchBy": "Search By", - "name": "Name", "desc": "Description" }, "addMember": { diff --git a/src/components/UserPortal/Login/Login.tsx b/src/components/UserPortal/Login/Login.tsx index 67126ddb2a..9126667c91 100644 --- a/src/components/UserPortal/Login/Login.tsx +++ b/src/components/UserPortal/Login/Login.tsx @@ -99,7 +99,7 @@ export default function login(props: InterfaceLoginProps): JSX.Element { -
{t('password')}
+
{tCommon('password')}
-
{t('password')}
+
{tCommon('password')}
{ const { t } = useTranslation('translation', { keyPrefix: 'blockUnblockUser', }); + const { t: tCommon } = useTranslation('common'); document.title = t('title'); const { orgId: currentUrl } = useParams(); @@ -87,7 +88,7 @@ const Requests = (): JSX.Element => { toast.success(t('blockedSuccessfully')); memberRefetch(); } - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -106,7 +107,7 @@ const Requests = (): JSX.Element => { toast.success(t('Un-BlockedSuccessfully')); memberRefetch(); } - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -126,9 +127,11 @@ const Requests = (): JSX.Element => { }); }; - const handleSearchByEnter = (e: any): void => { + const handleSearchByEnter = ( + e: React.KeyboardEvent, + ): void => { if (e.key === 'Enter') { - const { value } = e.target; + const { value } = e.currentTarget; handleSearch(value); } }; @@ -142,8 +145,8 @@ const Requests = (): JSX.Element => { const headerTitles: string[] = [ '#', - t('name'), - t('email'), + tCommon('name'), + tCommon('email'), t('block_unblock'), ]; @@ -268,7 +271,7 @@ const Requests = (): JSX.Element => { {user.email} {user.organizationsBlockedBy.some( - (spam: any) => spam._id === currentUrl, + (spam) => spam._id === currentUrl, ) ? ( - {t('password')} + + {tCommon('password')} +
{
- {t('email')} + {tCommon('email')}
{
- {t('password')} + {tCommon('password')}
setIsInputFocused(true)} onBlur={(): void => setIsInputFocused(false)} diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index 9047ce5725..d31d2d8b1f 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -350,7 +350,7 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { />
-

{t('email')}

+

{tCommon('email')}

= ({ id }): JSX.Element => { name="email" onChange={handleChange} required - placeholder={t('email')} + placeholder={tCommon('email')} />
diff --git a/src/screens/Requests/Requests.tsx b/src/screens/Requests/Requests.tsx index 16a85f15cd..d27f564beb 100644 --- a/src/screens/Requests/Requests.tsx +++ b/src/screens/Requests/Requests.tsx @@ -28,6 +28,7 @@ interface InterfaceRequestsListItem { const Requests = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'requests' }); + const { t: tCommon } = useTranslation('common'); document.title = t('title'); @@ -189,8 +190,8 @@ const Requests = (): JSX.Element => { const headerTitles: string[] = [ t('sl_no'), - t('name'), - t('email'), + tCommon('name'), + tCommon('email'), t('accept'), t('reject'), ]; diff --git a/src/screens/Users/Users.tsx b/src/screens/Users/Users.tsx index fedad9e0a5..618e8d4b97 100644 --- a/src/screens/Users/Users.tsx +++ b/src/screens/Users/Users.tsx @@ -235,8 +235,8 @@ const Users = (): JSX.Element => { const headerTitles: string[] = [ '#', - t('name'), - t('email'), + tCommon('name'), + tCommon('email'), t('joined_organizations'), t('blocked_organizations'), ]; From f741a5d85400a92155be5e3ac82ea23aa880bfda Mon Sep 17 00:00:00 2001 From: Pranshu Date: Wed, 22 May 2024 02:32:11 +0530 Subject: [PATCH 10/26] feat: Update screens to use tCommon for localization --- public/locales/en/common.json | 10 +- public/locales/en/translation.json | 50 +------- .../AdvertisementEntry/AdvertisementEntry.tsx | 2 +- src/components/LeftDrawer/LeftDrawer.tsx | 2 +- .../LeftDrawerOrg/LeftDrawerOrg.tsx | 5 +- src/components/OrgListCard/OrgListCard.tsx | 2 +- .../OrganizationCard/OrganizationCard.tsx | 3 +- .../OrganizationNavbar/OrganizationNavbar.tsx | 2 +- .../OrganizationSidebar.tsx | 107 ++++++++++-------- .../UserPortal/UserNavbar/UserNavbar.tsx | 2 +- .../UserPortal/UserSidebar/UserSidebar.tsx | 2 +- src/components/Venues/VenueCard.tsx | 3 +- src/screens/MemberDetail/MemberDetail.tsx | 4 +- .../OrganizationDashboard.tsx | 2 +- .../OrganizationFundCampagins.tsx | 2 +- .../OrganizationFunds/OrganizationFunds.tsx | 3 +- .../OrganizationPeople/OrganizationPeople.tsx | 2 +- src/screens/PageNotFound/PageNotFound.tsx | 3 +- src/screens/UserPortal/Chat/Chat.tsx | 41 +++---- .../Organizations/Organizations.tsx | 2 +- src/screens/UserPortal/People/People.tsx | 5 +- src/screens/UserPortal/Settings/Settings.tsx | 2 +- src/screens/Users/Users.tsx | 2 +- 23 files changed, 124 insertions(+), 134 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c608649f00..5fa1d8ce7d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -3,22 +3,28 @@ "admins": "Admins", "admin": "ADMIN", "user": "USER", - "superadmin": "SUPERADMIN", + "superAdmin": "SUPERADMIN", + "members": "Members", "logout": "Logout", "login": "Login", "register": "Register", "menu": "Menu", + "settings": "Settings", "users": "Users", "requests": "Requests", "OR": "OR", "cancel": "Cancel", "close": "Close", "create": "Create", + "delete": "Delete", "done": "Done", "yes": "Yes", "no": "No", + "filter": "Filter", + "search": "Search", "saveChanges": "Save Changes", "email": "Email", "name": "Name", - "password": "Password" + "password": "Password", + "talawaAdminPortal": "Talawa Admin Portal" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 9639abfb14..6834bd9949 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -2,7 +2,6 @@ "loginPage": { "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", - "talawa_portal": "Talawa Admin Portal", "userLogin": "User Login", "firstName": "First Name", "lastName": "Last Name", @@ -35,7 +34,6 @@ "userLoginPage": { "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", - "talawa_portal": "Talawa Admin Portal", "firstName": "First Name", "lastName": "Last Name", "password": "Password", @@ -67,18 +65,14 @@ "noPostsCreated": "No Posts Created" }, "listNavbar": { - "talawa_portal": "Talawa Admin Portal", "roles": "Roles" }, "leftDrawer": { - "talawaAdminPortal": "Talawa Admin Portal", "my organizations": "My Organizations", "requests": "Membership Requests", "communityProfile": "Community Profile" }, "leftDrawerOrg": { - "talawaAdminPortal": "Talawa Admin Portal", - "talawa_portal": "Talawa Admin Portal", "Dashboard": "Dashboard", "People": "People", "Events": "Events", @@ -91,7 +85,6 @@ "allOrganizations": "All Organizations", "yourOrganization": "Your Organization", "notification": "Notification", - "settings": "Settings", "language": "Language", "notifications": "Notifications", "spamsThe": "spams the", @@ -124,7 +117,6 @@ "sort": "Sort", "Latest": "Latest", "Earliest": "Earliest", - "filter": "Filter", "noOrgErrorTitle": "Organizations Not Found", "sampleOrgDuplicate": "Only one sample organization allowed", "noOrgErrorDescription": "Please create an organization through dashboard", @@ -137,7 +129,6 @@ "sampleOrgSuccess": "Sample Organization Successfully Created" }, "orgListCard": { - "members": "Members", "manage": "Manage", "sampleOrganization": "Sample Organization" }, @@ -172,20 +163,15 @@ "isNotBlockedByAnyOrg": "is not blocked by any organization", "searchByOrgName": "Search By Organization Name", "view": "View", - "admin": "ADMIN", - "superAdmin": "SUPERADMIN", - "user": "USER", "enterName": "Enter Name", "loadingUsers": "Loading Users...", "noUserFound": "No User Found", "sort": "Sort", "Newest": "Newest First", "Oldest": "Oldest First", - "filter": "Filter", "noOrgError": "Organizations not found, please create an organization through dashboard", "roleUpdated": "Role Updated.", "noResultsFoundFor": "No results found for ", - "members": "Members", "joinNow": "Join Now", "visit": "Visit", "withdraw": "Widthdraw" @@ -208,7 +194,6 @@ "about": "About", "deleteThisOrganization": "Delete This Organization", "statistics": "Statistics", - "members": "Members", "posts": "Posts", "events": "Events", "blockedUsers": "Blocked Users", @@ -225,7 +210,6 @@ "filterByName": "Filter by Name", "filterByLocation": "Filter by Location", "filterByEvent": "Filter by Event", - "members": "Members", "searchName": "Enter Name", "searchevent": "Enter Event", "searchFullName": "Enter Full Name", @@ -387,7 +371,6 @@ "fundDelete": "Delete Fund", "manageFund": "Manage Fund", "searchFullName": "Search By Name", - "filter": "Filter", "noFundsFound": "No Funds Found", "createdBy": "Created By", "createdOn": "Created On", @@ -420,7 +403,6 @@ "deleteCampaign": "Delete Fund Campaign", "currency": "Currency", "selectCurrency": "Select Currency", - "filter": "Filter", "searchFullName": "Search By Name" }, "pledges": { @@ -480,7 +462,6 @@ "organization not found!": "Organization Not Found!" }, "userNotFound": { - "user": "User", "not found!": "Not Found!", "roles": "Roles", "user not found!": "User Not Found!", @@ -581,12 +562,10 @@ }, "orgSettings": { "title": "Settings", - "pageName": "Settings", "general": "General", "actionItemCategories": "Action Item Categories", "updateOrganization": "Update Organization", "seeRequest": "See Request", - "settings": "Settings", "noData": "No data", "otherSettings": "Other Settings", "changeLanguage": "Change Language", @@ -606,8 +585,6 @@ "password": "Password", "appLanguageCode": "Default Language", "userType": "User Type", - "admin": "Admin", - "superAdmin": "Superadmin", "displayImage": "Display Image" }, "userPasswordUpdate": { @@ -660,9 +637,7 @@ "pHeading": "Plugins", "install": "Installed", "available": "Available", - "pMessage": "Plugin does not exists", - "filter": "Filters", - "search": "Search" + "pMessage": "Plugin does not exists" }, "addOnEntry": { "enable": "Enabled", @@ -699,7 +674,7 @@ "actionsHeading": "Actions", "personalDetailsHeading": "Profile Details", "appLanguageCode": "Choose Language", - "delete": "Delete User", + "deleteUser": "Delete User", "pluginCreationAllowed": "Plugin creation allowed", "joined": "Joined", "created": "Created", @@ -708,9 +683,7 @@ "adminForEvents": "Admin for events", "addedAsAdmin": "User is added as admin.", "password": "Password", - "userType": "User Type", - "admin": "Admin", - "superAdmin": "Superadmin" + "userType": "User Type" }, "userLogin": { "login": "Login", @@ -748,7 +721,6 @@ "events": "Events", "chat": "Chat", "donate": "Donate", - "settings": "Settings", "language": "Language" }, "userOrganizations": { @@ -756,11 +728,10 @@ "joinedOrganizations": "Joined Organizations", "createdOrganizations": "Created Organizations", "selectOrganization": "Select an organization", - "search": "Search users", + "searchUsers": "Search users", "nothingToShow": "Nothing to show here.", "organizations": "Organizations", - "searchByName": "Search By Name", - "filter": "Filter" + "searchByName": "Search By Name" }, "userSidebarOrg": { "yourOrganizations": "Your Organizations", @@ -768,19 +739,16 @@ "viewAll": "View all", "talawaUserPortal": "Talawa User Portal", "my organizations": "My Organizations", - "communityProfile": "Community Profile", - "settings": "Settings" + "communityProfile": "Community Profile" }, "organizationSidebar": { "viewAll": "View all", "events": "Events", - "members": "Members", "noEvents": "No Events to show", "noMembers": "No Members to show" }, "postCard": { "edit": "Edit", - "delete": "Delete", "likes": "Likes", "comments": "Comments" }, @@ -802,7 +770,6 @@ "article": "Article" }, "settings": { - "settings": "Settings", "profileSettings": "Profile Settings", "firstName": "First Name", "lastName": "Last Name", @@ -874,7 +841,6 @@ }, "userEvents": { "nothingToShow": "Nothing to show here.", - "search": "Search", "createEvent": "Create Event", "recurring": "Recurring Event", "startTime": "Start Time", @@ -909,7 +875,6 @@ "activeAds": "Active Campaigns", "archievedAds": "Completed Campaigns", "pMessage": "Ads not present for this campaign.", - "delete": "Delete", "validLink": "Link is valid", "invalidLink": "Link is invalid", "Rname": "Enter name of Advertisement", @@ -931,7 +896,6 @@ }, "userChat": { "chat": "Chat", - "search": "Search", "contacts": "Contacts" }, "userChatRoom": { @@ -984,7 +948,6 @@ "noVenues": "No Venues Found!", "edit": "Edit", "view": "View", - "delete": "Delete", "venueTitleError": "Venue title cannot be empty!", "venueCapacityError": "Capacity must be a positive number!", "searchBy": "Search By", @@ -1009,7 +972,6 @@ "organization": "Organization", "invalidDetailsMessage": "Please provide all required details.", "passwordNotMatch": "Passwords do not match.", - "user": "User", "addMember": "Add Member" }, "eventActionItems": { diff --git a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx index 0b75f8e2ff..cbc933a894 100644 --- a/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx +++ b/src/components/Advertisements/core/AdvertisementEntry/AdvertisementEntry.tsx @@ -97,7 +97,7 @@ function advertisementEntry({ />
  • - {t('delete')} + {tCommon('delete')}
  • )} diff --git a/src/components/LeftDrawer/LeftDrawer.tsx b/src/components/LeftDrawer/LeftDrawer.tsx index e601ba316a..dc501d6185 100644 --- a/src/components/LeftDrawer/LeftDrawer.tsx +++ b/src/components/LeftDrawer/LeftDrawer.tsx @@ -43,7 +43,7 @@ const leftDrawer = ({ data-testid="leftDrawerContainer" > -

    {t('talawaAdminPortal')}

    +

    {tCommon('talawaAdminPortal')}

    {tCommon('menu')}
    diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx index 3150b94666..4a52661e97 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx @@ -27,7 +27,6 @@ const leftDrawerOrg = ({ hideDrawer, setHideDrawer, }: InterfaceLeftDrawerProps): JSX.Element => { - const { t } = useTranslation('translation', { keyPrefix: 'leftDrawerOrg' }); const { t: tCommon } = useTranslation('common'); const [showDropdown, setShowDropdown] = React.useState(false); @@ -77,7 +76,9 @@ const leftDrawerOrg = ({ {/* Branding Section */}
    - {t('talawaAdminPortal')} + + {tCommon('talawaAdminPortal')} +
    {/* Organization Section */} diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index bacd03e432..bdba9107b0 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -85,7 +85,7 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { )}
    {tCommon('admins')}: {admins.length}     -   {t('members')}: {members.length} +   {tCommon('members')}: {members.length}
    diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx index 11e4d622b8..fdb2d040d9 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx @@ -154,7 +154,8 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { )}
    {tCommon('admins')}: {props.admins?.length}   -     {t('members')}: {props.members?.length} +     {tCommon('members')}:{' '} + {props.members?.length}
    diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx index bf48efa548..90cd75a83c 100644 --- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx +++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx @@ -225,7 +225,7 @@ function organizationNavbar(props: InterfaceNavbarProps): JSX.Element { - {t('settings')} + {tCommon('settings')}
    - {t('members')} + {tCommon('members')}
    {memberLoading ? (
    @@ -73,26 +78,31 @@ export default function organizationSidebar(): JSX.Element { ) : ( {members.length ? ( - members.map((member: any, index: React.Key | null | undefined) => { - const memberName = `${member.firstName} ${member.lastName}`; - return ( - -
    - -
    {memberName}
    -
    -
    - ); - }) + members.map( + ( + member: InterfaceMemberInfo, + index: React.Key | null | undefined, + ) => { + const memberName = `${member.firstName} ${member.lastName}`; + return ( + +
    + +
    {memberName}
    +
    +
    + ); + }, + ) ) : (
    {t('noMembers')}
    )} @@ -115,31 +125,36 @@ export default function organizationSidebar(): JSX.Element { ) : ( {events.length ? ( - events.map((event: any, index: React.Key | null | undefined) => { - return ( - -
    -
    -
    {event.title}
    -
    - + events.map( + ( + event: InterfaceQueryOrganizationEventListItem, + index: React.Key | null | undefined, + ) => { + return ( + +
    +
    +
    {event.title}
    +
    + +
    +
    +
    + Starts{' '} + {dayjs(event.startDate).format("D MMMM 'YY")} +
    +
    + Ends {dayjs(event.endDate).format("D MMMM 'YY")}
    -
    - Starts{' '} - {dayjs(event.startDate).format("D MMMM 'YY")} -
    -
    - Ends {dayjs(event.endDate).format("D MMMM 'YY")} -
    -
    - - ); - }) + + ); + }, + ) ) : (
    {t('noEvents')}
    )} diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.tsx index 7135684ef6..f58c061440 100644 --- a/src/components/UserPortal/UserNavbar/UserNavbar.tsx +++ b/src/components/UserPortal/UserNavbar/UserNavbar.tsx @@ -104,7 +104,7 @@ function userNavbar(): JSX.Element { onClick={() => navigate('/user/settings')} className={styles.link} > - {t('settings')} + {tCommon('settings')} {tCommon('logout')} diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.tsx index 5e91ff8b8e..563172fc07 100644 --- a/src/components/UserPortal/UserSidebar/UserSidebar.tsx +++ b/src/components/UserPortal/UserSidebar/UserSidebar.tsx @@ -83,7 +83,7 @@ const userSidebar = ({ }`} />
    - {t('settings')} + {tCommon('settings')} )} diff --git a/src/components/Venues/VenueCard.tsx b/src/components/Venues/VenueCard.tsx index 1132986e68..4df29eb3eb 100644 --- a/src/components/Venues/VenueCard.tsx +++ b/src/components/Venues/VenueCard.tsx @@ -22,6 +22,7 @@ const VenueCard = ({ const { t } = useTranslation('translation', { keyPrefix: 'organizationVenues', }); + const { t: tCommon } = useTranslation('common'); return (
    handleDelete(venueItem._id)} > - {t('delete')} + {tCommon('delete')}
    diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index d31d2d8b1f..3e416b939f 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -512,12 +512,12 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => {
    diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx index cf791db773..5c32d292a3 100644 --- a/src/screens/OrganizationDashboard/OrganizationDashboard.tsx +++ b/src/screens/OrganizationDashboard/OrganizationDashboard.tsx @@ -134,7 +134,7 @@ function organizationDashboard(): JSX.Element { > } /> diff --git a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx index dd7aeee1e0..cab7566ad5 100644 --- a/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx +++ b/src/screens/OrganizationFundCampaign/OrganizationFundCampagins.tsx @@ -299,7 +299,7 @@ const orgFundCampaign = (): JSX.Element => { data-testid="filter" > - {t('filter')} + {tCommon('filter')} diff --git a/src/screens/OrganizationFunds/OrganizationFunds.tsx b/src/screens/OrganizationFunds/OrganizationFunds.tsx index 2f67f61edc..cecedff2f1 100644 --- a/src/screens/OrganizationFunds/OrganizationFunds.tsx +++ b/src/screens/OrganizationFunds/OrganizationFunds.tsx @@ -55,6 +55,7 @@ const organizationFunds = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'funds', }); + const { t: tCommon } = useTranslation('common'); const { orgId: currentUrl } = useParams(); const navigate = useNavigate(); @@ -274,7 +275,7 @@ const organizationFunds = (): JSX.Element => { data-testid="filter" > - {t('filter')} + {tCommon('filter')} diff --git a/src/screens/OrganizationPeople/OrganizationPeople.tsx b/src/screens/OrganizationPeople/OrganizationPeople.tsx index 92ec957b3d..227a645292 100644 --- a/src/screens/OrganizationPeople/OrganizationPeople.tsx +++ b/src/screens/OrganizationPeople/OrganizationPeople.tsx @@ -332,7 +332,7 @@ function organizationPeople(): JSX.Element { setState(0); }} > - +
    { const { t } = useTranslation('translation', { keyPrefix: 'pageNotFound', }); + const { t: tCommon } = useTranslation('common'); document.title = t('title'); @@ -22,7 +23,7 @@ const PageNotFound = (): JSX.Element => {
    Logo {adminFor != undefined ? ( -

    {t('talawaAdmin')}

    +

    {tCommon('talawaAdmin')}

    ) : (

    {t('talawaUser')}

    )} diff --git a/src/screens/UserPortal/Chat/Chat.tsx b/src/screens/UserPortal/Chat/Chat.tsx index 4757ac9dcc..ee6a6c04f1 100644 --- a/src/screens/UserPortal/Chat/Chat.tsx +++ b/src/screens/UserPortal/Chat/Chat.tsx @@ -30,6 +30,7 @@ export default function chat(): JSX.Element { const { t } = useTranslation('translation', { keyPrefix: 'userChat', }); + const { t: tCommon } = useTranslation('common'); const organizationId = getOrganizationId(location.href); const [selectedContact, setSelectedContact] = React.useState(''); @@ -37,10 +38,6 @@ export default function chat(): JSX.Element { const [contacts, setContacts] = React.useState([]); const [filterName, setFilterName] = React.useState(''); - const navbarProps = { - currentPage: 'chat', - }; - const chatRoomProps: InterfaceChatRoomProps = { selectedContact, }; @@ -63,9 +60,11 @@ export default function chat(): JSX.Element { firstName_contains: value, }); }; - const handleSearchByEnter = (e: any): void => { + const handleSearchByEnter = ( + e: React.KeyboardEvent, + ): void => { if (e.key === 'Enter') { - const { value } = e.target; + const { value } = e.currentTarget; handleSearch(value); } }; @@ -95,7 +94,7 @@ export default function chat(): JSX.Element { Loading...
    ) : ( - contacts.map((contact: any, index: number) => { - const cardProps: InterfaceContactCardProps = { - id: contact._id, - firstName: contact.firstName, - lastName: contact.lastName, - email: contact.email, - image: contact.image, - setSelectedContactName, - selectedContact, - setSelectedContact, - }; - return ; - }) + contacts.map( + (contact: InterfaceContactCardProps, index: number) => { + const cardProps: InterfaceContactCardProps = { + id: contact.id, + firstName: contact.firstName, + lastName: contact.lastName, + email: contact.email, + image: contact.image, + setSelectedContactName, + selectedContact, + setSelectedContact, + }; + return ; + }, + ) )} diff --git a/src/screens/UserPortal/Organizations/Organizations.tsx b/src/screens/UserPortal/Organizations/Organizations.tsx index f9fae1f671..433416387d 100644 --- a/src/screens/UserPortal/Organizations/Organizations.tsx +++ b/src/screens/UserPortal/Organizations/Organizations.tsx @@ -273,7 +273,7 @@ export default function organizations(): JSX.Element {
    - {t('filter').toUpperCase()} + {tCommon('filter').toUpperCase()} {modes.map((value, index) => { diff --git a/src/screens/UserPortal/Settings/Settings.tsx b/src/screens/UserPortal/Settings/Settings.tsx index 93bfab4a78..1167f56446 100644 --- a/src/screens/UserPortal/Settings/Settings.tsx +++ b/src/screens/UserPortal/Settings/Settings.tsx @@ -209,7 +209,7 @@ export default function settings(): JSX.Element {
    -

    {t('settings')}

    +

    {tCommon('settings')}

    { data-testid="filterUsers" > - {t('filter')} + {tCommon('filter')} Date: Wed, 22 May 2024 03:03:41 +0530 Subject: [PATCH 11/26] remove pass --- public/locales/en/translation.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 6834bd9949..0d4f45325d 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -5,7 +5,6 @@ "userLogin": "User Login", "firstName": "First Name", "lastName": "Last Name", - "password": "Password", "atleast_8_char_long": "Atleast 8 Character long", "atleast_6_char_long": "Atleast 6 Character long", "firstName_invalid": "First name should contain only lower and upper case letters", @@ -36,7 +35,6 @@ "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", "firstName": "First Name", "lastName": "Last Name", - "password": "Password", "atleast_8_char_long": "Atleast 8 Character long", "Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.", "confirmPassword": "Confirm Password", @@ -225,7 +223,6 @@ "enterLastName": "Enter your last name", "emailAddress": "Email Address", "enterEmail": "Enter your email address", - "password": "Password", "enterPassword": "Enter your password", "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter your password to confirm", @@ -526,7 +523,6 @@ "changePassword": "Change Password", "backToLogin": "Back to Login", "userOtp": "e.g. 12345", - "password": "Password", "emailNotRegistered": "Email is not registered.", "errorSendingMail": "Error in sending mail.", "passwordMismatches": "Password and Confirm password mismatches.", @@ -582,7 +578,6 @@ "userUpdate": { "firstName": "First Name", "lastName": "Last Name", - "password": "Password", "appLanguageCode": "Default Language", "userType": "User Type", "displayImage": "Display Image" @@ -682,7 +677,6 @@ "membershipRequests": "Membership requests", "adminForEvents": "Admin for events", "addedAsAdmin": "User is added as admin.", - "password": "Password", "userType": "User Type" }, "userLogin": { @@ -691,7 +685,6 @@ "loginIntoYourAccount": "Login into your account", "emailAddress": "Email Address", "enterEmail": "Enter your email address", - "password": "Password", "enterPassword": "Enter your password", "invalidDetailsMessage": "Please enter a valid email and password.", "notAuthorised": "Sorry! you are not Authorised!", @@ -704,7 +697,6 @@ "enterLastName": "Enter your last name", "emailAddress": "Email Address", "enterEmail": "Enter your email address", - "password": "Password", "enterPassword": "Enter your password", "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter your password to confirm", @@ -965,7 +957,6 @@ "enterLastName": "Enter Last Name", "emailAddress": "Email Address", "enterEmail": "Enter Email", - "password": "Password", "enterPassword": "Enter Password", "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter Confirm Password", From 14ccda14d3f40b44ff99946cc281b8471887188e Mon Sep 17 00:00:00 2001 From: Pranshu Date: Wed, 22 May 2024 05:05:41 +0530 Subject: [PATCH 12/26] Update localization for first name and last name fields --- public/locales/en/common.json | 2 ++ public/locales/en/translation.json | 14 -------------- src/components/UserPortal/Register/Register.tsx | 4 ++-- src/screens/LoginPage/LoginPage.tsx | 8 ++++---- src/screens/MemberDetail/MemberDetail.tsx | 8 ++++---- src/screens/UserPortal/Settings/Settings.tsx | 4 ++-- 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 5fa1d8ce7d..fd904784ed 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -1,4 +1,6 @@ { + "firstName": "First Name", + "lastName": "Last Name", "loading": "Loading...", "admins": "Admins", "admin": "ADMIN", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 0d4f45325d..381b3d1a73 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -3,8 +3,6 @@ "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", "userLogin": "User Login", - "firstName": "First Name", - "lastName": "Last Name", "atleast_8_char_long": "Atleast 8 Character long", "atleast_6_char_long": "Atleast 6 Character long", "firstName_invalid": "First name should contain only lower and upper case letters", @@ -33,8 +31,6 @@ "userLoginPage": { "title": "Talawa Admin", "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", - "firstName": "First Name", - "lastName": "Last Name", "atleast_8_char_long": "Atleast 8 Character long", "Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.", "confirmPassword": "Confirm Password", @@ -217,9 +213,7 @@ "addMembers": "Add Members", "existingUser": "Existing User", "newUser": "New User", - "firstName": "First Name", "enterFirstName": "Enter your first name", - "lastName": "Last Name", "enterLastName": "Enter your last name", "emailAddress": "Email Address", "enterEmail": "Enter your email address", @@ -576,8 +570,6 @@ "successfullyDeletedSampleOrganization": "Successfully deleted sample Organization" }, "userUpdate": { - "firstName": "First Name", - "lastName": "Last Name", "appLanguageCode": "Default Language", "userType": "User Type", "displayImage": "Display Image" @@ -691,9 +683,7 @@ "invalidCredentials": "Entered credentials are incorrect. Please enter valid credentials." }, "userRegister": { - "firstName": "First Name", "enterFirstName": "Enter your first name", - "lastName": "Last Name", "enterLastName": "Enter your last name", "emailAddress": "Email Address", "enterEmail": "Enter your email address", @@ -763,8 +753,6 @@ }, "settings": { "profileSettings": "Profile Settings", - "firstName": "First Name", - "lastName": "Last Name", "gender": "Gender", "emailAddress": "Email Address", "phoneNumber": "Phone Number", @@ -951,9 +939,7 @@ "existingUser": "Existing User", "newUser": "New User", "searchFullName": "Search by Full Name", - "firstName": "First Name", "enterFirstName": "Enter First Name", - "lastName": "Last Name", "enterLastName": "Enter Last Name", "emailAddress": "Email Address", "enterEmail": "Enter Email", diff --git a/src/components/UserPortal/Register/Register.tsx b/src/components/UserPortal/Register/Register.tsx index b1e4cc1db5..c1503cd58a 100644 --- a/src/components/UserPortal/Register/Register.tsx +++ b/src/components/UserPortal/Register/Register.tsx @@ -119,7 +119,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { <>

    {tCommon('register')}

    -
    {t('firstName')}
    +
    {tCommon('firstName')}
    -
    {t('lastName')}
    +
    {tCommon('lastName')}
    {
    - {t('firstName')} + {tCommon('firstName')} { @@ -557,12 +557,12 @@ const loginPage = (): JSX.Element => {
    - {t('lastName')} + {tCommon('lastName')} { diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index 3e416b939f..b72d482840 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -225,7 +225,7 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => {
    -

    {t('firstName')}

    +

    {tCommon('firstName')}

    = ({ id }): JSX.Element => { name="firstName" onChange={handleChange} required - placeholder={t('firstName')} + placeholder={tCommon('firstName')} />
    -

    {t('lastName')}

    +

    {tCommon('lastName')}

    = ({ id }): JSX.Element => { name="lastName" onChange={handleChange} required - placeholder={t('lastName')} + placeholder={tCommon('lastName')} />
    diff --git a/src/screens/UserPortal/Settings/Settings.tsx b/src/screens/UserPortal/Settings/Settings.tsx index 1167f56446..bffd3adca0 100644 --- a/src/screens/UserPortal/Settings/Settings.tsx +++ b/src/screens/UserPortal/Settings/Settings.tsx @@ -233,7 +233,7 @@ export default function settings(): JSX.Element { htmlFor="inputFirstName" className={`${styles.cardLabel}`} > - {t('firstName')} + {tCommon('firstName')} - {t('lastName')} + {tCommon('lastName')} Date: Wed, 22 May 2024 06:07:56 +0530 Subject: [PATCH 13/26] tCommon fixes --- public/locales/en/common.json | 18 ++- public/locales/en/translation.json | 92 +----------- .../Advertisements/Advertisements.tsx | 7 +- .../AdvertisementRegister.tsx | 2 +- .../EventListCard/EventListCardModals.tsx | 8 +- .../MemberRequestCard/MemberRequestCard.tsx | 7 +- .../OrgActionItemCategories.tsx | 2 +- src/components/OrgPostCard/OrgPostCard.tsx | 2 +- src/components/OrgUpdate/OrgUpdate.tsx | 10 +- .../CustomRecurrenceModal.tsx | 4 +- .../UserPortal/EventCard/EventCard.tsx | 2 +- src/components/UserPortal/Login/Login.tsx | 8 +- .../UserPortal/Register/Register.tsx | 8 +- .../UserProfileSettings/UserProfile.tsx | 3 +- .../UsersTableItem/UsersTableItem.tsx | 32 +++-- src/components/Venues/VenueCard.tsx | 5 +- src/components/Venues/VenueModal.tsx | 3 +- src/screens/BlockUser/BlockUser.tsx | 2 +- src/screens/ForgotPassword/ForgotPassword.tsx | 4 +- .../FundCampaignPledge/FundCampaignPledge.tsx | 6 +- .../FundCampaignPledge/PledgeCreateModal.tsx | 6 +- .../FundCampaignPledge/PledgeEditModal.tsx | 6 +- src/screens/LoginPage/LoginPage.tsx | 10 +- src/screens/MemberDetail/MemberDetail.tsx | 6 +- src/screens/OrgList/OrgList.tsx | 6 +- src/screens/OrgList/OrganizationModal.tsx | 8 +- .../OrganizationEvents/OrganizationEvents.tsx | 10 +- .../OrganizationFundCampagins.tsx | 4 +- .../OrganizationVenues/OrganizationVenues.tsx | 3 +- src/screens/Requests/Requests.tsx | 4 +- src/screens/UserPortal/Events/Events.tsx | 132 +++--------------- src/screens/UserPortal/Settings/Settings.tsx | 6 +- src/screens/Users/Users.tsx | 4 +- 33 files changed, 147 insertions(+), 283 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index fd904784ed..66f3959604 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -1,7 +1,11 @@ { "firstName": "First Name", "lastName": "Last Name", + "searchByName": "Search By Name", "loading": "Loading...", + "endOfResults": "End of results", + "noResultsFoundFor": "No results found for ", + "edit": "Edit", "admins": "Admins", "admin": "ADMIN", "user": "USER", @@ -24,9 +28,21 @@ "no": "No", "filter": "Filter", "search": "Search", + "description": "Description", "saveChanges": "Save Changes", + "displayImage": "Display Image", + "enterEmail": "Enter Email", + "emailAddress": "Email Address", "email": "Email", "name": "Name", + "enterPassword": "Enter Password", "password": "Password", - "talawaAdminPortal": "Talawa Admin Portal" + "confirmPassword": "Confirm Password", + "forgotPassword": "Forgot Password ?", + "talawaAdminPortal": "Talawa Admin Portal", + "address": "Address", + "location": "Location", + "joined": "Joined", + "startDate": "Start Date", + "endDate": "End Date" } diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 381b3d1a73..fb459f29af 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -10,10 +10,6 @@ "password_invalid": "Password should contain atleast one lowercase letter, one uppercase letter, one numeric value and one special character", "email_invalid": "Email should have atleast 8 characters", "Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.", - "confirmPassword": "Confirm Password", - "forgotPassword": "Forgot Password ?", - "enterEmail": "Enter Email", - "enterPassword": "Enter Password", "doNotOwnAnAccount": "Do not own an account?", "captchaError": "Captcha Error!", "Please_check_the_captcha": "Please, check the captcha.", @@ -33,10 +29,6 @@ "fromPalisadoes": "An open source application by Palisadoes Foundation volunteers", "atleast_8_char_long": "Atleast 8 Character long", "Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.", - "confirmPassword": "Confirm Password", - "forgotPassword": "Forgot Password ?", - "enterEmail": "Enter Email", - "enterPassword": "Enter Password", "doNotOwnAnAccount": "Do not own an account?", "captchaError": "Captcha Error!", "Please_check_the_captcha": "Please, check the captcha.", @@ -89,13 +81,9 @@ "title": "Talawa Organizations", "you": "You", "designation": "Designation", - "searchByName": "Search By Name", "my organizations": "My Organizations", "createOrganization": "Create Organization", "createSampleOrganization": "Create Sample Organization", - "description": "Description", - "location": "Location", - "address": "Address", "city": "City", "countryCode": "Country Code", "dependentLocality": "Dependent Locality", @@ -106,7 +94,6 @@ "state": "State / Province", "userRegistrationRequired": "User Registration Required", "visibleInSearch": "Visible In Search", - "displayImage": "Display Image", "enterName": "Enter Name", "sort": "Sort", "Latest": "Latest", @@ -114,12 +101,10 @@ "noOrgErrorTitle": "Organizations Not Found", "sampleOrgDuplicate": "Only one sample organization allowed", "noOrgErrorDescription": "Please create an organization through dashboard", - "endOfResults": "End of results", "manageFeatures": "Manage Features", "manageFeaturesInfo": "Creation Successful ! Please select features that you want to enale for this organization from the plugin store.", "goToStore": "Go to Plugin Store", "enableEverything": "Enable Everything", - "noResultsFoundFor": "No results found for", "sampleOrgSuccess": "Sample Organization Successfully Created" }, "orgListCard": { @@ -136,9 +121,7 @@ "accept": "Accept", "reject": "Reject", "searchRequests": "Search membership requests", - "endOfResults": "End of results", "noOrgError": "Organizations not found, please create an organization through dashboard", - "noResultsFoundFor": "No results found for ", "noRequestsFound": "No Membership Requests Found", "acceptedSuccessfully": "Request accepted successfully", "rejectedSuccessfully": "Request rejected successfully", @@ -147,12 +130,10 @@ }, "users": { "title": "Talawa Roles", - "searchByName": "Search By Name", "joined_organizations": "Joined Organizations", "blocked_organizations": "Blocked Organizations", "orgJoinedBy": "Organizations Joined By", "orgThatBlocked": "Organizations That Blocked", - "endOfResults": "End of results", "hasNotJoinedAnyOrg": "has not joined any organization", "isNotBlockedByAnyOrg": "is not blocked by any organization", "searchByOrgName": "Search By Organization Name", @@ -165,7 +146,6 @@ "Oldest": "Oldest First", "noOrgError": "Organizations not found, please create an organization through dashboard", "roleUpdated": "Role Updated.", - "noResultsFoundFor": "No results found for ", "joinNow": "Join Now", "visit": "Visit", "withdraw": "Widthdraw" @@ -184,7 +164,6 @@ }, "dashboard": { "title": "Dashboard", - "location": "Location", "about": "About", "deleteThisOrganization": "Delete This Organization", "statistics": "Statistics", @@ -215,28 +194,21 @@ "newUser": "New User", "enterFirstName": "Enter your first name", "enterLastName": "Enter your last name", - "emailAddress": "Email Address", - "enterEmail": "Enter your email address", - "enterPassword": "Enter your password", - "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter your password to confirm", "organization": "Organization", "invalidDetailsMessage": "Please enter valid details." }, "userListCard": { - "joined": "Joined", "addAdmin": "Add Admin", "addedAsAdmin": "User is added as admin." }, "orgAdminListCard": { - "joined": "Joined", "remove": "Remove", "removeAdmin": "Remove Admin", "removeAdminMsg": "Do you want to remove this admin?", "adminRemoved": "The admin is removed." }, "orgPeopleListCard": { - "joined": "Joined", "remove": "Remove", "removeMember": "Remove Member", "removeMemberMsg": "Do you want to remove this member?", @@ -250,10 +222,6 @@ "addEvent": "Add Event", "eventDetails": "Event Details", "eventTitle": "Title", - "description": "Description", - "location": "Location", - "startDate": "Start Date", - "endDate": "End Date", "startTime": "Start Time", "endTime": "End Time", "allDay": "All Day", @@ -312,14 +280,10 @@ "title": "Action Items" }, "eventListCard": { - "location": "Event Location", "deleteEvent": "Delete Event", "deleteEventMsg": "Do you want to remove this event?", "editEvent": "Edit Event", "eventTitle": "Title", - "description": "Description", - "startDate": "Start Date", - "endDate": "End Date", "alreadyRegistered": "Already registered", "startTime": "Start Time", "endTime": "End Time", @@ -378,8 +342,6 @@ "fundCampaign": { "title": "Fundraising Campaigns", "campaignName": "Campaign Name", - "startDate": "Start Date", - "endDate": "End Date", "campaignOptions": "Options", "fundingGoal": "Funding Goal", "addCampaign": "Add Campaign", @@ -399,8 +361,6 @@ "pledges": { "title": "Fund Campaign Pledges", "volunteers": "Volunteers", - "startDate": "Start Date", - "endDate": "End Date", "pledgeAmount": "Pledge Amount", "pledgeOptions": "Options", "pledgeCreated": "Pledge created successfully", @@ -464,7 +424,6 @@ "author": "Author", "imageURL": "Image URL", "videoURL": "Video URL", - "edit": "Edit Post", "deletePost": "Delete Post", "deletePostMsg": "Do you want to remove this post?", "editPost": "Edit Post", @@ -483,7 +442,6 @@ "blockUnblockUser": { "title": "Block/Unblock User", "pageName": "Block/Unblock", - "searchByName": "Search By Name", "listOfUsers": "List of Users who spammed", "block_unblock": "Block/Unblock", "unblock": "UnBlock", @@ -495,7 +453,6 @@ "blockedUsers": "Blocked Users", "searchByFirstName": "Search By First Name", "searchByLastName": "Search By Last Name", - "noResultsFoundFor": "No results found for", "noSpammerFound": "No spammer found" }, "eventManagement": { @@ -508,7 +465,6 @@ }, "forgotPassword": { "title": "Talawa Forgot Password", - "forgotPassword": "Forgot Password", "registeredEmail": "Registered Email", "getOtp": "Get OTP", "enterOtp": "Enter OTP", @@ -571,8 +527,7 @@ }, "userUpdate": { "appLanguageCode": "Default Language", - "userType": "User Type", - "displayImage": "Display Image" + "userType": "User Type" }, "userPasswordUpdate": { "previousPassword": "Previous Password", @@ -583,15 +538,11 @@ "deleteOrg": "Delete Org" }, "membershipRequest": { - "joined": "Joined", "accept": "Accept", "reject": "Reject", "memberAdded": "it is accepted" }, "orgUpdate": { - "description": "Description", - "location": "Location", - "address": "Address", "city": "City", "countryCode": "Country Code", "line1": "Line 1", @@ -600,7 +551,6 @@ "dependentLocality": "Dependent Locality", "sortingCode": "Sorting code", "state": "State / Province", - "displayImage": "Display Image", "userRegistrationRequired": "User Registration Required", "isVisibleInSearch": "Visible in Search", "enterNameOrganization": "Enter Organization Name", @@ -650,9 +600,7 @@ "educationGrade": "Educational Grade", "employmentStatus": "Employment Status", "maritalStatus": "Marital Status", - "displayImage": "Display Image", "phone": "Phone", - "address": "Address", "countryCode": "Country Code", "state": "State", "city": "City", @@ -663,7 +611,6 @@ "appLanguageCode": "Choose Language", "deleteUser": "Delete User", "pluginCreationAllowed": "Plugin creation allowed", - "joined": "Joined", "created": "Created", "adminForOrganizations": "Admin for organizations", "membershipRequests": "Membership requests", @@ -673,11 +620,7 @@ }, "userLogin": { "login": "Login", - "forgotPassword": "Forgot Password?", "loginIntoYourAccount": "Login into your account", - "emailAddress": "Email Address", - "enterEmail": "Enter your email address", - "enterPassword": "Enter your password", "invalidDetailsMessage": "Please enter a valid email and password.", "notAuthorised": "Sorry! you are not Authorised!", "invalidCredentials": "Entered credentials are incorrect. Please enter valid credentials." @@ -685,10 +628,6 @@ "userRegister": { "enterFirstName": "Enter your first name", "enterLastName": "Enter your last name", - "emailAddress": "Email Address", - "enterEmail": "Enter your email address", - "enterPassword": "Enter your password", - "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter your password to confirm", "alreadyhaveAnAccount": "Already have an account?", "login": "Login", @@ -712,8 +651,7 @@ "selectOrganization": "Select an organization", "searchUsers": "Search users", "nothingToShow": "Nothing to show here.", - "organizations": "Organizations", - "searchByName": "Search By Name" + "organizations": "Organizations" }, "userSidebarOrg": { "yourOrganizations": "Your Organizations", @@ -730,7 +668,6 @@ "noMembers": "No Members to show" }, "postCard": { - "edit": "Edit", "likes": "Likes", "comments": "Comments" }, @@ -754,15 +691,12 @@ "settings": { "profileSettings": "Profile Settings", "gender": "Gender", - "emailAddress": "Email Address", "phoneNumber": "Phone Number", - "displayImage": "Display Image", "chooseFile": "Choose File", "birthDate": "Birth Date", "grade": "Educational Grade", "empStatus": "Employment Status", "maritalStatus": "Marital Status", - "address": "Address", "state": "City/State", "country": "Country", "resetChanges": "Reset Changes", @@ -806,8 +740,7 @@ "fullTime": "Full Time", "partTime": "Part Time", "selectCountry": "Select a country", - "enterState": "Enter City or State", - "joined": "Joined" + "enterState": "Enter City or State" }, "donate": { "donations": "Donations", @@ -832,19 +765,14 @@ "eventDetails": "Event Details", "eventTitle": "Title", "enterTitle": "Enter Title", - "eventDescription": "Description", "enterDescription": "Enter Description", - "eventLocation": "Location", "enterLocation": "Enter Location", - "startDate": "Start Date", - "endDate": "End Date", "publicEvent": "Is Public", "registerable": "Is Registerable", "monthlyCalendarView": "Monthly Calendar", "yearlyCalendarView": "Yearly Calender" }, "userEventCard": { - "location": "Location", "starts": "Starts", "ends": "Ends", "creator": "Creator", @@ -870,9 +798,7 @@ "deleteAdvertisement": "Delete Advertisement", "deleteAdvertisementMsg": "Do you want to remove this advertisement?", "view": "View", - "edit": "Edit", - "editAdvertisement": "Edit Advertisement", - "endOfResults": "End of results" + "editAdvertisement": "Edit Advertisement" }, "userChat": { "chat": "Chat", @@ -893,7 +819,6 @@ "fieldRemovalSuccess": "Field removed successfully" }, "orgActionItemCategories": { - "editButton": "Edit", "enableButton": "Enable", "disableButton": "Disable", "updateActionItemCategory": "Update", @@ -912,7 +837,6 @@ "venueDetails": "Venue Details", "venueName": "Name of the Venue", "enterVenueName": "Enter Venue Name", - "description": "Description of the Venue", "enterVenueDesc": "Enter Venue Description", "capacity": "Capacity", "enterVenueCapacity": "Enter Venue Capacity", @@ -926,12 +850,10 @@ "highestCapacity": "Highest Capacity", "lowestCapacity": "Lowest Capacity", "noVenues": "No Venues Found!", - "edit": "Edit", "view": "View", "venueTitleError": "Venue title cannot be empty!", "venueCapacityError": "Capacity must be a positive number!", - "searchBy": "Search By", - "desc": "Description" + "searchBy": "Search By" }, "addMember": { "title": "Add Member", @@ -941,10 +863,6 @@ "searchFullName": "Search by Full Name", "enterFirstName": "Enter First Name", "enterLastName": "Enter Last Name", - "emailAddress": "Email Address", - "enterEmail": "Enter Email", - "enterPassword": "Enter Password", - "confirmPassword": "Confirm Password", "enterConfirmPassword": "Enter Confirm Password", "organization": "Organization", "invalidDetailsMessage": "Please provide all required details.", diff --git a/src/components/Advertisements/Advertisements.tsx b/src/components/Advertisements/Advertisements.tsx index 95b95fb936..0b880700d9 100644 --- a/src/components/Advertisements/Advertisements.tsx +++ b/src/components/Advertisements/Advertisements.tsx @@ -13,6 +13,7 @@ import InfiniteScroll from 'react-infinite-scroll-component'; export default function advertisements(): JSX.Element { const { orgId: currentOrgId } = useParams(); const { t } = useTranslation('translation', { keyPrefix: 'advertisement' }); + const { t: tCommon } = useTranslation('common'); document.title = t('title'); const [after, setAfter] = useState(null); @@ -32,7 +33,7 @@ export default function advertisements(): JSX.Element { data?: { organizations: InterfaceQueryOrganizationAdvertisementListItem[]; }; - refetch: any; + refetch: () => void; } = useQuery(ORGANIZATION_ADVERTISEMENT_LIST, { variables: { id: currentOrgId, @@ -114,7 +115,7 @@ export default function advertisements(): JSX.Element { (ad: Ad) => new Date(ad.endDate) > new Date(), ).length !== 0 && (
    -
    {t('endOfResults')}
    +
    {tCommon('endOfResults')}
    ) } @@ -189,7 +190,7 @@ export default function advertisements(): JSX.Element { (ad: Ad) => new Date(ad.endDate) < new Date(), ).length !== 0 && (
    -
    {t('endOfResults')}
    +
    {tCommon('endOfResults')}
    ) } diff --git a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx index 1e7572928b..bd8d368412 100644 --- a/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx +++ b/src/components/Advertisements/core/AdvertisementRegister/AdvertisementRegister.tsx @@ -220,7 +220,7 @@ function advertisementRegister({ ) : (
    - {t('edit')} + {tCommon('edit')}
    )} diff --git a/src/components/EventListCard/EventListCardModals.tsx b/src/components/EventListCard/EventListCardModals.tsx index f0f253e136..20d1029305 100644 --- a/src/components/EventListCard/EventListCardModals.tsx +++ b/src/components/EventListCard/EventListCardModals.tsx @@ -408,7 +408,7 @@ function EventListCardModals({ eventListCardProps.userRole === Role.USER } /> -

    {t('description')}

    +

    {tCommon('description')}

    -

    {t('location')}

    +

    {tCommon('location')}

    { @@ -484,7 +484,7 @@ function EventListCardModals({
    { diff --git a/src/components/MemberRequestCard/MemberRequestCard.tsx b/src/components/MemberRequestCard/MemberRequestCard.tsx index 1ce1f1924c..462e78d2ee 100644 --- a/src/components/MemberRequestCard/MemberRequestCard.tsx +++ b/src/components/MemberRequestCard/MemberRequestCard.tsx @@ -32,6 +32,7 @@ function memberRequestCard( const { t } = useTranslation('translation', { keyPrefix: 'membershipRequest', }); + const { t: tCommon } = useTranslation('common'); const addMember = async (): Promise => { try { @@ -47,7 +48,7 @@ function memberRequestCard( setTimeout(() => { window.location.reload(); }, 2000); - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -65,7 +66,7 @@ function memberRequestCard( /* istanbul ignore next */ window.location.reload(); - } catch (error: any) { + } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); } @@ -99,7 +100,7 @@ function memberRequestCard(

    - {t('joined')}: {props.joinDate} + {tCommon('joined')}: {props.joinDate}

    ) : ( ) : (
    @@ -227,7 +227,7 @@ function advertisementRegister({ {formStatus === 'register' ? ( - {t('RClose')} + {t('addNew')} ) : ( {t('editAdvertisement')} )} diff --git a/src/components/EventListCard/EventListCard.test.tsx b/src/components/EventListCard/EventListCard.test.tsx index a1a60ea4df..22ddccd8d2 100644 --- a/src/components/EventListCard/EventListCard.test.tsx +++ b/src/components/EventListCard/EventListCard.test.tsx @@ -12,7 +12,7 @@ import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; import type { InterfaceEventListCardProps } from './EventListCard'; import EventListCard from './EventListCard'; -import i18nForTest from 'utils/i18nForTest'; +import i18n from 'utils/i18nForTest'; import { StaticMockLink } from 'utils/StaticMockLink'; import { BrowserRouter, MemoryRouter, Route, Routes } from 'react-router-dom'; import { Provider } from 'react-redux'; @@ -44,15 +44,15 @@ async function wait(ms = 100): Promise { }); } -const translations = JSON.parse( - JSON.stringify( - i18nForTest.getDataByLanguage('en')?.translation.eventListCard, +const translations = { + ...JSON.parse( + JSON.stringify( + i18n.getDataByLanguage('en')?.translation.eventListCard ?? {}, + ), ), -); - -const translationsCommon = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.common), -); + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; const renderEventListCard = ( props: InterfaceEventListCardProps, @@ -62,7 +62,7 @@ const renderEventListCard = ( - + { test('Should navigate to "/" if orgId is not defined', async () => { render( - + { fireEvent.change(eventLocation, { target: { value: '' } }); userEvent.type(eventLocation, updateData.location); - const startDatePicker = screen.getByLabelText(translationsCommon.startDate); + const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: updateData.startDate }, }); - const endDatePicker = screen.getByLabelText(translationsCommon.endDate); + const endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: updateData.endDate }, }); @@ -393,22 +393,22 @@ describe('Testing Event List Card', () => { fireEvent.change(eventLocation, { target: { value: '' } }); userEvent.type(eventLocation, updateData.location); - const startDatePicker = screen.getByLabelText(translationsCommon.startDate); + const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: updateData.startDate }, }); - const endDatePicker = screen.getByLabelText(translationsCommon.endDate); + const endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: updateData.endDate }, }); - const startTimePicker = screen.getByLabelText(translationsCommon.startTime); + const startTimePicker = screen.getByLabelText(translations.startTime); fireEvent.change(startTimePicker, { target: { value: updateData.startTime }, }); - const endTimePicker = screen.getByLabelText(translationsCommon.endTime); + const endTimePicker = screen.getByLabelText(translations.endTime); fireEvent.change(endTimePicker, { target: { value: updateData.endTime }, }); @@ -446,12 +446,12 @@ describe('Testing Event List Card', () => { fireEvent.change(eventLocation, { target: { value: '' } }); userEvent.type(eventLocation, updateData.location); - const startDatePicker = screen.getByLabelText(translationsCommon.startDate); + const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: updateData.startDate }, }); - const endDatePicker = screen.getByLabelText(translationsCommon.endDate); + const endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: updateData.endDate }, }); @@ -495,18 +495,16 @@ describe('Testing Event List Card', () => { userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startDate), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); }); // change the event dates - let startDatePicker = screen.getByLabelText(translationsCommon.startDate); + let startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: updateData.startDate }, }); - let endDatePicker = screen.getByLabelText(translationsCommon.endDate); + let endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: updateData.endDate }, }); @@ -527,18 +525,16 @@ describe('Testing Event List Card', () => { userEvent.click(screen.getByTestId('eventUpdateOptionsModalCloseBtn')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startDate), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); }); // reset the event dates to their original values - startDatePicker = screen.getByLabelText(translationsCommon.startDate); + startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: '03/17/2022' }, }); - endDatePicker = screen.getByLabelText(translationsCommon.endDate); + endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: '03/17/2022' }, }); @@ -720,18 +716,16 @@ describe('Testing Event List Card', () => { userEvent.click(screen.getByTestId('card')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startDate), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startDate)).toBeInTheDocument(); }); // change the event dates - const startDatePicker = screen.getByLabelText(translationsCommon.startDate); + const startDatePicker = screen.getByLabelText(translations.startDate); fireEvent.change(startDatePicker, { target: { value: updateData.startDate }, }); - const endDatePicker = screen.getByLabelText(translationsCommon.endDate); + const endDatePicker = screen.getByLabelText(translations.endDate); fireEvent.change(endDatePicker, { target: { value: updateData.endDate }, }); @@ -889,7 +883,7 @@ describe('Testing Event List Card', () => { - + { test('Component loads correctly', async () => { @@ -66,7 +66,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -77,7 +77,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(getByText(translationsCommon.create)).toBeInTheDocument(); + expect(getByText(translations.create)).toBeInTheDocument(); }); }); @@ -87,7 +87,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -98,7 +98,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(queryByText(translationsCommon.create)).not.toBeInTheDocument(); + expect(queryByText(translations.create)).not.toBeInTheDocument(); }); }); @@ -108,7 +108,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -137,7 +137,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -168,7 +168,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -199,7 +199,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -236,7 +236,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -273,7 +273,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -310,7 +310,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -343,7 +343,7 @@ describe('Testing Action Item Categories Component', () => { - + {} diff --git a/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx b/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx index 35e4be641a..510f7a04aa 100644 --- a/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx +++ b/src/components/RecurrenceOptions/RecurrenceOptions.test.tsx @@ -14,7 +14,7 @@ import { I18nextProvider } from 'react-i18next'; import OrganizationEvents from '../../screens/OrganizationEvents/OrganizationEvents'; import { store } from 'state/store'; -import i18nForTest from 'utils/i18nForTest'; +import i18n from 'utils/i18nForTest'; import userEvent from '@testing-library/user-event'; import { StaticMockLink } from 'utils/StaticMockLink'; import { toast } from 'react-toastify'; @@ -42,15 +42,15 @@ async function wait(ms = 100): Promise { }); } -const translations = JSON.parse( - JSON.stringify( - i18nForTest.getDataByLanguage('en')?.translation.organizationEvents, +const translations = { + ...JSON.parse( + JSON.stringify( + i18n.getDataByLanguage('en')?.translation.organizationEvents ?? {}, + ), ), -); - -const translationsCommon = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.common), -); + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; jest.mock('@mui/x-date-pickers/DateTimePicker', () => { return { @@ -86,7 +86,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -124,7 +124,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -168,7 +168,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -228,7 +228,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -352,7 +352,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -400,13 +400,11 @@ describe('Testing the creaction of recurring events through recurrence options', userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startTime), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); }); - const startTimePicker = screen.getByLabelText(translationsCommon.startTime); - const endTimePicker = screen.getByLabelText(translationsCommon.endTime); + const startTimePicker = screen.getByLabelText(translations.startTime); + const endTimePicker = screen.getByLabelText(translations.endTime); fireEvent.change(startTimePicker, { target: { value: formData.startTime }, @@ -472,7 +470,7 @@ describe('Testing the creaction of recurring events through recurrence options', - + @@ -520,13 +518,11 @@ describe('Testing the creaction of recurring events through recurrence options', userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startTime), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); }); - const startTimePicker = screen.getByLabelText(translationsCommon.startTime); - const endTimePicker = screen.getByLabelText(translationsCommon.endTime); + const startTimePicker = screen.getByLabelText(translations.startTime); + const endTimePicker = screen.getByLabelText(translations.endTime); fireEvent.change(startTimePicker, { target: { value: formData.startTime }, diff --git a/src/screens/ForgotPassword/ForgotPassword.test.tsx b/src/screens/ForgotPassword/ForgotPassword.test.tsx index 5dc7392830..eb62cb0178 100644 --- a/src/screens/ForgotPassword/ForgotPassword.test.tsx +++ b/src/screens/ForgotPassword/ForgotPassword.test.tsx @@ -74,15 +74,15 @@ async function wait(ms = 100): Promise { }); } -const translations = JSON.parse( - JSON.stringify( - i18n.getDataByLanguage('en')?.translation.forgotPassword ?? {}, +const translations = { + ...JSON.parse( + JSON.stringify( + i18n.getDataByLanguage('en')?.translation.forgotPassword ?? {}, + ), ), -); - -const translationsError = JSON.parse( - JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {}), -); + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; beforeEach(() => { setItem('IsLoggedIn', 'FALSE'); @@ -365,7 +365,7 @@ describe('Testing Forgot Password screen', () => { await wait(); expect( - await screen.findByText(translationsError.talawaApiUnavailable), + await screen.findByText(translations.talawaApiUnavailable), ).toBeInTheDocument(); }); diff --git a/src/screens/ForgotPassword/ForgotPassword.tsx b/src/screens/ForgotPassword/ForgotPassword.tsx index 37097039c8..bf1e8c1ee8 100644 --- a/src/screens/ForgotPassword/ForgotPassword.tsx +++ b/src/screens/ForgotPassword/ForgotPassword.tsx @@ -24,6 +24,7 @@ const ForgotPassword = (): JSX.Element => { keyPrefix: 'forgotPassword', }); const { t: tCommon } = useTranslation('common'); + const { t: tErrors } = useTranslation('errors'); document.title = t('title'); @@ -71,11 +72,11 @@ const ForgotPassword = (): JSX.Element => { } catch (error: unknown) { if (error instanceof Error) { if (error.message === 'User not found') { - toast.warn(t('emailNotRegistered')); + toast.warn(tErrors('emailNotRegistered')); } else if (error.message === 'Failed to fetch') { - toast.error(t('talawaApiUnavailable')); + toast.error(tErrors('talawaApiUnavailable')); } else { - toast.error(t('errorSendingMail')); + toast.error(tErrors('errorSendingMail')); } } } diff --git a/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx b/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx index 11fd9cbfb1..f949168c8a 100644 --- a/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx +++ b/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx @@ -16,7 +16,7 @@ import { BrowserRouter } from 'react-router-dom'; import { toast } from 'react-toastify'; import { store } from 'state/store'; import { StaticMockLink } from 'utils/StaticMockLink'; -import i18nForTest from '../../utils/i18nForTest'; +import i18n from '../../utils/i18nForTest'; import FundCampaignPledge from './FundCampaignPledge'; import { EMPTY_MOCKS, @@ -55,12 +55,14 @@ const link3 = new StaticMockLink(MOCKS_CREATE_PLEDGE_ERROR); const link4 = new StaticMockLink(MOCKS_UPDATE_PLEDGE_ERROR); const link5 = new StaticMockLink(MOCKS_DELETE_PLEDGE_ERROR); const link6 = new StaticMockLink(EMPTY_MOCKS); -const translations = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.translation.pledges), -); -const translationsCommon = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.common), -); + +const translations = { + ...JSON.parse( + JSON.stringify(i18n.getDataByLanguage('en')?.translation.pledges ?? {}), + ), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; describe('Testing Campaign Pledge Screen', () => { const formData = { @@ -75,7 +77,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -92,7 +94,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -114,7 +116,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -143,7 +145,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -163,8 +165,8 @@ describe('Testing Campaign Pledge Screen', () => { }); const currency = screen.getByTestId('currencySelect'); fireEvent.change(currency, { target: { value: formData.pledgeCurrency } }); - const startDate = screen.getByLabelText(translationsCommon.startDate); - const endDate = screen.getByLabelText(translationsCommon.endDate); + const startDate = screen.getByLabelText(translations.startDate); + const endDate = screen.getByLabelText(translations.endDate); fireEvent.change(startDate, { target: { value: formData.pledgeStartDate }, }); @@ -186,7 +188,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -206,8 +208,8 @@ describe('Testing Campaign Pledge Screen', () => { }); const currency = screen.getByTestId('currencySelect'); fireEvent.change(currency, { target: { value: formData.pledgeCurrency } }); - const startDate = screen.getByLabelText(translationsCommon.startDate); - const endDate = screen.getByLabelText(translationsCommon.endDate); + const startDate = screen.getByLabelText(translations.startDate); + const endDate = screen.getByLabelText(translations.endDate); fireEvent.change(startDate, { target: { value: formData.pledgeStartDate }, }); @@ -228,7 +230,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -257,7 +259,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -277,8 +279,8 @@ describe('Testing Campaign Pledge Screen', () => { }); const currency = screen.getByTestId('currencySelect'); fireEvent.change(currency, { target: { value: 'INR' } }); - const startDate = screen.getByLabelText(translationsCommon.startDate); - const endDate = screen.getByLabelText(translationsCommon.endDate); + const startDate = screen.getByLabelText(translations.startDate); + const endDate = screen.getByLabelText(translations.endDate); fireEvent.change(startDate, { target: { value: formData.pledgeStartDate }, }); @@ -300,7 +302,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -320,8 +322,8 @@ describe('Testing Campaign Pledge Screen', () => { }); const currency = screen.getByTestId('currencySelect'); fireEvent.change(currency, { target: { value: 'INR' } }); - const startDate = screen.getByLabelText(translationsCommon.startDate); - const endDate = screen.getByLabelText(translationsCommon.endDate); + const startDate = screen.getByLabelText(translations.startDate); + const endDate = screen.getByLabelText(translations.endDate); fireEvent.change(startDate, { target: { value: formData.pledgeStartDate }, }); @@ -341,7 +343,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -370,7 +372,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -401,7 +403,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} @@ -430,7 +432,7 @@ describe('Testing Campaign Pledge Screen', () => { - + {} diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index 725cfea4aa..56f2d38159 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -38,6 +38,8 @@ import { Autocomplete, TextField } from '@mui/material'; const loginPage = (): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'loginPage' }); const { t: tCommon } = useTranslation('common'); + const { t: tErrors } = useTranslation('errors'); + const navigate = useNavigate(); const { getItem, setItem } = useLocalStorage(); @@ -294,7 +296,7 @@ const loginPage = (): JSX.Element => { appUserProfile.isSuperAdmin || appUserProfile.adminFor.length !== 0; if (role === 'admin' && !isAdmin) { - toast.warn(t('notAuthorised')); + toast.warn(tErrors('notAuthorised')); return; } const loggedInUserId = user._id; @@ -318,7 +320,7 @@ const loginPage = (): JSX.Element => { navigate(role === 'admin' ? '/orglist' : '/user/organizations'); } else { - toast.warn(t('notFound')); + toast.warn(tErrors('notFound')); } } catch (error) { /* istanbul ignore next */ diff --git a/src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx b/src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx index f5fe11f4d4..a7a00b6caa 100644 --- a/src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx +++ b/src/screens/OrganizationActionItems/OrganizationActionItems.test.tsx @@ -14,7 +14,7 @@ import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; -import i18nForTest from 'utils/i18nForTest'; +import i18n from 'utils/i18nForTest'; import { toast } from 'react-toastify'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; @@ -68,15 +68,15 @@ const link3 = new StaticMockLink(MOCKS_ERROR_MEMBERS_LIST_QUERY, true); const link4 = new StaticMockLink(MOCKS_ERROR_ACTION_ITEM_LIST_QUERY, true); const link5 = new StaticMockLink(MOCKS_ERROR_MUTATIONS, true); -const translations = JSON.parse( - JSON.stringify( - i18nForTest.getDataByLanguage('en')?.translation.organizationActionItems, +const translations = { + ...JSON.parse( + JSON.stringify( + i18n.getDataByLanguage('en')?.translation.organizationActionItems ?? {}, + ), ), -); - -const translationsCommon = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.common), -); + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; describe('Testing Action Item Categories Component', () => { const formData = { @@ -91,7 +91,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -102,7 +102,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(getByText(translationsCommon.create)).toBeInTheDocument(); + expect(getByText(translations.create)).toBeInTheDocument(); }); }); @@ -111,7 +111,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -122,7 +122,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(queryByText(translationsCommon.create)).not.toBeInTheDocument(); + expect(queryByText(translations.create)).not.toBeInTheDocument(); }); }); @@ -131,7 +131,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -142,7 +142,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(queryByText(translationsCommon.create)).not.toBeInTheDocument(); + expect(queryByText(translations.create)).not.toBeInTheDocument(); }); }); @@ -151,7 +151,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -162,7 +162,7 @@ describe('Testing Action Item Categories Component', () => { await wait(); await waitFor(() => { - expect(queryByText(translationsCommon.create)).not.toBeInTheDocument(); + expect(queryByText(translations.create)).not.toBeInTheDocument(); }); }); @@ -171,7 +171,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -219,7 +219,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -338,7 +338,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -445,7 +445,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -479,7 +479,7 @@ describe('Testing Action Item Categories Component', () => { - + {} @@ -540,7 +540,7 @@ describe('Testing Action Item Categories Component', () => { - + {} diff --git a/src/screens/OrganizationEvents/OrganizationEvents.test.tsx b/src/screens/OrganizationEvents/OrganizationEvents.test.tsx index c1f7dd93a6..6c0491e2b2 100644 --- a/src/screens/OrganizationEvents/OrganizationEvents.test.tsx +++ b/src/screens/OrganizationEvents/OrganizationEvents.test.tsx @@ -14,7 +14,7 @@ import { I18nextProvider } from 'react-i18next'; import OrganizationEvents from './OrganizationEvents'; import { store } from 'state/store'; -import i18nForTest from 'utils/i18nForTest'; +import i18n from 'utils/i18nForTest'; import userEvent from '@testing-library/user-event'; import { StaticMockLink } from 'utils/StaticMockLink'; import { toast } from 'react-toastify'; @@ -43,15 +43,15 @@ async function wait(ms = 100): Promise { }); } -const translations = JSON.parse( - JSON.stringify( - i18nForTest.getDataByLanguage('en')?.translation.organizationEvents, +const translations = { + ...JSON.parse( + JSON.stringify( + i18n.getDataByLanguage('en')?.translation.organizationEvents ?? {}, + ), ), -); - -const translationsCommon = JSON.parse( - JSON.stringify(i18nForTest.getDataByLanguage('en')?.common), -); + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})), + ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})), +}; jest.mock('@mui/x-date-pickers/DateTimePicker', () => { return { @@ -135,7 +135,7 @@ describe('Organisation Events Page', () => { - + @@ -158,7 +158,7 @@ describe('Organisation Events Page', () => { - + @@ -182,7 +182,7 @@ describe('Organisation Events Page', () => { - + @@ -222,7 +222,7 @@ describe('Organisation Events Page', () => { - + @@ -313,7 +313,7 @@ describe('Organisation Events Page', () => { - + @@ -391,7 +391,7 @@ describe('Organisation Events Page', () => { - + @@ -435,13 +435,11 @@ describe('Organisation Events Page', () => { userEvent.click(screen.getByTestId('alldayCheck')); await waitFor(() => { - expect( - screen.getByLabelText(translationsCommon.startTime), - ).toBeInTheDocument(); + expect(screen.getByLabelText(translations.startTime)).toBeInTheDocument(); }); - const startTimePicker = screen.getByLabelText(translationsCommon.startTime); - const endTimePicker = screen.getByLabelText(translationsCommon.endTime); + const startTimePicker = screen.getByLabelText(translations.startTime); + const endTimePicker = screen.getByLabelText(translations.endTime); fireEvent.change(startTimePicker, { target: { value: formData.startTime }, diff --git a/src/screens/PageNotFound/PageNotFound.tsx b/src/screens/PageNotFound/PageNotFound.tsx index edd566fa24..92f4a98f7e 100644 --- a/src/screens/PageNotFound/PageNotFound.tsx +++ b/src/screens/PageNotFound/PageNotFound.tsx @@ -11,6 +11,7 @@ const PageNotFound = (): JSX.Element => { keyPrefix: 'pageNotFound', }); const { t: tCommon } = useTranslation('common'); + const { t: tErrors } = useTranslation('errors'); document.title = t('title'); @@ -33,7 +34,7 @@ const PageNotFound = (): JSX.Element => {

    {t('404')}

    -

    {t('notFoundMsg')}

    +

    {tErrors('notFoundMsg')}

    {adminFor != undefined ? ( {t('backToHome')} diff --git a/src/utils/errorHandler.test.tsx b/src/utils/errorHandler.test.tsx index a90ab859c7..7ed08ab707 100644 --- a/src/utils/errorHandler.test.tsx +++ b/src/utils/errorHandler.test.tsx @@ -10,12 +10,13 @@ jest.mock('react-toastify', () => ({ describe('Test if errorHandler is working properly', () => { const t: TFunction<'translation', string> = (key: string) => key; + const tErrors: TFunction<'errors', string> = (key: string) => key; it('should call toast.error with the correct message if error message is "Failed to fetch"', () => { const error = { message: 'Failed to fetch' }; errorHandler(t, error); - expect(toast.error).toHaveBeenCalledWith(t('talawaApiUnavailable')); + expect(toast.error).toHaveBeenCalledWith(tErrors('talawaApiUnavailable')); }); it('should call toast.error with the error message if it is not "Failed to fetch"', () => { diff --git a/src/utils/errorHandler.tsx b/src/utils/errorHandler.tsx index 1bc2aa8151..ee8f008299 100644 --- a/src/utils/errorHandler.tsx +++ b/src/utils/errorHandler.tsx @@ -7,18 +7,18 @@ import i18n from './i18n'; If the error is due to the Talawa API being unavailable, it displays a custom message. */ export const errorHandler = (a: unknown, error: unknown): void => { - const t: TFunction = i18n.getFixedT(null, 'errors'); + const tErrors: TFunction = i18n.getFixedT(null, 'errors'); if (error instanceof Error) { switch (error.message) { case 'Failed to fetch': console.log(error); - toast.error(t('talawaApiUnavailable')); + toast.error(tErrors('talawaApiUnavailable')); break; // Add more cases as needed default: toast.error(error.message); } } else { - toast.error(t('unknownError', { msg: error })); + toast.error(tErrors('unknownError', { msg: error })); } }; From 960084c8876c7e0359bc5bb47eb738b0a0413fa8 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Thu, 23 May 2024 04:33:11 +0530 Subject: [PATCH 20/26] chore: Update OrgPostCard.test.tsx with language detector mock --- src/components/OrgPostCard/OrgPostCard.test.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/OrgPostCard/OrgPostCard.test.tsx b/src/components/OrgPostCard/OrgPostCard.test.tsx index b89fc6cd99..863ed2822b 100644 --- a/src/components/OrgPostCard/OrgPostCard.test.tsx +++ b/src/components/OrgPostCard/OrgPostCard.test.tsx @@ -78,6 +78,12 @@ jest.mock('react-toastify', () => ({ error: jest.fn(), }, })); +jest.mock('i18next-browser-languagedetector', () => ({ + init: jest.fn(), + type: 'languageDetector', + detect: jest.fn(() => 'en'), + cacheUserLanguage: jest.fn(), +})); const link = new StaticMockLink(MOCKS, true); async function wait(ms = 100): Promise { await act(() => { From 74061fb7d7416eba058d058dfda30c8f695ce993 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Thu, 23 May 2024 05:32:57 +0530 Subject: [PATCH 21/26] error translation fix --- public/locales/en/translation.json | 3 ++- src/components/OrgAdminListCard/OrgAdminListCard.test.tsx | 7 ++++++- src/utils/errorHandler.test.tsx | 8 +++++--- src/utils/errorHandler.tsx | 1 - 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index a21efd5032..6e58a2ea2a 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -569,7 +569,8 @@ "pHeading": "Plugins", "install": "Installed", "available": "Available", - "pMessage": "Plugin does not exists" + "pMessage": "Plugin does not exists", + "filter": "Filters" }, "addOnEntry": { "enable": "Enabled", diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx index cb2492d306..282dedb330 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx @@ -57,7 +57,12 @@ const renderOrgAdminListCard = (props: {
    , ); }; - +jest.mock('i18next-browser-languagedetector', () => ({ + init: jest.fn(), + type: 'languageDetector', + detect: jest.fn(() => 'en'), + cacheUserLanguage: jest.fn(), +})); describe('Testing Organization Admin List Card', () => { global.alert = jest.fn(); diff --git a/src/utils/errorHandler.test.tsx b/src/utils/errorHandler.test.tsx index 7ed08ab707..1ca42441ab 100644 --- a/src/utils/errorHandler.test.tsx +++ b/src/utils/errorHandler.test.tsx @@ -13,14 +13,14 @@ describe('Test if errorHandler is working properly', () => { const tErrors: TFunction<'errors', string> = (key: string) => key; it('should call toast.error with the correct message if error message is "Failed to fetch"', () => { - const error = { message: 'Failed to fetch' }; + const error = new Error('Failed to fetch'); errorHandler(t, error); expect(toast.error).toHaveBeenCalledWith(tErrors('talawaApiUnavailable')); }); it('should call toast.error with the error message if it is not "Failed to fetch"', () => { - const error = { message: 'Some other error message' }; + const error = new Error('Some other error message'); errorHandler(t, error); expect(toast.error).toHaveBeenCalledWith(error.message); @@ -30,6 +30,8 @@ describe('Test if errorHandler is working properly', () => { const error = null; errorHandler(t, error); - expect(toast.error).toHaveBeenCalledWith(undefined); + expect(toast.error).toHaveBeenCalledWith( + tErrors('unknownError', { msg: error }), + ); }); }); diff --git a/src/utils/errorHandler.tsx b/src/utils/errorHandler.tsx index ee8f008299..aa7c6dc9dc 100644 --- a/src/utils/errorHandler.tsx +++ b/src/utils/errorHandler.tsx @@ -11,7 +11,6 @@ export const errorHandler = (a: unknown, error: unknown): void => { if (error instanceof Error) { switch (error.message) { case 'Failed to fetch': - console.log(error); toast.error(tErrors('talawaApiUnavailable')); break; // Add more cases as needed From f252e5d3701993b7d876d15977b838d9fa8d53a0 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Thu, 23 May 2024 06:27:07 +0530 Subject: [PATCH 22/26] Refactor UsersTableItem component to optimize performance and remove unnecessary code --- src/components/OrgPostCard/OrgPostCard.tsx | 49 +++---------------- .../UsersTableItem/UsersTableItem.tsx | 47 +++++------------- 2 files changed, 18 insertions(+), 78 deletions(-) diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index 14d4b19be8..be71622c7c 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -1,7 +1,5 @@ import { useMutation } from '@apollo/client'; -import CloseIcon from '@mui/icons-material/Close'; -import MoreVertIcon from '@mui/icons-material/MoreVert'; -import PushPinIcon from '@mui/icons-material/PushPin'; +import { Close, MoreVert, PushPin } from '@mui/icons-material'; import { DELETE_POST_MUTATION, TOGGLE_PINNED_POST, @@ -10,17 +8,13 @@ import { import AboutImg from 'assets/images/defaultImg.png'; import type { ChangeEvent } from 'react'; import React, { useEffect, useRef, useState } from 'react'; -import { Form } from 'react-bootstrap'; -import Button from 'react-bootstrap/Button'; -import Card from 'react-bootstrap/Card'; -import Modal from 'react-bootstrap/Modal'; +import { Form, Button, Card, Modal } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; import convertToBase64 from 'utils/convertToBase64'; import { errorHandler } from 'utils/errorHandler'; import type { InterfacePostForm } from 'utils/interfaces'; import styles from './OrgPostCard.module.css'; - interface InterfaceOrgPostCardProps { key: string; id: string; @@ -31,7 +25,6 @@ interface InterfaceOrgPostCardProps { postVideo: string | null; pinned: boolean; } - export default function orgPostCard( props: InterfaceOrgPostCardProps, ): JSX.Element { @@ -42,7 +35,6 @@ export default function orgPostCard( postvideo: '', pinned: false, }); - // console.log('postformState', postformState); const [postPhotoUpdated, setPostPhotoUpdated] = useState(false); const [postVideoUpdated, setPostVideoUpdated] = useState(false); const [togglePost, setPostToggle] = useState('Read more'); @@ -70,7 +62,6 @@ export default function orgPostCard( } } catch (error: unknown) { if (error instanceof Error) { - console.log(error.message); /* istanbul ignore next */ errorHandler(t, error); } @@ -89,12 +80,10 @@ export default function orgPostCard( setShowEditModal((prev) => !prev); }; const toggleShowDeleteModal = (): void => setShowDeleteModal((prev) => !prev); - const handleVideoPlay = (): void => { setPlaying(true); videoRef.current?.play(); }; - const handleVideoPause = (): void => { setPlaying(false); videoRef.current?.pause(); @@ -102,7 +91,6 @@ export default function orgPostCard( const handleCardClick = (): void => { setModalVisible(true); }; - const handleMoreOptionsClick = (): void => { setMenuVisible(true); }; @@ -119,7 +107,6 @@ export default function orgPostCard( fileInput.value = ''; } }; - const clearVideoInput = (): void => { setPostFormState({ ...postformState, @@ -140,7 +127,6 @@ export default function orgPostCard( setPostToggle('Read more'); } } - function handleEditModal(): void { setModalVisible(false); setMenuVisible(false); @@ -151,15 +137,12 @@ export default function orgPostCard( postvideo: props.postVideo, }); } - function handleDeleteModal(): void { setModalVisible(false); setMenuVisible(false); setShowDeleteModal(true); } - useEffect(() => { - // console.log(props.postPhoto); setPostFormState({ posttitle: props.postTitle, postinfo: props.postInfo, @@ -168,15 +151,12 @@ export default function orgPostCard( pinned: props.pinned, }); }, []); - const { t } = useTranslation('translation', { keyPrefix: 'orgPostCard', }); const { t: tCommon } = useTranslation('common'); - const [deletePostMutation] = useMutation(DELETE_POST_MUTATION); const [updatePostMutation] = useMutation(UPDATE_POST_MUTATION); - const deletePost = async (): Promise => { try { const { data } = await deletePostMutation({ @@ -184,7 +164,6 @@ export default function orgPostCard( id: props.id, }, }); - if (data) { toast.success(t('postDeleted')); toggleShowDeleteModal(); @@ -205,12 +184,10 @@ export default function orgPostCard( [name]: value, })); }; - const updatePostHandler = async ( e: ChangeEvent, ): Promise => { e.preventDefault(); - try { const { data } = await updatePostMutation({ variables: { @@ -225,7 +202,6 @@ export default function orgPostCard( }), }, }); - if (data) { toast.success(t('postUpdated')); setTimeout(() => { @@ -238,7 +214,6 @@ export default function orgPostCard( } } }; - return ( <>
    @@ -266,7 +241,7 @@ export default function orgPostCard( {props.pinned && ( - {props.pinned && ( - + )} {props.postTitle} @@ -319,7 +290,7 @@ export default function orgPostCard( /> {props.pinned && ( -
    )} -

    {t('author')}: {props.postAuthor} @@ -398,19 +368,18 @@ export default function orgPostCard( onClick={handleMoreOptionsClick} data-testid="moreiconbtn" > - +

    )} - {menuVisible && (
    @@ -451,8 +420,6 @@ export default function orgPostCard(
    )}
    - - {/* Delete Modal */}
    {t('deletePost')}
    @@ -475,8 +442,6 @@ export default function orgPostCard(
    - - {/* Edit Modal */} { const { t } = useTranslation('translation', { keyPrefix: 'users' }); const { t: tCommon } = useTranslation('common'); const { user, index, resetAndRefetch } = props; - const [showJoinedOrganizations, setShowJoinedOrganizations] = useState(false); const [showBlockedOrganizations, setShowBlockedOrganizations] = useState(false); @@ -62,11 +60,9 @@ const UsersTableItem = (props: Props): JSX.Element => { resetAndRefetch(); } } catch (error: unknown) { - /* istanbul ignore next */ errorHandler(t, error); } }; - /* istanbul ignore next */ const changeRoleInOrg = async ( e: React.ChangeEvent, ): Promise => { @@ -85,13 +81,11 @@ const UsersTableItem = (props: Props): JSX.Element => { resetAndRefetch(); } } catch (error: unknown) { - /* istanbul ignore next */ errorHandler(t, error); } }; function goToOrg(_id: string): void { const url = '/orgdash/' + _id; - // Dont change the below two lines window.location.replace(url); navigate(url); } @@ -148,7 +142,6 @@ const UsersTableItem = (props: Props): JSX.Element => { ?.value || ''; searchOrgsBlockedBy(inputValue); }; - /* istanbul ignore next */ function onHideRemoveUserModal(): void { setShowRemoveUserModal(false); if (removeUserProps.setShowOnCancel == 'JOINED') { @@ -160,7 +153,6 @@ const UsersTableItem = (props: Props): JSX.Element => { const isSuperAdmin = user.appUserProfile.isSuperAdmin; return ( <> - {/* Table Item */} {index + 1} {`${user.user.firstName} ${user.user.lastName}`} @@ -173,7 +165,6 @@ const UsersTableItem = (props: Props): JSX.Element => { {t('view')} ({user.user.joinedOrganizations.length}) - - {/* Organizations joined modal */} { {user.user.joinedOrganizations.length !== 0 && (
    {
    ) : joinedOrgs.length == 0 ? ( - <> -
    -

    - {tCommon('noResultsFoundFor')} " - {searchByNameJoinedOrgs} - " -

    -
    - +
    +

    + {tCommon('noResultsFoundFor')} " + {searchByNameJoinedOrgs} + " +

    +
    ) : ( @@ -254,7 +241,6 @@ const UsersTableItem = (props: Props): JSX.Element => { {joinedOrgs.map((org) => { - // Check user is admin for this organization or not let isAdmin = false; user.appUserProfile.adminFor.map((item) => { if (item._id == org._id) { @@ -380,7 +366,6 @@ const UsersTableItem = (props: Props): JSX.Element => { - {/* Organizations blocked by modal */} { {user.user.organizationsBlockedBy.length !== 0 && (
    {
    ) : orgsBlockedBy.length == 0 ? ( - <> -
    -

    - {tCommon('noResultsFoundFor')} " - {searchByNameOrgsBlockedBy} - " -

    -
    - +
    +

    {`${tCommon('noResultsFoundFor')} "${searchByNameOrgsBlockedBy}"`}

    +
    ) : (
    @@ -450,10 +428,8 @@ const UsersTableItem = (props: Props): JSX.Element => { - {orgsBlockedBy.map((org) => { - // Check user is admin for this organization or not let isAdmin = false; user.appUserProfile.adminFor.map((item) => { if (item._id == org._id) { @@ -573,7 +549,6 @@ const UsersTableItem = (props: Props): JSX.Element => { - {/* Remove user from Organization modal */} Date: Thu, 23 May 2024 06:47:24 +0530 Subject: [PATCH 23/26] Update common.json with startTime and endTime translations --- .github/workflows/compare_translations.py | 44 ++++++++++++++--------- public/locales/fr/common.json | 5 ++- public/locales/hi/common.json | 5 ++- public/locales/sp/common.json | 5 ++- public/locales/zh/common.json | 5 ++- 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.github/workflows/compare_translations.py b/.github/workflows/compare_translations.py index f6f22e843c..b689439a9f 100644 --- a/.github/workflows/compare_translations.py +++ b/.github/workflows/compare_translations.py @@ -112,26 +112,36 @@ def check_translations(directory): Returns: None """ - default_file = "en.json" - default_translation = load_translation(os.path.join(directory, default_file)) - translations = os.listdir(directory) - translations.remove(default_file) # Exclude default translation + default_language_dir = os.path.join(directory, "en") + default_files = ["common.json", "errors.json", "translation.json"] + default_translations = {} + for file in default_files: + file_path = os.path.join(default_language_dir, file) + default_translations[file] = load_translation(file_path) + + languages = os.listdir(directory) + languages.remove("en") # Exclude default language directory + error_found = False - for translation_file in translations: - other_file = os.path.join(directory, translation_file) - other_translation = load_translation(other_file) + for language in languages: + language_dir = os.path.join(directory, language) + for file in default_files: + default_translation = default_translations[file] + other_file_path = os.path.join(language_dir, file) + other_translation = load_translation(other_file_path) + + # Compare translations and get detailed error messages + errors = compare_translations( + default_translation, other_translation, f"en/{file}", f"{language}/{file}" + ) + if errors: + error_found = True + print(f"File {language}/{file} has missing translations for:") + for error in errors: + print(f" - {error}") - # Compare translations and get detailed error messages - errors = compare_translations( - default_translation, other_translation, default_file, translation_file - ) - if errors: - error_found = True - print(f"File {translation_file} has missing translations for:") - for error in errors: - print(f" - {error}") if error_found: sys.exit(1) # Exit with an error status code @@ -154,7 +164,7 @@ def main(): "--directory", type=str, nargs="?", - default=os.path.join(os.getcwd(), "public/locales"), + default=os.path.join(os.getcwd(), "locales"), help="Directory containing translation files(relative to the root directory).", ) args = parser.parse_args() diff --git a/public/locales/fr/common.json b/public/locales/fr/common.json index 5bb07613d4..49bfd3b5cd 100644 --- a/public/locales/fr/common.json +++ b/public/locales/fr/common.json @@ -42,7 +42,10 @@ "talawaAdminPortal": "Portail d'administration Talawa", "address": "Adresse", "location": "Emplacement", + "enterLocation": "Entrez l'emplacement", "joined": "Rejoint", "startDate": "Date de début", - "endDate": "Date de fin" + "endDate": "Date de fin", + "startTime": "Heure de début", + "endTime": "Heure de fin" } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 4e25c4e1c9..9431a45afc 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -42,7 +42,10 @@ "talawaAdminPortal": "तलावा एडमिन पोर्टल", "address": "पता", "location": "जगह", + "enterLocation": "स्थान दर्ज करें", "joined": "में शामिल हो गए", "startDate": "आरंभ करने की तिथि", - "endDate": "अंतिम तिथि" + "endDate": "अंतिम तिथि", + "startTime": "समय शुरू", + "endTime": "अंत समय" } diff --git a/public/locales/sp/common.json b/public/locales/sp/common.json index 66f3959604..75d994a01b 100644 --- a/public/locales/sp/common.json +++ b/public/locales/sp/common.json @@ -42,7 +42,10 @@ "talawaAdminPortal": "Talawa Admin Portal", "address": "Address", "location": "Location", + "enterLocation": "Enter Location", "joined": "Joined", "startDate": "Start Date", - "endDate": "End Date" + "endDate": "End Date", + "startTime": "Start Time", + "endTime": "End Time" } diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index 9af70a4dc8..c8a640e83d 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -42,7 +42,10 @@ "talawaAdminPortal": "塔拉瓦管理门户", "address": "地址", "location": "地点", + "enterLocation": "输入位置", "joined": "已加入", "startDate": "开始日期", - "endDate": "结束日期" + "endDate": "结束日期", + "startTime": "开始时间", + "endTime": "时间结束" } From 36a97e31dac92f2c9c790b85c1627c843f3b7b62 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Thu, 23 May 2024 06:50:46 +0530 Subject: [PATCH 24/26] Update error translations in French, Hindi, Spanish, and Chinese locales --- .github/workflows/compare_translations.py | 12 +++++++++--- public/locales/fr/errors.json | 9 +++++++++ public/locales/hi/errors.json | 9 +++++++++ public/locales/sp/errors.json | 9 +++++++++ public/locales/zh/errors.json | 9 +++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compare_translations.py b/.github/workflows/compare_translations.py index b689439a9f..fd4f772605 100644 --- a/.github/workflows/compare_translations.py +++ b/.github/workflows/compare_translations.py @@ -98,9 +98,15 @@ def load_translation(filepath): Returns: translation: Loaded translation """ - with open(filepath, "r", encoding="utf-8") as file: - translation = json.load(file) - return translation + try: + with open(filepath, "r", encoding="utf-8") as file: + content = file.read() + if not content.strip(): + raise ValueError(f"File {filepath} is empty.") + translation = json.loads(content) + return translation + except json.JSONDecodeError as e: + raise ValueError(f"Error decoding JSON from file {filepath}: {e}") def check_translations(directory): diff --git a/public/locales/fr/errors.json b/public/locales/fr/errors.json index e69de29bb2..5788340a97 100644 --- a/public/locales/fr/errors.json +++ b/public/locales/fr/errors.json @@ -0,0 +1,9 @@ +{ + "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible !. ", + "notFound": "Pas trouvé", + "unknownError": "Une erreur inconnue est survenue. {{msg}}", + "notAuthorised": "Désolé! ", + "errorSendingMail": "Erreur lors de l'envoi du courrier", + "emailNotRegistered": "Email non enregistré", + "notFoundMsg": "Oops! " +} diff --git a/public/locales/hi/errors.json b/public/locales/hi/errors.json index e69de29bb2..5e08ee8e9e 100644 --- a/public/locales/hi/errors.json +++ b/public/locales/hi/errors.json @@ -0,0 +1,9 @@ +{ + "talawaApiUnavailable": "तलवा-एपीआई सेवा उपलब्ध नहीं है! ", + "notFound": "नहीं मिला", + "unknownError": "एक अज्ञात त्रुटि हुई। {{msg}}", + "notAuthorised": "क्षमा मांगना! ", + "errorSendingMail": "मेल भेजने में त्रुटि", + "emailNotRegistered": "ईमेल पंजीकृत नहीं है", + "notFoundMsg": "उफ़! " +} diff --git a/public/locales/sp/errors.json b/public/locales/sp/errors.json index e69de29bb2..90b2acca9f 100644 --- a/public/locales/sp/errors.json +++ b/public/locales/sp/errors.json @@ -0,0 +1,9 @@ +{ + "talawaApiUnavailable": "Talawa-API service is unavailable!. Is it running? Check your network connectivity too.", + "notFound": "Not found", + "unknownError": "An unknown error occurred. Please try again later. {{msg}}", + "notAuthorised": "Sorry! you are not Authorised!", + "errorSendingMail": "Error sending mail", + "emailNotRegistered": "Email not registered", + "notFoundMsg": "Oops! The Page you requested was not found!" +} diff --git a/public/locales/zh/errors.json b/public/locales/zh/errors.json index e69de29bb2..7ddfe06ab4 100644 --- a/public/locales/zh/errors.json +++ b/public/locales/zh/errors.json @@ -0,0 +1,9 @@ +{ + "talawaApiUnavailable": "Talawa-API 服务不可用!", + "notFound": "未找到", + "unknownError": "出现未知错误。 {{msg}}", + "notAuthorised": "对不起!", + "errorSendingMail": "发送邮件时出错", + "emailNotRegistered": "邮箱未注册", + "notFoundMsg": "哎呀!" +} From 208743973445742fb83bb50f81dee99a21ee99c1 Mon Sep 17 00:00:00 2001 From: Pranshu Date: Sun, 26 May 2024 01:18:18 +0530 Subject: [PATCH 25/26] fix variable --- src/screens/OrgList/OrgList.test.tsx | 2 +- src/screens/OrgList/OrgListMocks.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/screens/OrgList/OrgList.test.tsx b/src/screens/OrgList/OrgList.test.tsx index b848b72c90..e7e0f7d4be 100644 --- a/src/screens/OrgList/OrgList.test.tsx +++ b/src/screens/OrgList/OrgList.test.tsx @@ -499,7 +499,7 @@ describe('Organisations Page testing as Admin', () => { test('Testing sort latest and oldest toggle', async () => { setItem('id', '123'); setItem('SuperAdmin', false); - setItem('AdminFor', [{ name: 'adi', _id: '1234', image: '' }]); + setItem('AdminFor', [{ name: 'adi', _id: 'a0', image: '' }]); await act(async () => { render( diff --git a/src/screens/OrgList/OrgListMocks.ts b/src/screens/OrgList/OrgListMocks.ts index 0706ec8f1f..380313ffd5 100644 --- a/src/screens/OrgList/OrgListMocks.ts +++ b/src/screens/OrgList/OrgListMocks.ts @@ -113,10 +113,10 @@ const MOCKS = [ { request: { query: USER_ORGANIZATION_LIST, - variables: { id: '123' }, + variables: { userId: '123' }, }, result: { - data: superAdminUser, + data: { user: superAdminUser }, }, }, { @@ -183,10 +183,10 @@ const MOCKS_EMPTY = [ { request: { query: USER_ORGANIZATION_LIST, - variables: { id: '123' }, + variables: { userId: '123' }, }, result: { - data: superAdminUser, + data: { user: superAdminUser }, }, }, ]; @@ -211,10 +211,10 @@ const MOCKS_WITH_ERROR = [ { request: { query: USER_ORGANIZATION_LIST, - variables: { id: '123' }, + variables: { userId: '123' }, }, result: { - data: superAdminUser, + data: { user: superAdminUser }, }, }, { @@ -247,10 +247,10 @@ const MOCKS_ADMIN = [ { request: { query: USER_ORGANIZATION_LIST, - variables: { id: '123' }, + variables: { userId: '123' }, }, result: { - data: adminUser, + data: { user: adminUser }, }, }, ]; From b58811e45c5f71916db964d8024617ee4cc2f46d Mon Sep 17 00:00:00 2001 From: Pranshu Date: Sun, 26 May 2024 02:12:21 +0530 Subject: [PATCH 26/26] fix tests usertableitem --- .../UsersTableItem/UserTableItem.test.tsx | 256 +++++++++++++++++- .../UsersTableItem/UserTableItemMocks.ts | 48 +++- 2 files changed, 302 insertions(+), 2 deletions(-) diff --git a/src/components/UsersTableItem/UserTableItem.test.tsx b/src/components/UsersTableItem/UserTableItem.test.tsx index e89288ff28..bfa0a31c86 100644 --- a/src/components/UsersTableItem/UserTableItem.test.tsx +++ b/src/components/UsersTableItem/UserTableItem.test.tsx @@ -6,11 +6,18 @@ import { toast } from 'react-toastify'; import { StaticMockLink } from 'utils/StaticMockLink'; import i18nForTest from 'utils/i18nForTest'; import type { InterfaceQueryUserListItem } from 'utils/interfaces'; -import { MOCKS } from './UserTableItemMocks'; +import { MOCKS, MOCKS2, MOCKS_UPDATE } from './UserTableItemMocks'; import UsersTableItem from './UsersTableItem'; import { BrowserRouter } from 'react-router-dom'; const link = new StaticMockLink(MOCKS, true); +const link2 = new StaticMockLink(MOCKS2, true); +const link3 = new StaticMockLink(MOCKS_UPDATE, true); import useLocalStorage from 'utils/useLocalstorage'; +import { + REMOVE_ADMIN_MUTATION, + REMOVE_MEMBER_MUTATION, +} from 'GraphQl/Mutations/mutations'; +import userEvent from '@testing-library/user-event'; const { setItem } = useLocalStorage(); @@ -1084,4 +1091,251 @@ describe('Testing User Table Item', () => { fireEvent.click(confirmRemoveBtn); }); + + test('handles errors in removeUser mutation', async () => { + const props: { + user: InterfaceQueryUserListItem; + index: number; + loggedInUserId: string; + resetAndRefetch: () => void; + } = { + user: { + user: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe', + email: '', + createdAt: '2022-09-29T15:39:36.355Z', + organizationsBlockedBy: [ + { + _id: 'xyz', + name: 'Blocked Organization 1', + image: + 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, + createdAt: '2023-08-29T15:39:36.355Z', + creator: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: + 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe', + email: '', + }, + }, + ], + joinedOrganizations: [ + { + _id: 'abc', + name: 'Joined Organization 1', + image: null, + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, + createdAt: '2023-08-29T15:39:36.355Z', + creator: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: null, + email: '', + }, + }, + ], + registeredEvents: [], + membershipRequests: [], + }, + appUserProfile: { + _id: '123', + isSuperAdmin: true, + createdOrganizations: [], + createdEvents: [], + eventAdmin: [], + adminFor: [ + { + _id: 'abc', + }, + { + _id: 'xyz', + }, + ], + }, + }, + index: 0, + loggedInUserId: '123', + resetAndRefetch: resetAndRefetchMock, + }; + + const mocks = [ + { + request: { + query: REMOVE_MEMBER_MUTATION, + variables: { + userId: '123', + orgId: 'xyz', + }, + }, + result: { + errors: [ + { + message: 'User does not exist', + }, + ], + }, + }, + ]; + + render( + + + + + + + , + ); + + await wait(); + const showBlockedByOrgsBtn = screen.getByTestId( + `showBlockedByOrgsBtn${123}`, + ); + expect(showBlockedByOrgsBtn).toBeInTheDocument(); + fireEvent.click(showBlockedByOrgsBtn); + expect(screen.getByTestId('modal-blocked-org-123')).toBeInTheDocument(); + }); + + test('change role button should function properly', async () => { + const props: { + user: InterfaceQueryUserListItem; + index: number; + loggedInUserId: string; + resetAndRefetch: () => void; + } = { + user: { + user: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe', + email: '', + createdAt: '2022-09-29T15:39:36.355Z', + organizationsBlockedBy: [ + { + _id: 'xyz', + name: 'Blocked Organization 1', + image: + 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, + createdAt: '2023-08-29T15:39:36.355Z', + creator: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: + 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe', + email: '', + }, + }, + ], + joinedOrganizations: [ + { + _id: 'abc', + name: 'Joined Organization 1', + image: null, + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, + createdAt: '2023-08-29T15:39:36.355Z', + creator: { + _id: '123', + firstName: 'John', + lastName: 'Doe', + image: null, + email: '', + }, + }, + ], + registeredEvents: [], + + membershipRequests: [], + }, + appUserProfile: { + _id: '123', + isSuperAdmin: false, + createdOrganizations: [], + createdEvents: [], + eventAdmin: [], + adminFor: [ + { + _id: 'abc', + }, + { + _id: 'xyz', + }, + ], + }, + }, + index: 0, + loggedInUserId: '123', + resetAndRefetch: resetAndRefetchMock, + }; + + render( + + + + + + + , + ); + + await wait(); + const showJoinedOrgs = screen.getByTestId(`showJoinedOrgsBtn${123}`); + expect(showJoinedOrgs).toBeInTheDocument(); + fireEvent.click(showJoinedOrgs); + const changeRoleBtn = screen.getByTestId( + `changeRoleInOrg${'abc'}`, + ) as HTMLSelectElement; + expect(changeRoleBtn).toBeInTheDocument(); + userEvent.selectOptions(changeRoleBtn, 'ADMIN'); + await wait(); + userEvent.selectOptions(changeRoleBtn, 'USER'); + await wait(); + expect(changeRoleBtn.value).toBe(`USER?abc`); + await wait(); + }); }); diff --git a/src/components/UsersTableItem/UserTableItemMocks.ts b/src/components/UsersTableItem/UserTableItemMocks.ts index 02c430f959..3162487f33 100644 --- a/src/components/UsersTableItem/UserTableItemMocks.ts +++ b/src/components/UsersTableItem/UserTableItemMocks.ts @@ -3,7 +3,7 @@ import { UPDATE_USER_ROLE_IN_ORG_MUTATION, } from 'GraphQl/Mutations/mutations'; -export const MOCKS = [ +const MOCKS = [ { request: { query: REMOVE_MEMBER_MUTATION, @@ -20,6 +20,39 @@ export const MOCKS = [ }, }, }, + { + request: { + query: UPDATE_USER_ROLE_IN_ORG_MUTATION, + variables: { + userId: '123', + organizationId: 'abc', + role: 'USER', + }, + }, + result: { + data: { + updateUserRoleInOrganization: { + _id: '123', + }, + }, + }, + }, +]; + +const MOCKS2 = [ + { + request: { + query: REMOVE_MEMBER_MUTATION, + variables: { + userid: '123', + orgid: 'abc', + }, + }, + error: new Error('Failed to remove member'), + }, +]; + +const MOCKS_UPDATE = [ { request: { query: UPDATE_USER_ROLE_IN_ORG_MUTATION, @@ -29,6 +62,17 @@ export const MOCKS = [ role: 'ADMIN', }, }, + error: new Error('Failed to update user role in organization'), + }, + { + request: { + query: UPDATE_USER_ROLE_IN_ORG_MUTATION, + variables: { + userId: '123', + organizationId: 'abc', + role: 'USER', + }, + }, result: { data: { updateUserRoleInOrganization: { @@ -38,3 +82,5 @@ export const MOCKS = [ }, }, ]; + +export { MOCKS, MOCKS2, MOCKS_UPDATE };
    Action