Skip to content

Instantly share code, notes, and snippets.

View enriquebeta6's full-sized avatar

Enrique Mora enriquebeta6

View GitHub Profile
import fs from 'fs'
async function init() {
let token = ''
const size = 1000
const schema = ''
const allDocuments = []
const accountName = ''
const fields = ['_all'].join(',')
const entity = ''
function getEntityNameAndSchemaOfMDV2({
appName,
vendor,
entity,
version,
workspace = '',
}) {
return {
entityName: `${vendor}_${appName}_${entity}`.replace(/(\.)|-|:|@/gi, "_"),
schema: [version, workspace].filter(Boolean).join('-'),
@enriquebeta6
enriquebeta6 / deleteAll.js
Last active February 15, 2024 17:09
MasterData Utils
async function deleteAll(entity) {
const sleep = (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms)
})
}
while (true) {
const randomNumber = Math.ceil(Math.random() * 100000)
@enriquebeta6
enriquebeta6 / withOrderForm.tsx
Created October 7, 2022 15:34
This HOC is a util that can be use with this app https://github.com/vtex-apps/checkout-button-example
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable import/order */
// Dependencies
import React from 'react'
type OrderForm = any
interface StateProviderState {
orderForm: OrderForm | null
}
// Depedencies
import React from 'react'
import { createPortal } from 'react-dom'
// Components
import ErrorBoundary from './ErrorBoundary'
interface SafePortalProps {
rootSelector: string
applyCleanup?: boolean
@enriquebeta6
enriquebeta6 / updateMarketingData.ts
Created July 5, 2022 18:19
Update the marketing data inside of VTEX OrderForm
// Dependencies
import Cookies from 'js-cookie'
// TODO: improve this typing
declare global {
interface Window {
vtexjs: {
checkout: {
orderForm: any;
getOrderForm: () => Promise<any>;