From 82491b05e11780a404b156ad3688e8906484155a Mon Sep 17 00:00:00 2001 From: meetul Date: Wed, 31 Jan 2024 10:06:17 +0530 Subject: [PATCH] add translations --- public/locales/en.json | 14 +++- public/locales/fr.json | 20 +++++- public/locales/hi.json | 20 +++++- public/locales/sp.json | 20 +++++- public/locales/zh.json | 20 +++++- .../Mutations/ActionItemCategoryMutations.ts | 10 --- .../OrgActionItemCategories.module.css | 1 - .../OrgActionItemCategories.tsx | 69 +++++++++++-------- src/screens/OrgSettings/OrgSettings.tsx | 4 +- 9 files changed, 131 insertions(+), 47 deletions(-) diff --git a/public/locales/en.json b/public/locales/en.json index 563d11ab81..e07dd8d664 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -446,6 +446,8 @@ "orgSettings": { "title": "Talawa Setting", "pageName": "Settings", + "generalSettings": "General", + "actionItemCategorySettings": "Action Item Categories", "updateOrganization": "Update Organization", "seeRequest": "See Request", "settings": "Settings", @@ -742,10 +744,18 @@ "fieldRemovalSuccess": "Field removed successfully" }, "orgActionItemCategories": { - "addActionItemCategory": "Create", + "createButton": "Create", + "editButton": "Edit", + "enableButton": "Enable", + "disableButton": "Disable", "updateActionItemCategory": "Update", "actionItemCategoryName": "Name", "actionItemCategoryDetails": "Action Item Category Details", - "enterName": "Enter Name" + "enterName": "Enter Name", + "successfulCreation": "Action Item Category created successfully", + "successfulUpdation": "Action Item Category updated successfully", + "sameNameConflict": "Please change the name to make an update", + "categoryEnabled": "Action Item Category Enabled", + "categoryDisabled": "Action Item Category Disabled" } } diff --git a/public/locales/fr.json b/public/locales/fr.json index b9862b6912..63262db200 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -441,6 +441,8 @@ "orgSettings": { "title": "Paramètre Talawa", "pageName": "Paramètres", + "generalSettings": "Général", + "actionItemCategorySettings": "Catégories d’éléments d’action", "updateYourDetails": "Mettre à jour vos informations", "updateYourPassword": "Mettez à jour votre mot de passe", "updateOrganization": "Mettre à jour l'organisation", @@ -449,7 +451,8 @@ "noData": "Pas de données", "otherSettings": "Autres paramètres", "changeLanguage": "Changer la langue", - "manageCustomFields": "Gérer les Champs Personnalisés" + "manageCustomFields": "Gérer les Champs Personnalisés", + "actionItemCategories": "Catégories d’éléments d’action" }, "deleteOrg": { "deleteOrganization": "Supprimer l'organisation", @@ -724,5 +727,20 @@ "Supprimer le champ personnalisé": "Supprimer le champ personnalisé", "fieldSuccessMessage": "Champ ajouté avec succès", "fieldRemovalSuccess": "Champ supprimé avec succès" + }, + "orgActionItemCategories": { + "createButton": "Créez", + "editButton": "Éditez", + "enableButton": "Activez", + "disableButton": "Désactivez", + "updateActionItemCategory": "Mettre à jour", + "actionItemCategoryName": "Nom", + "actionItemCategoryDetails": "Détails de la catégorie d’élément d’action", + "enterName": "Entrez le nom", + "successfulCreation": "Catégorie d’élément d’action créée avec succès", + "successfulUpdation": "La catégorie d’élément d’action a été mise à jour avec succès", + "sameNameConflict": "Veuillez modifier le nom pour effectuer une mise à jour", + "categoryEnabled": "Catégorie d’action activée", + "categoryDisabled": "Catégorie d’action désactivée" } } diff --git a/public/locales/hi.json b/public/locales/hi.json index 7db22caa28..1a7cb368d6 100644 --- a/public/locales/hi.json +++ b/public/locales/hi.json @@ -441,6 +441,8 @@ "orgSettings": { "title": "तलावा सेटिंग", "pageName": "सेटिंग्स", + "generalSettings": "सामान्य", + "actionItemCategorySettings": "कार्रवाई आइटम श्रेणियाँ", "updateYourDetails": "अपना विवरण अपडेट करें", "updateYourPassword": "अपना पासवर्ड अपडेट करें", "updateOrganization": "अद्यतन संगठन", @@ -449,7 +451,8 @@ "noData": "कोई डेटा नहीं", "otherSettings": "अन्य सेटिंग्स", "changeLanguage": "भाषा बदलें", - "manageCustomFields": "कस्टम फ़ील्ड प्रबंधन करें" + "manageCustomFields": "कस्टम फ़ील्ड प्रबंधन करें", + "actionItemCategories": "कार्रवाई आइटम श्रेणियाँ" }, "deleteOrg": { "deleteOrganization": "संगठन हटाएं", @@ -725,5 +728,20 @@ "Remove Custom Field": "कस्टम फ़ील्ड हटाएँ", "fieldSuccessMessage": "फ़ील्ड सफलतापूर्वक जोड़ा गया", "fieldRemovalSuccess": "फ़ील्ड सफलतापूर्वक हटा दिया गया" + }, + "orgActionItemCategories": { + "createButton": "बनाएं", + "editButton": "संपादित करें", + "enableButton": "सक्षम करें", + "disableButton": "अक्षम करें", + "updateActionItemCategory": "अद्यतन करें", + "actionItemCategoryName": "नाम", + "actionItemCategoryDetails": "कार्रवाई आइटम श्रेणी विवरण", + "enterName": "नाम दर्ज करें", + "successfulCreation": "कार्रवाई आइटम श्रेणी सफलतापूर्वक बनाई गई", + "successfulUpdation": "क्रिया आइटम श्रेणी सफलतापूर्वक अद्यतन की गई", + "sameNameConflict": "अपडेट करने के लिए कृपया नाम बदलें", + "categoryEnabled": "कार्रवाई आइटम श्रेणी सक्षम", + "categoryDisabled": "क्रिया आइटम श्रेणी अक्षम की गई" } } diff --git a/public/locales/sp.json b/public/locales/sp.json index 76138e8045..9f87d93bd4 100644 --- a/public/locales/sp.json +++ b/public/locales/sp.json @@ -440,6 +440,8 @@ "orgSettings": { "title": "Configuración Talawa", "pageName": "Configuración", + "generalSettings": "General", + "actionItemCategorySettings": "Categorías de elementos de acción", "updateYourDetails": "Actualiza tus datos", "updateYourPassword": "Actualice su contraseña", "updateOrganization": "Actualizar Organización", @@ -448,7 +450,8 @@ "noData": "Sin datos", "otherSettings": "Otras Configuraciones", "changeLanguage": "Cambiar Idioma", - "manageCustomFields": "Gestionar Campos Personalizados" + "manageCustomFields": "Gestionar Campos Personalizados", + "actionItemCategories": "Categorías de elementos de acción" }, "deleteOrg": { "deleteOrganization": "Eliminar organización", @@ -724,5 +727,20 @@ "Remove Custom Field": "Eliminar Campo Personalizado", "fieldSuccessMessage": "Campo añadido exitosamente", "fieldRemovalSuccess": "Campo eliminado exitosamente" + }, + "orgActionItemCategories": { + "createButton": "Crear", + "editButton": "Editar", + "enableButton": "Habilitar", + "disableButton": "Inhabilitar", + "updateActionItemCategory": "Actualizar", + "actionItemCategoryName": "Nombre", + "actionItemCategoryDetails": "Detalles de la categoría de elemento de acción", + "enterName": "Introduzca el nombre", + "successfulCreation": "Categoría de elemento de acción creada correctamente", + "successfulUpdation": "Categoría de elemento de acción actualizada correctamente", + "sameNameConflict": "Cambie el nombre para realizar una actualización", + "categoryEnabled": "Categoría de elemento de acción habilitada", + "categoryDisabled": "Categoría de elemento de acción deshabilitada" } } diff --git a/public/locales/zh.json b/public/locales/zh.json index 8c1337c0de..b4e996a8c0 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -441,6 +441,8 @@ "orgSettings": { "title": "塔拉瓦設置", "pageName": "设置", + "generalSettings": "一般", + "actionItemCategorySettings": "措施项类别", "updateYourDetails": "更新您的詳細信息", "updateYourPassword": "更新您的密碼", "updateOrganization": "更新組織", @@ -449,7 +451,8 @@ "noData": "沒有數據", "otherSettings": "其他设置", "changeLanguage": "更改语言", - "manageCustomFields": "管理自定义字段" + "manageCustomFields": "管理自定义字段", + "actionItemCategories": "措施项类别" }, "deleteOrg": { "deleteOrganization": "删除组织", @@ -725,5 +728,20 @@ "删除自定义字段": "删除自定义字段", "fieldSuccessMessage": "字段添加成功", "fieldRemovalSuccess": "字段删除成功" + }, + "orgActionItemCategories": { + "createButton": "创建", + "editButton": "编辑", + "enableButton": "启用", + "disableButton": "禁用", + "updateActionItemCategory": "更新", + "actionItemCategoryName": "名称", + "actionItemCategoryDetails": "措施项类别详细信息", + "enterName": "输入名称", + "successfulCreation": "已成功创建措施项类别", + "successfulUpdation": "措施项类别已成功更新", + "sameNameConflict": "请更改名称以进行更新", + "categoryEnabled": "已启用措施项类别", + "categoryDisabled": "措施项类别已禁用" } } diff --git a/src/GraphQl/Mutations/ActionItemCategoryMutations.ts b/src/GraphQl/Mutations/ActionItemCategoryMutations.ts index 2b3f97fce0..62abe181fd 100644 --- a/src/GraphQl/Mutations/ActionItemCategoryMutations.ts +++ b/src/GraphQl/Mutations/ActionItemCategoryMutations.ts @@ -11,11 +11,6 @@ export const CREATE_ACTION_ITEM_CATEGORY_MUTATION = gql` mutation CreateActionItemCategory($name: String!, $organizationId: ID!) { createActionItemCategory(name: $name, organizationId: $organizationId) { _id - name - organization { - _id - } - isDisabled } } `; @@ -39,11 +34,6 @@ export const UPDATE_ACTION_ITEM_CATEGORY_MUTATION = gql` data: { name: $name, isDisabled: $isDisabled } ) { _id - name - organization { - _id - } - isDisabled } } `; diff --git a/src/components/OrgActionItemCategories/OrgActionItemCategories.module.css b/src/components/OrgActionItemCategories/OrgActionItemCategories.module.css index d3aa11911c..93c2babd0f 100644 --- a/src/components/OrgActionItemCategories/OrgActionItemCategories.module.css +++ b/src/components/OrgActionItemCategories/OrgActionItemCategories.module.css @@ -18,7 +18,6 @@ } .message { - height: 420px; display: flex; justify-content: center; align-items: center; diff --git a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx index ba070306f4..e6f72e5924 100644 --- a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx +++ b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx @@ -3,17 +3,17 @@ import React, { useState } from 'react'; import { Button, Form, Modal } from 'react-bootstrap'; import styles from './OrgActionItemCategories.module.css'; import { useTranslation } from 'react-i18next'; +import { toast } from 'react-toastify'; +import { WarningAmberRounded } from '@mui/icons-material'; import { useMutation, useQuery } from '@apollo/client'; import { CREATE_ACTION_ITEM_CATEGORY_MUTATION, UPDATE_ACTION_ITEM_CATEGORY_MUTATION, } from 'GraphQl/Mutations/mutations'; -import { toast } from 'react-toastify'; -import type { InterfaceActionItemCategoryList } from 'utils/interfaces'; import { ACTION_ITEM_CATEGORY_LIST } from 'GraphQl/Queries/ActionItemCategoryQueries'; +import type { InterfaceActionItemCategoryList } from 'utils/interfaces'; import Loader from 'components/Loader/Loader'; -import { WarningAmberRounded } from '@mui/icons-material'; type ModalType = 'Create' | 'Update'; @@ -27,6 +27,7 @@ const OrgActionItemCategories = (): any => { const [categoryId, setCategoryId] = useState(''); const [name, setName] = useState(''); + const [currName, setCurrName] = useState(''); const currentUrl = window.location.href.split('=')[1]; @@ -60,7 +61,7 @@ const OrgActionItemCategories = (): any => { ): Promise => { e.preventDefault(); try { - const { data } = await createActionItemCategory({ + await createActionItemCategory({ variables: { name, organizationId: currentUrl, @@ -72,8 +73,7 @@ const OrgActionItemCategories = (): any => { setAddModalIsOpen(false); - toast.success('Action Item Category created successfully'); - console.log(data); + toast.success(t('successfulCreation')); } catch (error: any) { toast.error(error.message); console.log(error); @@ -82,24 +82,28 @@ const OrgActionItemCategories = (): any => { const handleEdit = async (e: ChangeEvent): Promise => { e.preventDefault(); - try { - await updateActionItemCategory({ - variables: { - actionItemCategoryId: categoryId, - name, - }, - }); + if (name === currName) { + toast.info(t('sameNameConflict')); + } else { + try { + await updateActionItemCategory({ + variables: { + actionItemCategoryId: categoryId, + name, + }, + }); - setName(''); - setCategoryId(''); - refetch(); + setName(''); + setCategoryId(''); + refetch(); - setAddModalIsOpen(false); + setAddModalIsOpen(false); - toast.success('Action Item Category updated successfully'); - } catch (error: any) { - toast.error(error.message); - console.log(error); + toast.success(t('successfulUpdation')); + } catch (error: any) { + toast.error(error.message); + console.log(error); + } } }; @@ -118,9 +122,7 @@ const OrgActionItemCategories = (): any => { refetch(); toast.success( - `Action Item Category ${ - disabledStatus === true ? 'Enabled' : 'Disabled' - }` + disabledStatus ? t('categoryEnabled') : t('categoryDisabled') ); } catch (error: any) { toast.error(error.message); @@ -134,6 +136,7 @@ const OrgActionItemCategories = (): any => { }; const showUpdateModal = (name: string, id: string): void => { + setCurrName(name); setName(name); setCategoryId(id); setModalType('Update'); @@ -173,7 +176,7 @@ const OrgActionItemCategories = (): any => { data-testid="saveChangesBtn" > - {t('addActionItemCategory')} + {t('createButton')}
@@ -181,7 +184,15 @@ const OrgActionItemCategories = (): any => { return (
-
{category.name}
+
+ {category.name} +
diff --git a/src/screens/OrgSettings/OrgSettings.tsx b/src/screens/OrgSettings/OrgSettings.tsx index d159b645e2..b82fbf425f 100644 --- a/src/screens/OrgSettings/OrgSettings.tsx +++ b/src/screens/OrgSettings/OrgSettings.tsx @@ -38,7 +38,7 @@ function orgSettings(): JSX.Element { } onClick={() => setSetting('General')} > - General + {t('generalSettings')}