npm-pkg-hook 1.6.0 → 1.6.2
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
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* @returns {string} A string indicating the original number and the result of adding 10 minutes.
|
|
5
5
|
*/
|
|
6
6
|
export const addTenMinutes = (num) => {
|
|
7
|
+
if (num > 60) return ''
|
|
7
8
|
if (num >= 50) {
|
|
8
|
-
|
|
9
|
+
const newNum = num - 10
|
|
10
|
+
return `${newNum} - ${60} min`
|
|
9
11
|
} else {
|
|
10
12
|
return `${num} - ${num + 10} min`
|
|
11
13
|
}
|
|
@@ -9,16 +9,33 @@ const CREATE_DELIVERY_TIME = gql`
|
|
|
9
9
|
}
|
|
10
10
|
`
|
|
11
11
|
|
|
12
|
-
export const useCreateDeliveryTime = (
|
|
13
|
-
|
|
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({
|
|
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
|
-
|
|
21
|
-
|
|
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,11 +1,17 @@
|
|
|
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 = () => {
|
|
8
|
-
const [deliveryTime, setDeliveryTime] = useState(
|
|
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
17
|
* @param {String} value - The input change value.
|