laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
36 lines (35 loc) • 838 B
JavaScript
"use client";
import { jsx as i } from "react/jsx-runtime";
import u from "../../../_virtual/dayjs.min.js";
import { useState as t, useEffect as c, createContext as m, useContext as C } from "react";
const r = m(
void 0
), x = () => {
const e = C(r);
if (!e)
throw new Error("useCalendar must be used within a CalendarProvider");
return e;
}, I = ({ children: e, value: n }) => {
const [o, s] = t(null), [a, l] = t(null);
return c(() => {
const d = setInterval(() => {
l(u().format("HH:mm"));
}, 1e3);
return () => clearInterval(d);
}, []), /* @__PURE__ */ i(
r.Provider,
{
value: {
...n,
selectedAppointmentId: o,
setSelectedAppointmentId: s,
currentTime: a
},
children: e
}
);
};
export {
I as CalendarProvider,
x as useCalendar
};