blob: 2f94a6eacde8a91433417488061029d0d2d6e9f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
"use client";
import React, { createContext, useState, useContext } from "react";
interface PendingJobContextType {
pendingJobs: number;
setPendingJobs: (pendingJobs: number) => void;
}
const PendingJobContext = createContext<PendingJobContextType | undefined>(
undefined,
);
export const PendingJobProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [pendingJobs, setPendingJobs] = useState(0);
return (
<PendingJobContext.Provider value={{ pendingJobs, setPendingJobs }}>
{children}
</PendingJobContext.Provider>
);
};
export const usePendingJob = () => {
const context = useContext(PendingJobContext);
if (context === undefined) {
throw new Error("usePendingJob must be used within a PendingJobProvider");
}
return context;
};
|