hunk.code_window:   pages: any
     pageCount: number
     pageSWRs: responseInterface<any, any>[]
     isLoadingMore: boolean
     isReachingEnd: boolean
     isEmpty: boolean
  
hunk.labels: keep keep replace keep keep keep
hunk.after_edit:   pageSWRs: responseInterface<Data, Error>[]
  
hunk.file_path: src/types.ts
hunk.type: replace
file: import Button from '../components/button'
  import fetch from '../libs/fetch'
  import { login, logout } from '../libs/auth'
  
  import useSWR from 'swr'
  
  export default () => {
    const { data, revalidate } = useSWR('/api/user', fetch)
  
    if (!data) return <h1>loading...</h1>
    if (data.loggedIn) {
      return <div>
        <h1>Welcome, {data.name}</h1>
        <img src={data.avatar} width={80} />
        <Button onClick={() => {
          logout()
          revalidate() // after logging in/out, we revalidate the SWR
        }}>Logout</Button>
      </div>
    } else {
      return <div>
        <h1>Please login</h1>
        <Button onClick={() => {
          login()
          revalidate()
        }}>Login</Button>
      </div>
    }
  }
  