npm-pkg-hook 1.6.1 → 1.6.3

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/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "rm": "rm -rf node_modules package-lock.json && npm i",
44
44
  "test": "echo \"Error: no test specified\" && exit 1"
45
45
  },
46
- "version": "1.6.1"
46
+ "version": "1.6.3"
47
47
  }
@@ -9,16 +9,33 @@ const CREATE_DELIVERY_TIME = gql`
9
9
  }
10
10
  `
11
11
 
12
- export const useCreateDeliveryTime = () => {
13
- const [createDeliveryTimeMutation, { loading, error }] = useMutation(CREATE_DELIVERY_TIME)
12
+ export const useCreateDeliveryTime = ({
13
+ sendNotification = ({ description, title, backgroundColor }) => {
14
+ return { description, title, backgroundColor }
15
+ }
16
+ }) => {
17
+ const [createDeliveryTimeMutation, { loading, error }] =
18
+ useMutation(CREATE_DELIVERY_TIME)
14
19
 
15
20
  const createDeliveryTime = async (minutes) => {
16
21
  try {
17
- const { data } = await createDeliveryTimeMutation({ variables: { minutes } })
22
+ const { data } = await createDeliveryTimeMutation({
23
+ variables: { minutes: parseInt(minutes) }
24
+ })
25
+ if (data?.createDeliveryTime?.success) {
26
+ sendNotification({
27
+ title: 'Delivery Time Created',
28
+ description: data.createDeliveryTime.message,
29
+ backgroundColor: 'success'
30
+ })
31
+ }
18
32
  return data.createDeliveryTime
19
33
  } catch (error) {
20
- console.error('Error creating delivery time:', error)
21
- return { success: false, message: 'An error occurred while creating delivery time' }
34
+ sendNotification({
35
+ backgroundColor: 'error',
36
+ title: 'Error',
37
+ description: 'An error occurred while creating the delivery time.'
38
+ })
22
39
  }
23
40
  }
24
41
 
@@ -1,14 +1,20 @@
1
- import { useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
2
 
3
3
  /**
4
4
  * Custom hook to handle delivery time input validation and formatting.
5
5
  * @returns {Object} An object containing state and functions for handling delivery time.
6
6
  */
7
- export const useDeliveryTime = ({ initialTime = 0 }) => {
8
- const [deliveryTime, setDeliveryTime] = useState(initialTime || 0)
7
+ export const useDeliveryTime = ({ initialTime = '' }) => {
8
+ const [deliveryTime, setDeliveryTime] = useState(initialTime)
9
+ useEffect(() => {
10
+ if (initialTime) {
11
+ setDeliveryTime(initialTime)
12
+ }
13
+ }, [initialTime])
14
+
9
15
  /**
10
16
  * Handles changes to the delivery time input.
11
- * @param {Number} value - The input change value.
17
+ * @param {String} value - The input change value.
12
18
  */
13
19
  const handleDeliveryTimeChange = (value) => {
14
20
  setDeliveryTime(value)
@@ -18,6 +18,7 @@ export const GET_ALL_FAV_STORE = gql`
18
18
  schHoEnd
19
19
  schState
20
20
  }
21
+ deliveryTimeMinutes
21
22
  scheduleOpenAll
22
23
  idStore
23
24
  cId