Skip to content

Commit

Permalink
members tab added
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsinghbisht committed Oct 28, 2024
1 parent 3d752df commit cf77a9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/app/context/AppContext.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client"
import { createContext, useEffect, useState } from "react";
import TabData from "../interface/TabData";
import AppContextInterface from "../interface/AppContextInterface";
import AppContextInterface, { SiteData } from "../interface/AppContextInterface";


export const AppContext = createContext<AppContextInterface>({} as AppContextInterface);

export const AppContextProvider = ({ children }: { children: React.ReactNode }) => {
const [tabs, setTabs] = useState<TabData[]>([]);
const [data, setData] = useState<any>();
const [data, setData] = useState<SiteData>({} as SiteData);
const [loading, setLoading] = useState<boolean>(true);

useEffect(() => {
Expand All @@ -22,9 +22,9 @@ export const AppContextProvider = ({ children }: { children: React.ReactNode })
const res = await fetch("/data.json", { signal });
const data = await res.json();
setData(data);
} catch(err: any) {
setData({})
if (err.name === 'AbortError') {
} catch(err) {
setData({} as SiteData)
if ((err as Error).name === 'AbortError') {
console.log('Fetch aborted');
} else {
console.log(err);
Expand Down
10 changes: 5 additions & 5 deletions src/app/interface/AppContextInterface.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Dispatch, SetStateAction } from "react";
import TabData from "./TabData";

interface MemberData {
export interface MemberData {
id: number;
name: string;
username: string;
about: string;
link: string;
}

export interface SiteData {
members: MemberData[]
}
// interface BlogData {}
// interface EventData {}

export default interface AppContextInterface {
tabs: TabData[],
setTabs: Dispatch<SetStateAction<TabData[]>>,
data: {
members: MemberData[]
},
data: SiteData,
loading: boolean,
setLoading: Dispatch<SetStateAction<boolean>>,
}

0 comments on commit cf77a9b

Please sign in to comment.