@codecraftkit
Documentation
Helpers is package that has a bundle of useful functions to use in the project.
npm install @codecraftkit/helpers
npm i @apollo/client graphql moment subscriptions-transport-wsnpm i isomorphic-unfetch is-electron slugify
Some components their own standalone package
npm i @codecraftkit/comet
This helper allows to make calls to the meteor backend
To use Comet first yo have to initialize it in you _app page like this
import { Comet as CometApi} from '@codecraftkit/helpers'// o import Comet from '@codecraftkit/comet'/*** Meteor Backend Connection*/global['Comet'] = CometApi({host: process.env.NEXT_PUBLIC_METEOR_BACKEND,ssl: process.env.NEXT_PUBLIC_METEOR_SSL,tokenKey: 'token'})
Running a fecth query
const getDataSelect = async (value) => {setLoading(true);try {const res = await Comet.call('service.name',{filters});if(res.success){setData(res.data)}setLoading(false)} catch (e) {}};
npm i @codecraftkit/texttransform
toLowerCase allows the user to transform the text into a camelCase Form
toLowerCase("STRING TO CAMEL CASE") // string to camel case
npm i @codecraftkit/phonenumber
phoneNumber allows us to add a prefix to a phone number and chose if we want to show it or not
phoneNumber(58846141788,'58') // +58 (588) 461-4178
npm i @codecraftkit/splititem
It gets a string with the keys of the object separate by a dot, Then it takes care of looping through each key to get the value from the object that is the second argument
splitItem("user.name.name",{user:{name:{name:"Jose"}}}) // Jose
npm i @codecraftkit/redirectto
redirectTo is use to redirect the user to another route
redirectTo(anotherRoute)
npm i @codecraftkit/slug
Transform a String into slug form
slug("ESTO ES UNA RUTA") // esto-es-una-ruta
Format any number to a more legible format
NumberFormat(5000000000) // 5,000,000,000
Parse time in seconds to get its duration
getDuration(5000000000) // 08:53:20