Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #39 from hanshs/styling
Browse files Browse the repository at this point in the history
Authentication: Don't show delete and create buttons to unauthorized users (#28) and styling
  • Loading branch information
stibia authored Nov 7, 2021
2 parents 618d757 + 9791259 commit af9446e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import Head from 'next/head'
import Link from 'next/link'
import React from 'react'
import { useTheorems } from '../lib/data'
import { useSession } from 'next-auth/react'


export default function IndexPage() {
const theorems = useTheorems()
const session = useSession({ required: false })

return (
<>
Expand All @@ -21,7 +23,8 @@ export default function IndexPage() {
<h1 className="font-semibold text-2xl">Theorems</h1>
<p className="mb-4">Here you can find the list of all theorems currently in the system.</p>
</div>
<Link href={'/create'}><a className="btn">Create Theorem</a></Link>
{session.status === 'authenticated' &&
<Link href={'/create'}><a className="btn">Create Theorem</a></Link>}
</div>
<div className="flex">
<ol className="w-full">
Expand Down
5 changes: 4 additions & 1 deletion pages/theorem/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import React from 'react'
import { useRouter } from 'next/router'
import { useSession } from 'next-auth/react'

import { deleteTheorem, useTheorem } from '../../lib/data'
import Head from 'next/head'
Expand All @@ -9,6 +10,7 @@ import Theorem from '../../components/Theorem'
export default function ProofPage() {
const router = useRouter()
const theorem = useTheorem(router.query.id)
const session = useSession({ required: false })

if (!theorem) return null

Expand All @@ -32,7 +34,8 @@ export default function ProofPage() {

<Theorem theorem={theorem} />

<button className="btn btn-secondary block ml-auto" onClick={onClickDelete}>Delete Theorem</button>
{session.status === 'authenticated' &&
<button className="btn btn-secondary block ml-auto" onClick={onClickDelete}>Delete Theorem</button>}
</>
)
}
Binary file modified public/img/main-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/old-main-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

1 comment on commit af9446e

@vercel
Copy link

@vercel vercel bot commented on af9446e Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.