Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PF-323 research and functionality for disabling dates on date field wix #207

Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"axios": "^0.25.0",
"boomform": "^3.6.7",
"classnames": "^2.3.1",
"dayjs": "^1.11.13",
"react-google-recaptcha": "^2.1.0",
"react-grid-layout": "^1.4.2",
"react-quill": "^2.0.0",
Expand Down
16 changes: 13 additions & 3 deletions src/Body/Fields/Date/Date.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import React from 'react'
import { Input } from 'boomform'
import { iphoneCheck } from '../../../Helpers/global'
import dayjs from 'dayjs'

const Date = ({ validation = {}, payment, ...props }) => {
const { min, max } = validation
if (min || max) {
const { min, max, hideDays, disableDates, hiddenCustomDays, isCustom } =
validation
if (min || max || disableDates) {
validation = {
...validation,
custom: (value) => {
custom: value => {
if (value) {
const dayName = dayjs(value).format('dddd')
const customDay = dayjs(value).format('MMM D, YYYY')
if (min?.value > value) return min?.msg
if (max?.value < value) return max?.msg
if (disableDates && hideDays[dayName] && !isCustom) {
return `${dayName}s are disabled. Please pick another date. `
}
if (disableDates && hiddenCustomDays.includes(value) && isCustom) {
return `${customDay} is disabled. Please pick another date.`
}
}
return false
}
Expand Down
Loading