All checks were successful
forgejo/romanjaros/portfolio/pipeline/head This commit looks good
25 lines
No EOL
634 B
TypeScript
25 lines
No EOL
634 B
TypeScript
"use client"
|
|
|
|
import {createContext, ReactNode, FC, useState, Dispatch, SetStateAction} from "react";
|
|
import {Job} from "../type";
|
|
|
|
type JobsContextPayload = {
|
|
data: Job[]
|
|
filter?: string
|
|
setFilter: Dispatch<SetStateAction<string | undefined>>
|
|
} | undefined
|
|
|
|
export const JobsContext = createContext<JobsContextPayload>(undefined);
|
|
|
|
type JobsContextProviderProps = {
|
|
jobs: Job[]
|
|
children: ReactNode[]
|
|
}
|
|
|
|
export const JobsProvider: FC<JobsContextProviderProps> = ({children, jobs: data}) => {
|
|
const [filter, setFilter] = useState<string>()
|
|
|
|
return (
|
|
<JobsContext value={{data, filter, setFilter}}>{children}</JobsContext>
|
|
)
|
|
} |