Team Ai
Apppublic

Underground-Digital/Workflow-Engine

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
external-api-panel-context.tsx29 linesDownload Raw Back to context
1'use client'2 3import React, { createContext, useContext, useState } from 'react'4 5type ExternalApiPanelContextType = {6  showExternalApiPanel: boolean7  setShowExternalApiPanel: (show: boolean) => void8}9 10const ExternalApiPanelContext = createContext<ExternalApiPanelContextType | undefined>(undefined)11 12export const ExternalApiPanelProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {13  const [showExternalApiPanel, setShowExternalApiPanel] = useState(false)14 15  return (16    <ExternalApiPanelContext.Provider value={{ showExternalApiPanel, setShowExternalApiPanel }}>17      {children}18    </ExternalApiPanelContext.Provider>19  )20}21 22export const useExternalApiPanel = () => {23  const context = useContext(ExternalApiPanelContext)24  if (context === undefined)25    throw new Error('useExternalApiPanel must be used within an ExternalApiPanelProvider')26 27  return context28}29