npm-pkg-hook 1.6.8 → 1.6.9

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
@@ -44,5 +44,5 @@
44
44
  "rm": "rm -rf node_modules package-lock.json && npm i",
45
45
  "test": "echo \"Error: no test specified\" && exit 1"
46
46
  },
47
- "version": "1.6.8"
47
+ "version": "1.6.9"
48
48
  }
@@ -0,0 +1,22 @@
1
+ export const completeSchedules = (dataSchedules) => {
2
+ // Días de la semana
3
+ const daysSemana = ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo']
4
+
5
+ // Mapear los horarios existentes para crear un mapa por día
6
+ const horariosPorDia = dataSchedules.reduce((mapa, horario) => {
7
+ const day = daysSemana[horario.schDay]
8
+ if (!mapa[day]) {
9
+ mapa[day] = []
10
+ }
11
+ mapa[day].push({ horaInicio: horario.schHoSta, horaFin: horario.schHoEnd })
12
+ return mapa
13
+ }, {})
14
+
15
+ // Completar los días que faltan y formatear el objeto
16
+ const horariosFormateados = daysSemana.map((day, index) => ({
17
+ day,
18
+ horarios: horariosPorDia[day] || [{ horaInicio: '', horaFin: '' }]
19
+ }))
20
+
21
+ return horariosFormateados
22
+ }
@@ -7,6 +7,7 @@ export * from './useCatWithProduct'
7
7
  export * from './useManageQueryParams'
8
8
  export * from './useDeliveryTime'
9
9
  export * from './statusOpenStores'
10
+ export * from './completeSchedules'
10
11
  export * from './useLogout/helpers/BroadcastChannel'
11
12
  export * from './newMessageSubscription'
12
13
  export * from './isTokenExpired'
@@ -19,15 +19,16 @@ export const useSchedule = ({ day = null, idStore = '' }) => {
19
19
  export const useSetScheduleOpenAll = () => {
20
20
  const [setStoreSchedule, { loading, error }] = useMutation(SET_STATUS_ALL_SCHEDULE_STORE, {
21
21
  onError: (e) => {
22
- console.error(e);
22
+ console.error(e)
23
23
  }
24
- });
24
+ })
25
25
 
26
26
  const handleSetStoreSchedule = (scheduleOpenAll) => {
27
27
  setStoreSchedule({
28
28
  variables: {
29
- scheduleOpenAll: scheduleOpenAll
30
- }, update: (cache, { data }) => {
29
+ scheduleOpenAll
30
+ },
31
+ update: (cache, { data }) => {
31
32
  const success = data?.setScheduleOpenAll?.success
32
33
  if (success) {
33
34
  cache.modify({
@@ -36,20 +37,19 @@ export const useSetScheduleOpenAll = () => {
36
37
  const store = readField('getStore')
37
38
  const updatedCart = {
38
39
  ...store,
39
- scheduleOpenAll: scheduleOpenAll
40
- }
41
- return updatedCart
40
+ scheduleOpenAll
41
+ }
42
+ return updatedCart
42
43
  }
43
44
  }
44
45
  })
45
46
  }
46
47
  }
47
- });
48
- };
49
-
50
- return [handleSetStoreSchedule, { loading, error }];
51
- };
48
+ })
49
+ }
52
50
 
51
+ return [handleSetStoreSchedule, { loading, error }]
52
+ }
53
53
 
54
54
  export const useSchedules = ({ schDay = 1, idStore = '' }) => {
55
55
  const {
@@ -16,8 +16,7 @@ export const useSchedules = ({ schDay = 1, idStore = '' }) => {
16
16
  data,
17
17
  loading,
18
18
  error
19
- } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay: schDay, idStore } })
20
-
19
+ } = useQuery(GET_SCHEDULE_STORE, { variables: { schDay, idStore } })
21
20
 
22
21
  return [data?.getStoreSchedules, { loading, error }]
23
- }
22
+ }
@@ -42,7 +42,7 @@ export function useScheduleData (data) {
42
42
  * Calcula la duración en horas entre dos horas de inicio y final.
43
43
  * @param {string} startTime - Hora de inicio en formato 'HH:mm'.
44
44
  * @param {string} endTime - Hora de fin en formato 'HH:mm'.
45
- * @returns {number} Duración en horas con dos decimales.
45
+ * @returns {number|string} Duración en horas con dos decimales.
46
46
  */
47
47
 
48
48
  // Función para calcular la duración en horas de un horario