Skip to content
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
4 changes: 2 additions & 2 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jmstechnologiesinc/react-native-components",
"version": "0.7.1",
"version": "0.7.2",
"description": "Biblioteca de componentes de interfaz compartida por las aplicaciones de Daxir.",
"author": "yerloveraaa <yerloveraaa@gmail.com>",
"homepage": "https://github.com/jmstechnologiesinc/react-native-components#readme",
Expand Down
11 changes: 11 additions & 0 deletions packages/components/src/Form/Form.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ export const AuthFormEmailPasswordDisabled = () => (
/>
);

export const AuthFormEmailHelperText = () => (
<AuthForm.EmailPassword
email={state.email}
inputActionHandler={() => {}}
showPasswordInput={false}
showConfirmPasswordInput={false}
isEmailDisabled={true}
emailHelperText="This email comes from your Google account and can't be changed here."
/>
);

export const AuthFormPersonInfo = () => (
<AuthForm.PersonInfo
firstName={state.firstName}
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/Form/FormEmailPassword.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import { TextInput, Button, MD3LightTheme } from '@jmstechnologiesinc/react-native-paper';
import { TextInput, Button, HelperText, MD3LightTheme } from '@jmstechnologiesinc/react-native-paper';
import ScreenWrapper from '../ScreenWrapper';
import { localized } from '../Localization/Localization';

Expand All @@ -15,6 +15,8 @@ const FormEmailPassword = ({
passwordConfirm,
isLoading = false,
isEmailDisabled = false,
// A line under the email, already localized: the host's reason for it (why it cannot be changed, say).
emailHelperText,
isPasswordDisabled = false,
isPasswordButtonLoading = false,
showConfirmPasswordInput = true,
Expand Down Expand Up @@ -43,6 +45,7 @@ const FormEmailPassword = ({
onChangeText={(email) => inputActionHandler('email', email)}
disabled={isEmailDisabled}
/>
{emailHelperText ? <HelperText>{emailHelperText}</HelperText> : null}
</ScreenWrapper.Section>

{showPasswordInput ? (
Expand Down
57 changes: 57 additions & 0 deletions packages/components/src/Form/__tests__/FormEmailPassword.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Form.EmailPassword places the host's line under the email (the app's profile says why a social sign-in's address
// cannot be changed there), inside the email's own section, as the business form places its helper texts.
jest.mock('react-native-localize', () => ({
findBestLanguageTag: jest.fn(() => ({ languageTag: 'en', isRTL: false })),
}));
// The section frame alone: the package's ScreenWrapper entry also loads the camera's native modules.
jest.mock('../../ScreenWrapper', () => ({ __esModule: true, default: { Section: 'ScreenWrapper.Section' } }));

import React from 'react';
import renderer, { act } from 'react-test-renderer';

import { HelperText, MD3LightTheme, Provider, TextInput } from '@jmstechnologiesinc/react-native-paper';

import FormEmailPassword from '../FormEmailPassword';

// Paper's HelperText animates its entrance: its timers run inside the test, as the inputs' own suite runs them.
jest.useFakeTimers();

const LINE = "This email comes from your Google account and can't be changed here.";

const emailSectionOf = (props) => {
let tree;
act(() => {
tree = renderer.create(
<Provider theme={MD3LightTheme}>
<FormEmailPassword
email="ada@example.com"
showPasswordInput={false}
showConfirmPasswordInput={false}
inputActionHandler={() => {}}
{...props}
/>
</Provider>
);
});
const [section] = tree.root.findAllByType('ScreenWrapper.Section');
const helperTexts = section.findAllByType(HelperText).map((helperText) => helperText.props.children);
const { disabled } = section.findByType(TextInput).props;
act(() => {
tree.unmount();
jest.runOnlyPendingTimers();
});
return { helperTexts, disabled };
};

describe('Form.EmailPassword', () => {
it('shows no line under the email by default', () => {
expect(emailSectionOf().helperTexts).toEqual([]);
});

it('shows the host’s line under the email, in its section', () => {
const { helperTexts, disabled } = emailSectionOf({ isEmailDisabled: true, emailHelperText: LINE });

expect(helperTexts).toEqual([LINE]);
expect(disabled).toBe(true);
});
});
4 changes: 2 additions & 2 deletions packages/components/src/Localization/Translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@
"storeDetailsUpdated": "Store details updated successfully.",
"fulfillmentMethodsUpdated": "Fulfillment Methods updated successfully.",
"preferencesUpdated": "Preferences updated successfully successfully.",
"emailUpdated": "Your changes have been saved. If you updated your email address, confirm it with the link we sent you.",
"profileUpdated": "Perfil actualizada con éxito.",
"emailUpdated": "We sent a link to %{email}. Your email changes when you open it.",
"profileUpdated": "Profile updated.",
"submissionStatus": "Request received. We are reviewing your submission.",
"paymentMethodUpdated": "Your payment method was updated successfully.",
"partnerReviewed": "The application was reviewed successfully.",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Localization/Translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@
"storeDetailsUpdated": "Detalles de la tienda actualizados con éxito.",
"fulfillmentMethodsUpdated": "Métodos de cumplimiento actualizados con éxito.",
"preferencesUpdated": "¡Preferencias actualizadas con éxito.",
"profileUpdated": "Tus cambios han sido guardados. Si actualizaste tu correo, confírmalo con el enlace que te enviamos.",
"emailUpdated": "Perfil actualizada con éxito.",
"profileUpdated": "Perfil actualizado.",
"emailUpdated": "Te enviamos un enlace a %{email}. Tu correo cambia cuando lo abras.",
"submissionStatus": "Solicitud recibida. Estamos revisando tu envío.",
"paymentMethodUpdated": "Su método de pago se actualizó con éxito.",
"partnerReviewed": "La solicitud se revisó correctamente.",
Expand Down
Loading