Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added dropdown for Applanguage in UserUpdation form #498

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"lastName": "Last Name",
"email": "Email",
"password": "Password",
"appLanguageCode": "App Language Code",
"appLanguageCode": "Default Language",
"userType": "User Type",
"admin": "Admin",
"superAdmin": "Superadmin",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"lastName": "Nom de famille",
"email": "E-mail",
"password": "Mot de passe",
"appLanguageCode": "Code de langue de l'application",
"appLanguageCode": "Langue par défaut",
"userType": "Type d'utilisateur",
"admin": "Administrateur",
"superAdmin": "Super administrateur",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"lastName": "उपनाम",
"email": "ईमेल",
"password": "पासवर्ड",
"appLanguageCode": "ऐप भाषा कोड",
"appLanguageCode": "डिफ़ॉल्ट भाषा",
"userType": "उपयोगकर्ता का प्रकार",
"admin": "व्यवस्थापक",
"superAdmin": "सुपरएडमिन",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"lastName": "Apellido",
"email": "Correo electrónico",
"password": "Clave",
"appLanguageCode": "Código de idioma de la aplicación",
"appLanguageCode": "Idioma predeterminado",
"userType": "Tipo de usuario",
"admin": "Administración",
"superAdmin": "Superadministrador",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"lastName": "姓",
"email": "電子郵件",
"password": "密碼",
"appLanguageCode": "應用語言代碼",
"appLanguageCode": "默认语言",
"userType": "用戶類型",
"admin": "行政",
"superAdmin": "超級管理員",
Expand Down
12 changes: 5 additions & 7 deletions src/components/UserUpdate/UserUpdate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Testing User Update', () => {
lastName: 'Doe',
email: 'johndoe@gmail.com',
password: 'qwerty',
applangcode: '2',
applangcode: 'en',
selectedOption: 'selectadmin',
displayImage: new File(['hello'], 'hello.png', { type: 'image/png' }),
};
Expand All @@ -75,8 +75,8 @@ describe('Testing User Update', () => {
);
userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email);
userEvent.type(screen.getByPlaceholderText(/Password/i), formData.password);
userEvent.type(
screen.getByPlaceholderText(/App Language Code/i),
userEvent.selectOptions(
screen.getByTestId(/applangcode/i),
formData.applangcode
);
userEvent.click(screen.getByLabelText('Admin'));
Expand All @@ -100,7 +100,7 @@ describe('Testing User Update', () => {
expect(screen.getByPlaceholderText(/Password/i)).toHaveValue(
formData.password
);
expect(screen.getByPlaceholderText(/App Language Code/i)).toHaveValue(
expect(screen.getByTestId(/applangcode/i)).toHaveValue(
formData.applangcode
);
expect(screen.getByLabelText('Admin')).not.toBeChecked();
Expand All @@ -112,9 +112,7 @@ describe('Testing User Update', () => {
expect(screen.getByPlaceholderText(/Last Name/i)).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Email/i)).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Password/i)).toBeInTheDocument();
expect(
screen.getByPlaceholderText(/App Language Code/i)
).toBeInTheDocument();
expect(screen.getByTestId(/applangcode/i)).toBeInTheDocument();
expect(screen.getByText('User Type')).toBeInTheDocument();
expect(screen.getByText('Admin')).toBeInTheDocument();
expect(screen.getByText('Superadmin')).toBeInTheDocument();
Expand Down
18 changes: 11 additions & 7 deletions src/components/UserUpdate/UserUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMutation } from '@apollo/client';
import { UPDATE_USER_MUTATION } from 'GraphQl/Mutations/mutations';
import { useTranslation } from 'react-i18next';

import { languages } from 'utils/languages';
import styles from './UserUpdate.module.css';

interface UserUpdateProps {
Expand Down Expand Up @@ -130,19 +131,22 @@ function UserUpdate(props: UserUpdateProps): JSX.Element {
<div className={styles.dispflex}>
<div>
<label>{t('appLanguageCode')}</label>
<input
type="input"
id="applangcode"
placeholder={t('appLanguageCode')}
required
value={formState.applangcode}
<select
className="form-control"
data-testid="applangcode"
onChange={(e) => {
setFormState({
...formState,
applangcode: e.target.value,
});
}}
/>
>
{languages.map((language, index: number) => (
<option key={index} value={language.code}>
{language.name}
</option>
))}
</select>
</div>
<div>
<label>{t('userType')}</label>
Expand Down