import { isLoggedIn, getLoggedInHandle } from '../lib/auth'
export function renderHeader(currentHandle: string, oauth: boolean = true): string {
const loggedIn = isLoggedIn()
const handle = getLoggedInHandle()
let loginBtn = ''
if (oauth) {
loginBtn = loggedIn
? ``
: ``
}
return `
`
}
export function mountHeader(
container: HTMLElement,
currentHandle: string,
onBrowse: (handle: string) => void
): void {
container.innerHTML = renderHeader(currentHandle)
const form = document.getElementById('header-form') as HTMLFormElement
const input = document.getElementById('header-input') as HTMLInputElement
form?.addEventListener('submit', (e) => {
e.preventDefault()
const handle = input.value.trim()
if (handle) {
onBrowse(handle)
}
})
}