0.1.8 • Published 2 years ago

@doxa-code/utils v0.1.8

Weekly downloads
-
License
-
Repository
-
Last release
2 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

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago