Skip to content

Conversation

@yvmunayev
Copy link
Contributor

No description provided.

@commit-lint
Copy link

commit-lint bot commented Apr 5, 2023

Features

  • add MultiInput component (eba0521)

Contributors

yvmunayev

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

Visit the preview URL for this PR (updated for commit eba0521):

https://rainbow-modules--pr693-feat-add-multi-input-oyhkkx9u.web.app

(expires Wed, 12 Apr 2023 19:50:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a8717bcb415e206776430df4c4296748001a9951


# Overview

`MultiInput` is an component that allows you to enter many input.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's have chat GPT to help with the documentation

import { Field, UniversalForm } from '@rainbow-modules/forms';
import MultiInput from '../../src/components/MultiInput';

const GOOGLE_MAPS_APIKEY = process.env.STORYBOOK_GOOGLE_MAPS_APIKEY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and we already have an env for this called STORYBOOK_GOOGLE_MAPS_API_KEY in circle CI then let's change it here

<Field
name="phones"
label="Phone numbers"
component={(props) => <MultiInput component={PhoneInput} {...props} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change the prop name component to inputComponent then we can use it like

<Field
    label="Phone numbers"
    component={MultiInput}
    inputComponent={PhoneInput}
    validate={validate}
/>

@@ -0,0 +1,101 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not use enzyme anymore, instead use react testing library

label?: ReactNode;
error?: ReactNode;
value?: T;
onChange?: (value: any) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must avoid using any

? valueInProps
: [[undefined, undefined]];

const updatePhone = (index: number, newValue: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updatePhone?

? valueInProps
: [[undefined, undefined]];

const updatePhone = (index: number, newValue: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no any instead you can use unkown

: [{ label: isFirst ? 'Primary' : 'Secondary' }, { label: 'Note' }];

const rowError = !error || typeof error === 'string' ? null : (error[index] as RowError);
const phoneError = rowError && rowError.value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change var name phoneError

import { InputConfig, RowError } from './types';

interface InputProps<T> {
label?: ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think label is always required

@LeandroTorresSicilia
Copy link
Contributor

Screen Shot 2023-04-07 at 11 36 19 AM

using this example causes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants