Skip to content

Commit

Permalink
fix(build): fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
kilip committed Oct 24, 2023
1 parent da1a4f8 commit 48f19b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
16 changes: 8 additions & 8 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import classNames from 'classnames'
import Layout from '@/pkg/ui/views/Layout'
import Providers from '@/pkg/ui/Providers'

const inter = Inter({ subsets: ['latin'] })
Expand All @@ -20,13 +19,14 @@ export default function RootLayout({
return (
<html lang="en">
<body
className={classNames({
'bg-gray-200 min-h-screen': true
})}
>
<Providers>
{children}
</Providers>
className={
inter.className +
' ' +
classNames({
'bg-gray-200 min-h-screen': true,
})
}>
<Providers>{children}</Providers>
</body>
</html>
)
Expand Down
10 changes: 5 additions & 5 deletions src/pkg/github/views/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use client'

import { useEffect, useState } from 'react'
import { useSearchRepos } from '../hooks/search'
import { useThemeContext } from '@/pkg/ui/contexts/ThemeContext'
import { GitHubSearchItems } from '../types'
import SearchToolbar from './SearchToolbar'
import { useGitHubSearchContext } from '../context/SearchContext'
import RepoList from './repo/RepoList'
import useSearchRepos from '../hooks/search'

export default function Search() {
const { setLoading } = useThemeContext()
Expand All @@ -19,16 +19,16 @@ export default function Search() {
}, [isLoading, setLoading])

useEffect(() => {
if(response){
if (response) {
setRepositories(response.data.items)
setTotal(response.data.total_count)
}
}, [response, setTotal])

return (
<div className='flex flex-col w-screen gap-4'>
<SearchToolbar/>
<RepoList repositories={repositories}/>
<div className="flex flex-col w-screen gap-4">
<SearchToolbar />
<RepoList repositories={repositories} />
</div>
)
}
45 changes: 22 additions & 23 deletions src/pkg/ui/contexts/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
'use client'

import { createContext, useContext, useReducer, useState } from 'react'
import { ThemeAction, ThemeActionType, ThemeContextProps, ThemeState, ToastState } from '../types'
import { createContext, useContext, useState } from 'react'
import {
ThemeAction,
ThemeActionType,
ThemeContextProps,
ThemeState,
} from '../types'
import { PropsWithChildren } from 'react'
import ToastProvider from './ToastContext'
import Layout from '../views/Layout'
import AuthProvider from '@/pkg/auth/context/AuthContext'
import ReactQueryProvider from './ReactQueryContext'
import LoadingOverlay from '../views/LoadingOverlay'

function themeReducer(state: ThemeState, action: ThemeAction){
const {type, payload} = action
function themeReducer(state: ThemeState, action: ThemeAction) {
const { type, payload } = action

switch(type){
switch (type) {
case ThemeActionType.Loading:
return {
...state,
...payload
...payload,
}
default:
throw new Error('Unknown theme action type: '+type)
throw new Error('Unknown theme action type: ' + type)
}
}

const ThemeContext = createContext<ThemeContextProps|undefined>(undefined)
export default function ThemeProvider({children}: PropsWithChildren) {
const ThemeContext = createContext<ThemeContextProps | undefined>(undefined)
export default function ThemeProvider({ children }: PropsWithChildren) {
const [loading, setLoading] = useState(false)
return (
<ThemeContext.Provider value={{
loading,
setLoading
}}>
<ThemeContext.Provider
value={{
loading,
setLoading,
}}>
{children}
<LoadingOverlay loading={loading}/>
<LoadingOverlay loading={loading} />
</ThemeContext.Provider>
)
}

export function useThemeContext(): ThemeContextProps {
const context = useContext(ThemeContext) as ThemeContextProps | undefined

if(!context){
throw Error(
'useThemeContext should be used within ThemeProvider'
)
if (!context) {
throw Error('useThemeContext should be used within ThemeProvider')
}

return context
}

0 comments on commit 48f19b6

Please sign in to comment.