Skip to content

Commit

Permalink
Merge pull request #207 from BoomTech-LLC/PF-323-research-and-functio…
Browse files Browse the repository at this point in the history
…nality-for-disabling-dates-on-date-field-wix

PF-323 research and functionality for disabling dates on date field wix
  • Loading branch information
Tigran0199 authored Oct 27, 2024
2 parents 3f6813c + 7949236 commit 728fee6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 728fee6

Please sign in to comment.