Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulijuz committed Nov 8, 2023
1 parent b95aa40 commit dfc5254
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
5 changes: 3 additions & 2 deletions src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import Image from 'next/image'

import styles from './layout.module.scss'
Expand All @@ -9,12 +10,12 @@ export default function AuthLayout({ children } : { children: React.ReactNode})
<div className={styles.wrapper}>
<div className={styles.card}>
<div className={styles.input}>
{children}
{children}
</div>
<div className={styles.image}>
<Image alt="en kappemann sin hatt" width={200} src={magiskHatt} />
</div>
</div>
</div>
)
}
}
40 changes: 20 additions & 20 deletions src/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
"use client"
'use client'

import { FormEvent, useState } from 'react'
import { FormEvent } from 'react'
import { signIn } from 'next-auth/react'
import { useSearchParams } from 'next/navigation'

import TextInput from '@/components/TextInput/TextInput'
import PrimaryButton from '@/app/components/PrimaryButton/PrimaryButton'

export default async function LogIn({ }) {
export default function LogIn() {
const searchParams = useSearchParams()

const error = searchParams.get('error')

async function handleSignIn(event: FormEvent<HTMLFormElement>) {
event.preventDefault()

const formData = new FormData(event.currentTarget);
await signIn('credentials', {
username: formData.get('username'),
password: formData.get('password'),
redirect: true,
callbackUrl: searchParams.get('callbackUrl') || '/users/me'
})
event.preventDefault()

const formData = new FormData(event.currentTarget)

await signIn('credentials', {
username: formData.get('username'),
password: formData.get('password'),
redirect: true,
callbackUrl: searchParams.get('callbackUrl') || '/users/me'
})
}

return <>
<form onSubmit={handleSignIn}>
<TextInput label='Brukernavn' name='username' type='text'/>
<TextInput label='Passord' name='password' type='password'/>
<PrimaryButton>Logg inn</PrimaryButton>
<p style={{color: "red"}}>{error == "CredentialsSignin" ? "Feil brukernavn eller passord :(" : ""}</p>
</form>
<form onSubmit={handleSignIn}>
<TextInput label='Brukernavn' name="username" type="text"/>
<TextInput label="Passord" name="password" type="password"/>
<PrimaryButton>Logg inn</PrimaryButton>
<p style={{ color: 'red' }}>{error === 'CredentialsSignin' ? 'Feil brukernavn eller passord :(' : ''}</p>
</form>
</>
}
7 changes: 3 additions & 4 deletions src/app/(auth)/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client"
'use client'

import { FormEvent } from 'react'
import { signOut } from 'next-auth/react'
import PrimaryButton from '@/app/components/PrimaryButton/PrimaryButton'

export default async function LogOut() {
export default function LogOut() {
async function handleSignOut() {
await signOut({
redirect: true,
Expand All @@ -13,6 +12,6 @@ export default async function LogOut() {
}

return (
<PrimaryButton type='button' onClick={handleSignOut}>Logg ut</PrimaryButton>
<PrimaryButton type="button" onClick={handleSignOut}>Logg ut</PrimaryButton>
)
}
4 changes: 2 additions & 2 deletions src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export default function Home() {
</div>
<div className={`${styles.part} ${styles.taktlause}`}>
<div className={styles.emptyPart} />
{/* <GoogleMap height={500} location = {{
<GoogleMap height={500} location = {{
lat: 37.42216,
lng: -122.08427,
}}/> */}
}}/>
</div>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions src/app/components/PrimaryButton/PrimaryButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import { ButtonHTMLAttributes } from 'react'

import styles from './PrimaryButton.module.scss'
Expand Down
7 changes: 3 additions & 4 deletions src/app/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ type PropTypes = InputHTMLAttributes<HTMLInputElement> & {
label?: string
}

export default function TextInput({ label, ...props } : PropTypes) {
label ??= ''
export default function TextInput({ label = 'default', ...props } : PropTypes) {
props.type ??= 'text'
props.id ??= `id_input_${uuid()}`

return (
<div className={styles.Input}>
<input {...props}/>
<label htmlFor={props.id}>{label}</label>
</div>
)
}
}

0 comments on commit dfc5254

Please sign in to comment.