0.1.8 • Published 3 years ago

@doxa-code/utils v0.1.8

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

DOXA CODE - UTILS

Format Money

  import { formatMoney } from '@doxa-code/utils'

  formatMoney("0.43") // R$ 0,43

Set Fields Value

This function sets the value of all inputs in its components, following the Object inserted as a parameter

  import { setFieldsValue } from '@doxa-code/utils'
  import { useEffect } from 'react'

  const values = {
    name: "John Mayer",
    age: 35
  }

  useEffect(() => {
    if(values) {
      setFieldsValue(values)
    }
  }, [values])

  /*
    <input name="name"/>
    <input name="age" type="number">
  */

Set Fields Value

This function gets the value of all inputs, selects and textares in its components, following the parameter

  import { getFieldsValue } from '@doxa-code/utils'
  import { useEffect } from 'react'

  async function handleSubmit(e) {
    const fields = getFieldsValue(e) 
    console.log(fields)
    /*
      {
        name: "John Mayer",
        age: 35
      }
    */
  }

  /*
    <form onSubmit={handleSubmit}>
      <input name="name"/>
      <input name="age" type="number">
    </form>
  */
0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago