Skip to content
Merged

Dev #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
var t = localStorage.getItem('theme');
if (t === 'dark') document.documentElement.classList.add('dark');
} catch (e) {}
})();</script><link rel="icon" type="image/png" href="/logoBrowser.png"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=DM+Sans:opsz,wght@9..40,400;9..40,600&family=Public+Sans:wght@400;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"><script defer="defer" src="/js/runtime.9f8278dc.js"></script><script defer="defer" src="/js/vendor-react.dbd9c2ef.js"></script><script defer="defer" src="/js/vendor-redux.2aa40dea.js"></script><script defer="defer" src="/js/vendors.eafec659.js"></script><script defer="defer" src="/js/main.42a5ec8a.js"></script></head><body><div id="root"></div></body></html>
})();</script><link rel="icon" type="image/png" href="/logoBrowser.png"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=DM+Sans:opsz,wght@9..40,400;9..40,600&family=Public+Sans:wght@400;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet"><script defer="defer" src="/js/runtime.b75a4144.js"></script><script defer="defer" src="/js/vendor-react.dbd9c2ef.js"></script><script defer="defer" src="/js/vendor-redux.2aa40dea.js"></script><script defer="defer" src="/js/vendors.eafec659.js"></script><script defer="defer" src="/js/main.42a5ec8a.js"></script></head><body><div id="root"></div></body></html>

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/js/1393.08461c74.chunk.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/js/1393.6082f12c.chunk.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions dist/js/6284.275f700f.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/js/6284.275f700f.chunk.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions dist/js/6284.9007407f.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/js/6284.9007407f.chunk.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/js/runtime.9f8278dc.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/js/runtime.b75a4144.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

31 changes: 28 additions & 3 deletions src/components/mortgage/ApplicationFormSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ const ApplicationFormSection = memo(() => {
const [errors, setErrors] = useState({});
const [submitting, setSubmitting] = useState(false);

const sanitizeDecimalInput = useCallback((value) => {
const text = String(value);
const [wholePart, ...decimalParts] = text.replace(/[^\d.]/g, '').split('.');
if (decimalParts.length === 0) return wholePart;
return `${wholePart}.${decimalParts.join('').replace(/\./g, '')}`;
}, []);

const getCalculatorPayload = useCallback(() => {
const drafts = getAllMortgageApplicationDrafts();
const activeDraft = getMortgageApplicationDraft();
Expand All @@ -67,12 +74,19 @@ const ApplicationFormSection = memo(() => {

const handleChange = useCallback((e) => {
const { name, value, type, checked } = e.target;
const nextValue =
name === 'phone' || name === 'annualIncome'
? value.replace(/\D/g, '')
: name === 'desiredLoanAmount'
? sanitizeDecimalInput(value)
: value;

setForm((prev) => ({
...prev,
[name]: type === 'checkbox' ? checked : value,
[name]: type === 'checkbox' ? checked : nextValue,
}));
setErrors((prev) => ({ ...prev, [name]: '' }));
}, []);
}, [sanitizeDecimalInput]);

const isNumericValue = useCallback((value) => {
const text = String(value).trim();
Expand All @@ -89,7 +103,12 @@ const ApplicationFormSection = memo(() => {
errs.email = 'Please enter a valid email address.';
}
if (!form.phone.trim()) errs.phone = 'Phone number is required.';
if (form.desiredLoanAmount.trim() && !isNumericValue(form.desiredLoanAmount)) {
if (form.annualIncome.trim() && !isNumericValue(form.annualIncome)) {
errs.annualIncome = 'Please enter a valid annual income.';
}
if (!form.desiredLoanAmount.trim()) {
errs.desiredLoanAmount = 'Desired Loan Amount is required.';
} else if (!isNumericValue(form.desiredLoanAmount)) {
errs.desiredLoanAmount = 'Please enter a number in Desired Loan Amount.';
}
if (!form.agreeToTerms)
Expand Down Expand Up @@ -252,10 +271,13 @@ const ApplicationFormSection = memo(() => {
id='af-income'
name='annualIncome'
type='text'
inputMode='numeric'
pattern='[0-9]*'
value={form.annualIncome}
onChange={handleChange}
placeholder='Enter your annual income'
className={formInputClass}
aria-invalid={Boolean(errors.annualIncome)}
/>
</InputField>
</div>
Expand All @@ -274,17 +296,20 @@ const ApplicationFormSection = memo(() => {
</InputField>
<InputField
label='Desired Loan Amount'
required
id='af-loan-amt'
error={errors.desiredLoanAmount}
>
<input
id='af-loan-amt'
name='desiredLoanAmount'
type='text'

value={form.desiredLoanAmount}
onChange={handleChange}
placeholder='Enter your desired loan amount'
inputMode='decimal'
pattern='[0-9]*[.]?[0-9]*'
aria-invalid={Boolean(errors.desiredLoanAmount)}
className={formInputClass}
/>
Expand Down
9 changes: 7 additions & 2 deletions src/components/new-construction/ProjectsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ const ProjectModal = memo(({ project, onClose }) => {

const handleFieldChange = useCallback((e) => {
const { name, value } = e.target;
setForm((prev) => ({ ...prev, [name]: value }));
setForm((prev) => ({
...prev,
[name]: name === 'phone' ? value.replace(/\D/g, '') : value,
}));
}, []);

const handleBookSubmit = useCallback(
Expand Down Expand Up @@ -472,7 +475,9 @@ const ProjectModal = memo(({ project, onClose }) => {
<input
id='book-phone'
name='phone'
type='tel'
type='text'
inputMode='numeric'
pattern='[0-9]*'
value={form.phone}
onChange={handleFieldChange}
placeholder='Enter your phone number'
Expand Down
Loading