bfg-common 1.4.263 → 1.4.265

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.
@@ -35,6 +35,7 @@
35
35
  import type { UI_I_Localization } from '~/lib/models/interfaces'
36
36
  import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
37
37
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
38
+ import { validateDate } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/utils'
38
39
  import { frequencyEndTimeFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/end/lib/config/endOptions'
39
40
 
40
41
  const modelFrequencyLocal = defineModel<UI_I_ScheduleNewTasksForm>({
@@ -51,9 +52,10 @@ const frequencyEndTimeOptions = computed<UI_I_SelectInputItem[]>(() =>
51
52
  const selectedFrequencyEndMode = ref<'never' | 'on'>('never')
52
53
 
53
54
  const schedulerEndDateErrorText = computed<string>(() => {
54
- return !modelFrequencyLocal.value.frg_end_time
55
+ const { frg_end_time, frg_start_on_time } = modelFrequencyLocal.value
56
+ return !frg_end_time
55
57
  ? localization.value.common.fieldRequired
56
- : ''
58
+ : validateDate(localization.value, frg_end_time, frg_start_on_time)
57
59
  })
58
60
  watch(
59
61
  [schedulerEndDateErrorText, selectedFrequencyEndMode],
@@ -1,4 +1,4 @@
1
- import { isBefore, parseISO, startOfDay, subMinutes } from 'date-fns'
1
+ import { isBefore, parseISO, subMinutes } from 'date-fns'
2
2
  import type {
3
3
  UI_I_Localization,
4
4
  UI_I_ArbitraryObject,
@@ -87,12 +87,16 @@ export const validateField = (
87
87
  export const validateDate = (
88
88
  localization: UI_I_Localization,
89
89
  date: string,
90
- _predefinedDate?: string
90
+ predefinedDate?: string
91
91
  ): string => {
92
- const currentDateTime = startOfDay(new Date())
93
- const selectedDate = subMinutes(parseISO(date), 4) // Начало дня выбранной даты theValueLargeThanStartTime
92
+ const currentDateTime = new Date()
93
+ const thresholdDate = subMinutes(currentDateTime, 4) // Используем date-fns для вычитания 4 минут
94
94
 
95
- return isBefore(selectedDate, currentDateTime)
95
+ console.log(predefinedDate, 'ssskddjkllalaksjdjkd')
96
+
97
+ const selectedDate = parseISO(date) // Начало дня выбранной даты theValueLargeThanStartTime
98
+
99
+ return isBefore(selectedDate, thresholdDate)
96
100
  ? localization.common.theValueTooSmall
97
101
  : ''
98
102
  }
@@ -24,8 +24,10 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts" setup>
27
+ import { format } from 'date-fns'
27
28
  import type { UI_I_Localization } from '~/lib/models/interfaces'
28
29
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
30
+ import { validateDate } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/utils'
29
31
 
30
32
  const modelFrequencyLocal = defineModel<UI_I_ScheduleNewTasksForm>({
31
33
  required: true,
@@ -37,7 +39,10 @@ const localization = computed<UI_I_Localization>(() => useLocal())
37
39
  const schedulerStartOnErrorText = computed<string>(() => {
38
40
  return !modelFrequencyLocal.value.frg_start_on_time
39
41
  ? localization.value.common.fieldRequired
40
- : ''
42
+ : validateDate(
43
+ localization.value,
44
+ modelFrequencyLocal.value.frg_start_on_time
45
+ )
41
46
  })
42
47
  watch(
43
48
  schedulerStartOnErrorText,
@@ -47,19 +52,16 @@ watch(
47
52
  { immediate: true }
48
53
  )
49
54
 
50
- // const onUpdateDateTo = (val: number): void => {
51
- // if (!val) return
52
- //
53
- // modelTimeLocal.value = val // milliseconds
54
- //
55
- // currentDateLocal.value = $formattedDate(new Date(val), 'MM.dd.yyyy, hh:mm')
56
- // }
57
- //
58
- // watch(currentDateLocal, (newValue) => {
59
- // $isDate(newValue) &&
60
- // (calendarDefaultDate.value = modelTimeLocal.value =
61
- // $getUnixByDate(newValue))
62
- // })
55
+ onMounted(() => {
56
+ setDefaultDateTime()
57
+ })
58
+ const setDefaultDateTime = () => {
59
+ const currentDateTime = new Date()
60
+ modelFrequencyLocal.value.frg_start_on_time = format(
61
+ currentDateTime,
62
+ "yyyy-MM-dd'T'HH:mm"
63
+ )
64
+ }
63
65
  </script>
64
66
 
65
67
  <style lang="scss" scoped>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.263",
4
+ "version": "1.4.265",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",