@doxa-code/utils
v0.1.8
Published
Funções úteis para o desenvolvimento de aplicações
Downloads
3
Readme
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>
*/