New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@open-tender/utils

Package Overview
Dependencies
Maintainers
2
Versions
370
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-tender/utils - npm Package Compare versions

Comparing version 0.1.31 to 0.1.32

6

dist/cjs/hooks/useProfileForm.d.ts
/// <reference types="react" />
import { Customer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
import { Customer, CustomerCreate, FormFields, Gender, RequestError, RequestStatus } from '@open-tender/types';
export declare const genderOptions: {
name: string;
value: Gender;
}[];
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void) => {

@@ -4,0 +8,0 @@ submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;

10

dist/cjs/hooks/useProfileForm.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useProfileForm = void 0;
exports.useProfileForm = exports.genderOptions = void 0;
const react_1 = require("react");
const utils_1 = require("../utils");
const genderOptions = [
exports.genderOptions = [
{ name: 'not specified', value: 'DECLINED' },

@@ -32,3 +32,3 @@ { name: 'Male', value: 'MALE' },

{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
{ label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
{ label: 'Gender', name: 'gender', type: 'select', options: exports.genderOptions }
];

@@ -40,4 +40,2 @@ (0, react_1.useEffect)(() => {

const errs = (0, utils_1.makeFormErrors)(error);
if (errs)
errs.form = 'There are one or more errors below.';
if (errs.birth_date) {

@@ -77,4 +75,2 @@ errs.birth_date = 'Invalid date. Please enter in mm/dd/yyyy format.';

const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
// const rest = { ...data }
// const { customer_id, is_notification_set, is_verified, ...rest } = data
rest.birth_date = data.birth_date ? (0, utils_1.slashesToDashes)(data.birth_date) : null;

@@ -81,0 +77,0 @@ rest.gender = data.gender || null;

/// <reference types="react" />
import { CheckoutConfig, CustomerCreate, FormFieldType, RequestError } from '@open-tender/types';
import { CheckoutConfig, CustomerCreate, RequestError } from '@open-tender/types';
export declare const useSignUpForm: (loading: RequestInfo, error: RequestError, signUp: (data: CustomerCreate, callback?: () => void) => void, callback?: () => void, checkConfig?: Partial<CheckoutConfig>, hasThanx?: boolean) => {

@@ -8,6 +8,5 @@ submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;

submitting: boolean;
formfields: FormFieldType[];
errMsg: string | null;
fields: import("@open-tender/types").FormFieldType[];
handleChange: (name: string, value: string | number | boolean) => void;
handleSubmit: (evt?: any) => void;
handleSubmit: (evt: React.FormEvent<HTMLFormElement>) => void;
};

@@ -6,2 +6,3 @@ "use strict";

const utils_1 = require("../utils");
const useProfileForm_1 = require("./useProfileForm");
const initState = {

@@ -14,5 +15,2 @@ first_name: '',

const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}, hasThanx = false) => {
const { displayed, required } = checkConfig || {};
const companyDisplayed = displayed && displayed.customer.includes('company');
const companyRequired = required && required.customer.includes('company');
const submitRef = (0, react_1.useRef)(null);

@@ -22,4 +20,12 @@ const [data, setData] = (0, react_1.useState)(initState);

const [submitting, setSubmitting] = (0, react_1.useState)(false);
const errMsg = error ? 'There are one or more errors below.' : null;
let fields = [
const { displayed, required } = checkConfig || {};
const companyDisplayed = displayed && displayed.customer.includes('company');
const companyRequired = required && required.customer.includes('company');
const showCompany = companyDisplayed || companyRequired;
const toRemove = [];
if (!showCompany)
toRemove.push('company');
if (hasThanx)
toRemove.push('password');
const allFields = [
{

@@ -51,6 +57,4 @@ label: 'First Name',

},
{ label: 'Phone', name: 'phone', type: 'tel', required: true }
];
if (companyDisplayed || companyRequired) {
const company = {
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
{
label: 'Company',

@@ -60,8 +64,7 @@ name: 'company',

required: companyRequired
};
fields = [...fields, company];
}
const formfields = hasThanx
? fields.filter(i => i.name !== 'password')
: fields;
},
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
{ label: 'Gender', name: 'gender', type: 'select', options: useProfileForm_1.genderOptions }
];
const fields = allFields.filter(i => !toRemove.includes(i.name));
(0, react_1.useEffect)(() => {

@@ -82,3 +85,7 @@ return () => {

const handleChange = (name, value) => {
const inputValue = name === 'phone' ? (0, utils_1.makePhone)((value !== null && value !== void 0 ? value : '')) : value;
const inputValue = name === 'phone'
? (0, utils_1.makePhone)((value !== null && value !== void 0 ? value : ''))
: name === 'birth_date'
? (0, utils_1.makeBirthDate)(value)
: value;
setData(Object.assign(Object.assign({}, data), { [name]: inputValue }));

@@ -91,3 +98,7 @@ };

setSubmitting(true);
signUp(data, callback);
const values = Object.assign({}, data);
if (values.birth_date) {
values.birth_date = (0, utils_1.slashesToDashes)(values.birth_date);
}
signUp(values, callback);
((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());

@@ -100,4 +111,3 @@ };

submitting,
formfields,
errMsg,
fields,
handleChange,

@@ -104,0 +114,0 @@ handleSubmit

/// <reference types="react" />
import { Customer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
import { Customer, CustomerCreate, FormFields, Gender, RequestError, RequestStatus } from '@open-tender/types';
export declare const genderOptions: {
name: string;
value: Gender;
}[];
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void) => {

@@ -4,0 +8,0 @@ submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;

import { useRef, useState, useEffect } from 'react';
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
const genderOptions = [
export const genderOptions = [
{ name: 'not specified', value: 'DECLINED' },

@@ -36,4 +36,2 @@ { name: 'Male', value: 'MALE' },

const errs = makeFormErrors(error);
if (errs)
errs.form = 'There are one or more errors below.';
if (errs.birth_date) {

@@ -73,4 +71,2 @@ errs.birth_date = 'Invalid date. Please enter in mm/dd/yyyy format.';

const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
// const rest = { ...data }
// const { customer_id, is_notification_set, is_verified, ...rest } = data
rest.birth_date = data.birth_date ? slashesToDashes(data.birth_date) : null;

@@ -77,0 +73,0 @@ rest.gender = data.gender || null;

/// <reference types="react" />
import { CheckoutConfig, CustomerCreate, FormFieldType, RequestError } from '@open-tender/types';
import { CheckoutConfig, CustomerCreate, RequestError } from '@open-tender/types';
export declare const useSignUpForm: (loading: RequestInfo, error: RequestError, signUp: (data: CustomerCreate, callback?: () => void) => void, callback?: () => void, checkConfig?: Partial<CheckoutConfig>, hasThanx?: boolean) => {

@@ -8,6 +8,5 @@ submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;

submitting: boolean;
formfields: FormFieldType[];
errMsg: string | null;
fields: import("@open-tender/types").FormFieldType[];
handleChange: (name: string, value: string | number | boolean) => void;
handleSubmit: (evt?: any) => void;
handleSubmit: (evt: React.FormEvent<HTMLFormElement>) => void;
};
import { useRef, useState, useEffect } from 'react';
import { makeFormErrors, makePhone } from '../utils';
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
import { genderOptions } from './useProfileForm';
const initState = {

@@ -10,5 +11,2 @@ first_name: '',

export const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}, hasThanx = false) => {
const { displayed, required } = checkConfig || {};
const companyDisplayed = displayed && displayed.customer.includes('company');
const companyRequired = required && required.customer.includes('company');
const submitRef = useRef(null);

@@ -18,4 +16,12 @@ const [data, setData] = useState(initState);

const [submitting, setSubmitting] = useState(false);
const errMsg = error ? 'There are one or more errors below.' : null;
let fields = [
const { displayed, required } = checkConfig || {};
const companyDisplayed = displayed && displayed.customer.includes('company');
const companyRequired = required && required.customer.includes('company');
const showCompany = companyDisplayed || companyRequired;
const toRemove = [];
if (!showCompany)
toRemove.push('company');
if (hasThanx)
toRemove.push('password');
const allFields = [
{

@@ -47,6 +53,4 @@ label: 'First Name',

},
{ label: 'Phone', name: 'phone', type: 'tel', required: true }
];
if (companyDisplayed || companyRequired) {
const company = {
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
{
label: 'Company',

@@ -56,8 +60,7 @@ name: 'company',

required: companyRequired
};
fields = [...fields, company];
}
const formfields = hasThanx
? fields.filter(i => i.name !== 'password')
: fields;
},
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
{ label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
];
const fields = allFields.filter(i => !toRemove.includes(i.name));
useEffect(() => {

@@ -78,3 +81,7 @@ return () => {

const handleChange = (name, value) => {
const inputValue = name === 'phone' ? makePhone((value !== null && value !== void 0 ? value : '')) : value;
const inputValue = name === 'phone'
? makePhone((value !== null && value !== void 0 ? value : ''))
: name === 'birth_date'
? makeBirthDate(value)
: value;
setData(Object.assign(Object.assign({}, data), { [name]: inputValue }));

@@ -87,3 +94,7 @@ };

setSubmitting(true);
signUp(data, callback);
const values = Object.assign({}, data);
if (values.birth_date) {
values.birth_date = slashesToDashes(values.birth_date);
}
signUp(values, callback);
((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());

@@ -96,4 +107,3 @@ };

submitting,
formfields,
errMsg,
fields,
handleChange,

@@ -100,0 +110,0 @@ handleSubmit

{
"name": "@open-tender/utils",
"version": "0.1.31",
"version": "0.1.32",
"description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc