@open-tender/utils 0.1.33 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,13 @@ const useProfileForm = (profile, loading, error, update
29
29
  { label: 'Phone', name: 'phone', type: 'tel', required: true },
30
30
  { label: 'Company', name: 'company', type: 'text' },
31
31
  { label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
32
- { label: 'Gender', name: 'gender', type: 'select', options: exports.genderOptions }
32
+ {
33
+ label: 'Gender',
34
+ name: 'gender',
35
+ type: 'select',
36
+ showLabel: true,
37
+ options: exports.genderOptions
38
+ }
33
39
  ];
34
40
  (0, react_1.useEffect)(() => {
35
41
  if (loading === 'idle') {
@@ -67,6 +73,7 @@ const useProfileForm = (profile, loading, error, update
67
73
  evt.preventDefault();
68
74
  if (!data)
69
75
  return;
76
+ setErrors({});
70
77
  setSubmitting(true);
71
78
  // remove read-only properties
72
79
  const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
@@ -59,9 +59,16 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}, hasTh
59
59
  required: companyRequired
60
60
  },
61
61
  { label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
62
- { label: 'Gender', name: 'gender', type: 'select', options: useProfileForm_1.genderOptions }
62
+ {
63
+ label: 'Gender',
64
+ name: 'gender',
65
+ type: 'select',
66
+ showLabel: true,
67
+ options: useProfileForm_1.genderOptions
68
+ }
63
69
  ];
64
70
  const fields = allFields.filter(i => !toRemove.includes(i.name));
71
+ console.log(data);
65
72
  (0, react_1.useEffect)(() => {
66
73
  return () => {
67
74
  setData(initState);
@@ -74,6 +81,9 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}, hasTh
74
81
  if (error) {
75
82
  setErrors((0, utils_1.makeFormErrors)(error));
76
83
  }
84
+ else {
85
+ setErrors({});
86
+ }
77
87
  }
78
88
  }, [loading, error]);
79
89
  const handleChange = (name, value) => {
@@ -89,11 +99,13 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}, hasTh
89
99
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
90
100
  setErrors({});
91
101
  setSubmitting(true);
92
- const values = Object.assign({}, data);
93
- if (values.birth_date) {
94
- values.birth_date = (0, utils_1.slashesToDashes)(values.birth_date);
95
- }
96
- signUp(values, callback);
102
+ console.log('handleSubmit data', data);
103
+ // const values = { ...data }
104
+ // if (values.birth_date) {
105
+ // values.birth_date = slashesToDashes(values.birth_date)
106
+ // }
107
+ // console.log('handleSubmit values', values)
108
+ signUp(data, callback);
97
109
  ((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());
98
110
  };
99
111
  return {
@@ -26,7 +26,13 @@ export const useProfileForm = (profile, loading, error, update
26
26
  { label: 'Phone', name: 'phone', type: 'tel', required: true },
27
27
  { label: 'Company', name: 'company', type: 'text' },
28
28
  { label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
29
- { label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
29
+ {
30
+ label: 'Gender',
31
+ name: 'gender',
32
+ type: 'select',
33
+ showLabel: true,
34
+ options: genderOptions
35
+ }
30
36
  ];
31
37
  useEffect(() => {
32
38
  if (loading === 'idle') {
@@ -64,6 +70,7 @@ export const useProfileForm = (profile, loading, error, update
64
70
  evt.preventDefault();
65
71
  if (!data)
66
72
  return;
73
+ setErrors({});
67
74
  setSubmitting(true);
68
75
  // remove read-only properties
69
76
  const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
@@ -1,5 +1,7 @@
1
1
  import { useRef, useState, useEffect } from 'react';
2
- import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
2
+ import { makeBirthDate, makeFormErrors, makePhone
3
+ // slashesToDashes
4
+ } from '../utils';
3
5
  import { genderOptions } from './useProfileForm';
4
6
  const initState = {
5
7
  first_name: '',
@@ -56,9 +58,16 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}
56
58
  required: companyRequired
57
59
  },
58
60
  { label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
59
- { label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
61
+ {
62
+ label: 'Gender',
63
+ name: 'gender',
64
+ type: 'select',
65
+ showLabel: true,
66
+ options: genderOptions
67
+ }
60
68
  ];
61
69
  const fields = allFields.filter(i => !toRemove.includes(i.name));
70
+ console.log(data);
62
71
  useEffect(() => {
63
72
  return () => {
64
73
  setData(initState);
@@ -71,6 +80,9 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}
71
80
  if (error) {
72
81
  setErrors(makeFormErrors(error));
73
82
  }
83
+ else {
84
+ setErrors({});
85
+ }
74
86
  }
75
87
  }, [loading, error]);
76
88
  const handleChange = (name, value) => {
@@ -86,11 +98,13 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig = {}
86
98
  evt === null || evt === void 0 ? void 0 : evt.preventDefault();
87
99
  setErrors({});
88
100
  setSubmitting(true);
89
- const values = Object.assign({}, data);
90
- if (values.birth_date) {
91
- values.birth_date = slashesToDashes(values.birth_date);
92
- }
93
- signUp(values, callback);
101
+ console.log('handleSubmit data', data);
102
+ // const values = { ...data }
103
+ // if (values.birth_date) {
104
+ // values.birth_date = slashesToDashes(values.birth_date)
105
+ // }
106
+ // console.log('handleSubmit values', values)
107
+ signUp(data, callback);
94
108
  ((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());
95
109
  };
96
110
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",