"use client"; import {useState} from "react"; import * as github from "../services/github/client"; export default function useGitHub(){ const [loading,setLoading]=useState(false); async function execute(fn,...args){ setLoading(true); try{ return await fn(...args); }finally{ setLoading(false); } } return{ loading, repositories:(...a)=>execute(github.repositories,...a), repository:(...a)=>execute(github.repository,...a), cloneRepository:(...a)=>execute(github.cloneRepository,...a), createRepository:(...a)=>execute(github.createRepository,...a), commit:(...a)=>execute(github.commit,...a), push:(...a)=>execute(github.push,...a), pull:(...a)=>execute(github.pull,...a), branches:(...a)=>execute(github.branches,...a), checkout:(...a)=>execute(github.checkout,...a), pullRequests:(...a)=>execute(github.pullRequests,...a) }; }