@homefile/components-v2 2.14.16 → 2.14.18
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.
- package/dist/components/forms/dynamicForm/fields/GroupField.js +1 -1
- package/dist/components/forms/dynamicForm/fields/NumberField.js +2 -1
- package/dist/helpers/propertyTiles/MortgageInfo.helper.js +5 -6
- package/dist/stories/propertyTiles/MortgageInfo.stories.js +2 -2
- package/dist/utils/Formaters.utils.d.ts +1 -0
- package/dist/utils/Formaters.utils.js +7 -0
- package/package.json +1 -1
- package/src/components/forms/dynamicForm/fields/GroupField.tsx +1 -1
- package/src/components/forms/dynamicForm/fields/NumberField.tsx +4 -1
- package/src/helpers/propertyTiles/MortgageInfo.helper.ts +5 -6
- package/src/stories/propertyTiles/MortgageInfo.stories.tsx +2 -2
- package/src/utils/Formaters.utils.ts +9 -0
|
@@ -3,5 +3,5 @@ import { Stack } from '@chakra-ui/react';
|
|
|
3
3
|
import { FieldWithDelete } from '../../..';
|
|
4
4
|
import { SingleFields } from './SingleFields';
|
|
5
5
|
export const GroupField = ({ id, fields, onRemove, canBeHidden, }) => {
|
|
6
|
-
return (_jsx(FieldWithDelete, { id: id, onRemove: onRemove, canBeHidden: canBeHidden, children: _jsx(Stack, { spacing: "
|
|
6
|
+
return (_jsx(FieldWithDelete, { id: id, onRemove: onRemove, canBeHidden: canBeHidden, children: _jsx(Stack, { spacing: "base", flex: "1", children: _jsx(SingleFields, { fields: fields }) }) }));
|
|
7
7
|
};
|
|
@@ -4,7 +4,8 @@ import { Flex, Input } from '@chakra-ui/react';
|
|
|
4
4
|
import { FieldDescription, LabeledField } from '../../..';
|
|
5
5
|
export const NumberField = ({ description, icon, id, label, placeholder, value, }) => {
|
|
6
6
|
const { control } = useFormContext();
|
|
7
|
-
|
|
7
|
+
const hasDescriptionAndIcon = Boolean(description) && Boolean(icon);
|
|
8
|
+
return (_jsxs(Flex, { align: "center", gap: "base", flex: "auto", children: [hasDescriptionAndIcon && (_jsx(FieldDescription, { description: description, icon: icon })), _jsx(Controller, { control: control, name: id, defaultValue: value, render: ({ field: { value, onChange } }) => {
|
|
8
9
|
return (_jsx(LabeledField, { label: label, children: _jsx(Input, { onChange: (e) => {
|
|
9
10
|
const value = e.target.valueAsNumber;
|
|
10
11
|
const isNumber = !isNaN(value);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t } from 'i18next';
|
|
2
|
+
import { formatISODate } from '../../utils';
|
|
2
3
|
export const mortgageInfoForm = ({ amount = 0, documentDate = '', maturityDate = '', interestRate = 0, interestRateType = '', estimatedMortgageBalance = 0, estimatedMortgagePayment = 0, lenderName = '', purchasePrice = 0, }) => {
|
|
3
4
|
return [
|
|
4
5
|
{
|
|
@@ -9,11 +10,10 @@ export const mortgageInfoForm = ({ amount = 0, documentDate = '', maturityDate =
|
|
|
9
10
|
visible: true,
|
|
10
11
|
},
|
|
11
12
|
{
|
|
12
|
-
icon: 'price',
|
|
13
13
|
id: 'purchase-price',
|
|
14
14
|
name: t('propertyTiles.placeholders.purchasePrice'),
|
|
15
15
|
value: purchasePrice,
|
|
16
|
-
type: '
|
|
16
|
+
type: 'currency',
|
|
17
17
|
visible: true,
|
|
18
18
|
},
|
|
19
19
|
{
|
|
@@ -27,9 +27,8 @@ export const mortgageInfoForm = ({ amount = 0, documentDate = '', maturityDate =
|
|
|
27
27
|
id: 'group-1-loan',
|
|
28
28
|
name: t('propertyTiles.placeholders.loan'),
|
|
29
29
|
value: amount,
|
|
30
|
-
type: '
|
|
30
|
+
type: 'currency',
|
|
31
31
|
visible: true,
|
|
32
|
-
icon: 'billing',
|
|
33
32
|
},
|
|
34
33
|
{
|
|
35
34
|
id: 'group-1-grid',
|
|
@@ -38,7 +37,7 @@ export const mortgageInfoForm = ({ amount = 0, documentDate = '', maturityDate =
|
|
|
38
37
|
children: [
|
|
39
38
|
{
|
|
40
39
|
id: 'group-1-grid-origination',
|
|
41
|
-
value: documentDate,
|
|
40
|
+
value: formatISODate(documentDate),
|
|
42
41
|
description: t('propertyTiles.placeholders.origination'),
|
|
43
42
|
type: 'date',
|
|
44
43
|
visible: true,
|
|
@@ -79,7 +78,7 @@ export const mortgageInfoForm = ({ amount = 0, documentDate = '', maturityDate =
|
|
|
79
78
|
{
|
|
80
79
|
id: 'payment-grid-maturity-date',
|
|
81
80
|
description: t('propertyTiles.placeholders.maturityDate'),
|
|
82
|
-
value: maturityDate,
|
|
81
|
+
value: formatISODate(maturityDate),
|
|
83
82
|
type: 'date',
|
|
84
83
|
visible: true,
|
|
85
84
|
},
|
|
@@ -9,8 +9,8 @@ export default {
|
|
|
9
9
|
onCheckChange: action('onCheckChange'),
|
|
10
10
|
form: {
|
|
11
11
|
amount: 0,
|
|
12
|
-
maturityDate: '',
|
|
13
|
-
documentDate: '',
|
|
12
|
+
maturityDate: '2025-04-17T00:00:00.000Z',
|
|
13
|
+
documentDate: '2017-04-17T00:00:00.000Z',
|
|
14
14
|
estimatedMortgageBalance: 0,
|
|
15
15
|
estimatedMortgagePayment: 0,
|
|
16
16
|
interestRate: 0,
|
|
@@ -24,6 +24,7 @@ interface FormatCurrencyI {
|
|
|
24
24
|
currrency?: string;
|
|
25
25
|
value: string | number;
|
|
26
26
|
}
|
|
27
|
+
export declare const formatISODate: (value: string) => string;
|
|
27
28
|
export declare const formatCurrency: ({ country, currrency, value, }: FormatCurrencyI) => string;
|
|
28
29
|
export declare const formatCurrencyWithoutDigits: ({ country, currrency, value, }: FormatCurrencyI) => string;
|
|
29
30
|
export declare const formatNumber: (value: string | number) => string | 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { format, isValid, parseISO } from 'date-fns';
|
|
1
2
|
export const formatDate = ({ date, locale = 'en-US' }) => {
|
|
2
3
|
const timeFormat = new Intl.DateTimeFormat(locale, {
|
|
3
4
|
timeStyle: 'short',
|
|
@@ -90,6 +91,12 @@ export const joinDayMonthYear = (value) => {
|
|
|
90
91
|
year: 'numeric',
|
|
91
92
|
});
|
|
92
93
|
};
|
|
94
|
+
export const formatISODate = (value) => {
|
|
95
|
+
const displayValue = isValid(parseISO(value))
|
|
96
|
+
? format(value, 'MM/dd/yyyy')
|
|
97
|
+
: '';
|
|
98
|
+
return displayValue;
|
|
99
|
+
};
|
|
93
100
|
export const formatCurrency = ({ country = 'en-US', currrency = 'USD', value, }) => {
|
|
94
101
|
if (!value) {
|
|
95
102
|
return Number(0).toLocaleString(country, {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ export const GroupField = ({
|
|
|
11
11
|
}: GroupFieldI) => {
|
|
12
12
|
return (
|
|
13
13
|
<FieldWithDelete id={id} onRemove={onRemove} canBeHidden={canBeHidden}>
|
|
14
|
-
<Stack spacing="
|
|
14
|
+
<Stack spacing="base" flex="1">
|
|
15
15
|
<SingleFields fields={fields} />
|
|
16
16
|
</Stack>
|
|
17
17
|
</FieldWithDelete>
|
|
@@ -12,9 +12,12 @@ export const NumberField = ({
|
|
|
12
12
|
value,
|
|
13
13
|
}: TextFieldI) => {
|
|
14
14
|
const { control } = useFormContext()
|
|
15
|
+
const hasDescriptionAndIcon = Boolean(description) && Boolean(icon)
|
|
15
16
|
return (
|
|
16
17
|
<Flex align="center" gap="base" flex="auto">
|
|
17
|
-
|
|
18
|
+
{hasDescriptionAndIcon && (
|
|
19
|
+
<FieldDescription description={description} icon={icon} />
|
|
20
|
+
)}
|
|
18
21
|
<Controller
|
|
19
22
|
control={control}
|
|
20
23
|
name={id}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t } from 'i18next'
|
|
2
2
|
import { MortgageInfoI, ReportI } from '@/interfaces'
|
|
3
|
+
import { formatISODate } from '@/utils'
|
|
3
4
|
|
|
4
5
|
export const mortgageInfoForm = ({
|
|
5
6
|
amount = 0,
|
|
@@ -21,11 +22,10 @@ export const mortgageInfoForm = ({
|
|
|
21
22
|
visible: true,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
|
-
icon: 'price',
|
|
25
25
|
id: 'purchase-price',
|
|
26
26
|
name: t('propertyTiles.placeholders.purchasePrice'),
|
|
27
27
|
value: purchasePrice,
|
|
28
|
-
type: '
|
|
28
|
+
type: 'currency',
|
|
29
29
|
visible: true,
|
|
30
30
|
},
|
|
31
31
|
{
|
|
@@ -39,9 +39,8 @@ export const mortgageInfoForm = ({
|
|
|
39
39
|
id: 'group-1-loan',
|
|
40
40
|
name: t('propertyTiles.placeholders.loan'),
|
|
41
41
|
value: amount,
|
|
42
|
-
type: '
|
|
42
|
+
type: 'currency',
|
|
43
43
|
visible: true,
|
|
44
|
-
icon: 'billing',
|
|
45
44
|
},
|
|
46
45
|
{
|
|
47
46
|
id: 'group-1-grid',
|
|
@@ -50,7 +49,7 @@ export const mortgageInfoForm = ({
|
|
|
50
49
|
children: [
|
|
51
50
|
{
|
|
52
51
|
id: 'group-1-grid-origination',
|
|
53
|
-
value: documentDate,
|
|
52
|
+
value: formatISODate(documentDate),
|
|
54
53
|
description: t('propertyTiles.placeholders.origination'),
|
|
55
54
|
type: 'date',
|
|
56
55
|
visible: true,
|
|
@@ -91,7 +90,7 @@ export const mortgageInfoForm = ({
|
|
|
91
90
|
{
|
|
92
91
|
id: 'payment-grid-maturity-date',
|
|
93
92
|
description: t('propertyTiles.placeholders.maturityDate'),
|
|
94
|
-
value: maturityDate,
|
|
93
|
+
value: formatISODate(maturityDate),
|
|
95
94
|
type: 'date',
|
|
96
95
|
visible: true,
|
|
97
96
|
},
|
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
onCheckChange: action('onCheckChange'),
|
|
12
12
|
form: {
|
|
13
13
|
amount: 0,
|
|
14
|
-
maturityDate: '',
|
|
15
|
-
documentDate: '',
|
|
14
|
+
maturityDate: '2025-04-17T00:00:00.000Z',
|
|
15
|
+
documentDate: '2017-04-17T00:00:00.000Z',
|
|
16
16
|
estimatedMortgageBalance: 0,
|
|
17
17
|
estimatedMortgagePayment: 0,
|
|
18
18
|
interestRate: 0,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DayValue } from 'react-modern-calendar-datepicker'
|
|
2
|
+
import { format, isValid, parseISO } from 'date-fns'
|
|
2
3
|
|
|
3
4
|
interface FormatDateI {
|
|
4
5
|
date: Date | string
|
|
@@ -134,6 +135,14 @@ interface FormatCurrencyI {
|
|
|
134
135
|
value: string | number
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
export const formatISODate = (value: string) => {
|
|
139
|
+
const displayValue = isValid(parseISO(value))
|
|
140
|
+
? format(value, 'MM/dd/yyyy')
|
|
141
|
+
: ''
|
|
142
|
+
|
|
143
|
+
return displayValue
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
export const formatCurrency = ({
|
|
138
147
|
country = 'en-US',
|
|
139
148
|
currrency = 'USD',
|