mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-02-04 04:30:07 +00:00
feat: refactor overview button
This commit is contained in:
10
src/context/filter-context.ts
Normal file
10
src/context/filter-context.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export interface FilterContextType {
|
||||
filter: boolean;
|
||||
setFilter: (filter: boolean) => void;
|
||||
}
|
||||
|
||||
export const FilterContext = createContext<FilterContextType | undefined>(
|
||||
undefined,
|
||||
);
|
||||
14
src/context/network-filter-context.tsx
Normal file
14
src/context/network-filter-context.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { ReactNode, useState } from "react";
|
||||
import { FilterContext } from "./filter-context";
|
||||
|
||||
export function FilterProvider({ children }: { children: ReactNode }) {
|
||||
const [filter, setFilter] = useState<boolean>(false);
|
||||
|
||||
return (
|
||||
<FilterContext.Provider value={{ filter, setFilter }}>
|
||||
{children}
|
||||
</FilterContext.Provider>
|
||||
);
|
||||
}
|
||||
12
src/context/status-context.ts
Normal file
12
src/context/status-context.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createContext } from "react";
|
||||
|
||||
export type Status = "all" | "online" | "offline";
|
||||
|
||||
export interface StatusContextType {
|
||||
status: Status;
|
||||
setStatus: (status: Status) => void;
|
||||
}
|
||||
|
||||
export const StatusContext = createContext<StatusContextType | undefined>(
|
||||
undefined,
|
||||
);
|
||||
14
src/context/status-provider.tsx
Normal file
14
src/context/status-provider.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
"use client";
|
||||
|
||||
import { ReactNode, useState } from "react";
|
||||
import { Status, StatusContext } from "./status-context";
|
||||
|
||||
export function StatusProvider({ children }: { children: ReactNode }) {
|
||||
const [status, setStatus] = useState<Status>("all");
|
||||
|
||||
return (
|
||||
<StatusContext.Provider value={{ status, setStatus }}>
|
||||
{children}
|
||||
</StatusContext.Provider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user