Skip to content

Commit

Permalink
Clients - Upgrade tn-forms (#378)
Browse files Browse the repository at this point in the history
## What this does

Upgrade tn-forms in clients and add lock files for R and R.
  • Loading branch information
lakardion authored Jan 23, 2025
1 parent 13c92f2 commit 1f015a4
Show file tree
Hide file tree
Showing 11 changed files with 31,074 additions and 206 deletions.
20,136 changes: 20,136 additions & 0 deletions {{cookiecutter.project_slug}}/clients/mobile/react-native/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@sentry/react-native": "~5.22.0",
"@shopify/flash-list": "1.6.4",
"@tanstack/react-query": "^5.15.0",
"@thinknimble/tn-forms": "^3.1.3",
"@thinknimble/tn-forms": "^3.3.3",
"@thinknimble/tn-forms-react": "^1.0.3",
"@thinknimble/tn-models": "^4.0.0",
"axios": "^1.3.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IFormFieldError } from '@thinknimble/tn-forms'
import React from 'react'
import { FC, Fragment, ReactNode } from 'react'
import { Text, View } from 'react-native'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Form, { IFormField } from '@thinknimble/tn-forms'
import { Form, FormFieldsRecord, IFormField } from '@thinknimble/tn-forms'
import { useTnForm } from '@thinknimble/tn-forms-react'
import { Text, TextInput, TextInputProps, View } from 'react-native'
import twColors from 'tailwindcss/colors'
import { ErrorsList } from '@components/errors'
import { FormFieldsRecord } from '@thinknimble/tn-forms/lib/cjs/types/interfaces'

export const TextFormField = <T extends IFormField<string>, TForm extends Form<FormFieldsRecord>>({
field,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,171 +1,171 @@
import Form, {
EmailValidator,
FormField,
IFormField,
MinLengthValidator,
RequiredValidator,
} from '@thinknimble/tn-forms'
export type AccountFormInputs = {
firstName: IFormField<string>
lastName: IFormField<string>
email: IFormField<string>
password: IFormField<string>
confirmPassword: IFormField<string>
}
export type AccountFormValues = {
/**
* HACK - PB - 2023-05-10
* Temporary hack to get the fields because the form returns all field values as <T> | undefined
*/
firstName: string
lastName: string
email: string
password: string
confirmPassword: string
}
export class AccountForm extends Form<AccountFormInputs> {
static firstName = FormField.create({
label: 'First name',
placeholder: 'First Name',
type: 'text',
validators: [new RequiredValidator({ message: 'Please enter your first' })],
value: '',
})

static lastName = FormField.create({
label: 'Last Name',
placeholder: 'Last Name',
type: 'text',
validators: [new RequiredValidator({ message: 'Please enter your last name' })],
value: '',
})

static email = FormField.create({
label: 'Email',
placeholder: 'Email',
type: 'email',
value: '',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})

static password = FormField.create({
label: 'Password',
placeholder: 'Password',
type: 'password',

validators: [
new MinLengthValidator({
minLength: 6,
message: 'Please enter a password with a minimum of six characters',
}),
],
value: '',
})

static confirmPassword = FormField.create({
label: 'Confirm Password',
placeholder: 'Confirm Password',
type: 'password',
value: '',
validators: [],
})
}
export type TAccountForm = AccountForm & AccountFormInputs
export type EmailForgotPasswordInput = {
email: IFormField<string>
}
export class EmailForgotPasswordForm extends Form<EmailForgotPasswordInput> {
static email = FormField.create({
label: 'Email',
placeholder: 'Email',
type: 'email',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
}
export type TEmailForgotPasswordForm = EmailForgotPasswordForm & EmailForgotPasswordInput
export type ResetPasswordInput = {
email: IFormField<string>
code: IFormField<string>
password: IFormField<string>
confirmPassword: IFormField<string>
}
export class ResetPasswordForm extends Form<ResetPasswordInput> {
static email = new FormField({
label: 'Email',
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
static code = new FormField({
placeholder: 'Verification Code',
type: 'number',
validators: [
new MinLengthValidator({ message: 'Please enter a valid 5 digit code', minLength: 5 }),
],
})
static password = FormField.create({
label: 'Password',
placeholder: 'Password',
type: 'password',

validators: [
new MinLengthValidator({
minLength: 6,
message: 'Please enter a password with at least 6 characters',
}),
],
value: '',
})

static confirmPassword = FormField.create({
label: 'Confirm Password',
placeholder: 'Confirm Password',
type: 'password',
value: '',
validators: [],
})
}
export type TResetPasswordForm = ResetPasswordForm & ResetPasswordInput
export type LoginFormInputs = {
email: IFormField<string>
confirmEmail: IFormField<string>
password: IFormField<string>
}
export type TLoginForm = LoginFormInputs & LoginForm
export class LoginForm extends Form<LoginFormInputs> {
static email = new FormField({
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
static password = new FormField({
validators: [new RequiredValidator({ message: 'Please enter your password' })],
placeholder: 'Password',
value: '',
type: 'password',
})
}
export type ForgotPasswordInput = {
email: IFormField<string>
}
export class ForgotPasswordForm extends Form<ForgotPasswordInput> {
static email = new FormField({
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
}
export type TForgotPasswordForm = ForgotPasswordForm & ForgotPasswordInput
import {
Form,
EmailValidator,
FormField,
IFormField,
MinLengthValidator,
RequiredValidator,
} from '@thinknimble/tn-forms'

export type AccountFormInputs = {
firstName: IFormField<string>
lastName: IFormField<string>
email: IFormField<string>
password: IFormField<string>
confirmPassword: IFormField<string>
}
export type AccountFormValues = {
/**
* HACK - PB - 2023-05-10
* Temporary hack to get the fields because the form returns all field values as <T> | undefined
*/
firstName: string
lastName: string
email: string
password: string
confirmPassword: string
}
export class AccountForm extends Form<AccountFormInputs> {
static firstName = FormField.create({
label: 'First name',
placeholder: 'First Name',
type: 'text',
validators: [new RequiredValidator({ message: 'Please enter your first' })],
value: '',
})

static lastName = FormField.create({
label: 'Last Name',
placeholder: 'Last Name',
type: 'text',
validators: [new RequiredValidator({ message: 'Please enter your last name' })],
value: '',
})

static email = FormField.create({
label: 'Email',
placeholder: 'Email',
type: 'email',
value: '',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})

static password = FormField.create({
label: 'Password',
placeholder: 'Password',
type: 'password',

validators: [
new MinLengthValidator({
minLength: 6,
message: 'Please enter a password with a minimum of six characters',
}),
],
value: '',
})

static confirmPassword = FormField.create({
label: 'Confirm Password',
placeholder: 'Confirm Password',
type: 'password',
value: '',
validators: [],
})
}
export type TAccountForm = AccountForm & AccountFormInputs

export type EmailForgotPasswordInput = {
email: IFormField<string>
}

export class EmailForgotPasswordForm extends Form<EmailForgotPasswordInput> {
static email = FormField.create({
label: 'Email',
placeholder: 'Email',
type: 'email',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
}

export type TEmailForgotPasswordForm = EmailForgotPasswordForm & EmailForgotPasswordInput

export type ResetPasswordInput = {
email: IFormField<string>
code: IFormField<string>
password: IFormField<string>
confirmPassword: IFormField<string>
}

export class ResetPasswordForm extends Form<ResetPasswordInput> {
static email = new FormField({
label: 'Email',
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
static code = new FormField({
placeholder: 'Verification Code',
type: 'number',
validators: [
new MinLengthValidator({ message: 'Please enter a valid 5 digit code', minLength: 5 }),
],
})
static password = FormField.create({
label: 'Password',
placeholder: 'Password',
type: 'password',

validators: [
new MinLengthValidator({
minLength: 6,
message: 'Please enter a password with at least 6 characters',
}),
],
value: '',
})

static confirmPassword = FormField.create({
label: 'Confirm Password',
placeholder: 'Confirm Password',
type: 'password',
value: '',
validators: [],
})
}

export type TResetPasswordForm = ResetPasswordForm & ResetPasswordInput

export type LoginFormInputs = {
email: IFormField<string>
confirmEmail: IFormField<string>
password: IFormField<string>
}
export type TLoginForm = LoginFormInputs & LoginForm

export class LoginForm extends Form<LoginFormInputs> {
static email = new FormField({
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
static password = new FormField({
validators: [new RequiredValidator({ message: 'Please enter your password' })],
placeholder: 'Password',
value: '',
type: 'password',
})
}

export type ForgotPasswordInput = {
email: IFormField<string>
}

export class ForgotPasswordForm extends Form<ForgotPasswordInput> {
static email = new FormField({
placeholder: 'Email',
type: 'emailAddress',
validators: [new EmailValidator({ message: 'Please enter a valid email' })],
})
}

export type TForgotPasswordForm = ForgotPasswordForm & ForgotPasswordInput
Loading

0 comments on commit 1f015a4

Please sign in to comment.