Skip to content

Commit

Permalink
I commited something
Browse files Browse the repository at this point in the history
  • Loading branch information
Obadja Ris committed Sep 26, 2020
1 parent 81eba2e commit f7b049c
Show file tree
Hide file tree
Showing 8 changed files with 1,499 additions and 310 deletions.
Empty file added app/auth/session.tsx
Empty file.
21 changes: 21 additions & 0 deletions app/pages/Fietsen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Suspense } from "react"
import Layout from "app/layouts/Layout"
import { Head, Link, usePaginatedQuery, useRouter, BlitzPage } from "blitz"

const ITEMS_PER_PAGE = 100
const FietsenPage: BlitzPage = () => {
return (
<div>
<Head>
<title>Fietsen</title>
</Head>
<main>
<div>
<p>Hoi, welkom op deze pagina!</p>
</div>
</main>
</div>
)
}
FietsenPage.getLayout = (page) => <Layout title={"Fietsen"}>{page}</Layout>
export default FietsenPage
Empty file added app/pages/index-inlog.tsx
Empty file.
295 changes: 72 additions & 223 deletions app/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
import { Link, BlitzPage } from "blitz"
import React, { Suspense } from "react"
import Layout from "app/layouts/Layout"
import logout from "app/auth/mutations/logout"
import { Head, Link, usePaginatedQuery, useRouter, BlitzPage } from "blitz"
import { useCurrentUser } from "app/hooks/useCurrentUser"
import { Suspense } from "react"

/*
* This file is just for a pleasant getting started page for your new app.
* You can delete everything in here and start from scratch if you like.
*/
import logout from "app/auth/mutations/logout"
import { LabeledTextField } from "app/components/LabeledTextField"
import { Form, FORM_ERROR } from "app/components/Form"
import login from "app/auth/mutations/login"
import { LoginInput, LoginInputType } from "app/auth/validations"
const ITEMS_PER_PAGE = 100

const UserInfo = () => {
const loginForm = () => {
return (
<div className="base-container">
<div className="header">Login</div>
<div className="content">
<div className="form">
<div className="formGroup">
<label htmlFor="username">Username</label>
<input type="text" name="username" placeholder="username" />
</div>
<div className="form">
<div className="formGroup">
<label htmlFor="password">Password</label>
<input type="password" name="password" placeholder="password" />
</div>
</div>
</div>
</div>
<div className="footer">
<button type="button" className="btn">
Login
</button>
</div>
</div>
)
}
type LoginFormProps = {
onSuccess?: () => void
}
const UserInfo = (props: LoginFormProps) => {
const currentUser = useCurrentUser()

if (currentUser) {
Expand All @@ -32,229 +61,49 @@ const UserInfo = () => {
)
} else {
return (
<>
<Link href="/signup">
<a className="button small">
<strong>Sign Up</strong>
</a>
</Link>
<Link href="/login">
<a className="button small">
<strong>Login</strong>
</a>
</Link>
</>
<Form<LoginInputType>
submitText="Log In"
schema={LoginInput}
initialValues={{ email: "", password: "" }}
onSubmit={async (values) => {
try {
await login({ email: values.email, password: values.password })
props.onSuccess && props.onSuccess()
} catch (error) {
if (error.name === "AuthenticationError") {
return { [FORM_ERROR]: "Sorry, those credentials are invalid" }
} else {
return {
[FORM_ERROR]:
"Sorry, we had an unexpected error. Please try again. - " + error.toString(),
}
}
}
}}
>
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
</Form>
)
}
}

const Home: BlitzPage = () => {
const HomePage: BlitzPage = () => {
return (
<div className="container">
<div>
<Head>
<title>Home</title>
</Head>
<main>
<div className="logo">
<img src="/logo.png" alt="blitz.js" />
</div>
<p>
<strong>Congrats!</strong> Your app is ready, including user sign-up and log-in.
</p>
<div className="buttons" style={{ marginTop: "1rem", marginBottom: "5rem" }}>
<Suspense fallback="Loading...">
<UserInfo />
</Suspense>
</div>
<p>
<strong>
To add a new model to your app, <br />
run the following in your terminal:
</strong>
</p>
<pre>
<code>blitz generate all project name:string</code>
</pre>
<pre>
<code>blitz db migrate</code>
</pre>

<p>
Then go to{" "}
<Link href="/projects">
<a>/projects</a>
<div>
<p>Hoi, welkom op deze pagina!</p>
<Link href="/Fietsen">
<a>Klik Deze Link!</a>
</Link>
</p>
<div className="buttons" style={{ marginTop: "5rem" }}>
<a
className="button"
href="https://github.com/blitz-js/blitz/blob/master/USER_GUIDE.md?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
<a
className="button-outline"
href="https://github.com/blitz-js/blitz"
target="_blank"
rel="noopener noreferrer"
>
Github Repo
</a>
<a
className="button-outline"
href="https://slack.blitzjs.com"
target="_blank"
rel="noopener noreferrer"
>
Slack Community
</a>
</div>
</main>

<footer>
<a
href="https://blitzjs.com?utm_source=blitz-new&utm_medium=app-template&utm_campaign=blitz-new"
target="_blank"
rel="noopener noreferrer"
>
Powered by Blitz.js
</a>
</footer>

<style jsx global>{`
@import url("https://fonts.googleapis.com/css2?family=Libre+Franklin:wght@300;700&display=swap");
html,
body {
padding: 0;
margin: 0;
font-family: "Libre Franklin", -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
* {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
box-sizing: border-box;
}
.container {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
main {
padding: 5rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
main p {
font-size: 1.2rem;
}
p {
text-align: center;
}
footer {
width: 100%;
height: 60px;
border-top: 1px solid #eaeaea;
display: flex;
justify-content: center;
align-items: center;
background-color: #45009d;
}
footer a {
display: flex;
justify-content: center;
align-items: center;
}
footer a {
color: #f4f4f4;
text-decoration: none;
}
.logo {
margin-bottom: 2rem;
}
.logo img {
width: 300px;
}
.buttons {
display: grid;
grid-auto-flow: column;
grid-gap: 0.5rem;
}
.button {
font-size: 1rem;
background-color: #6700eb;
padding: 1rem 2rem;
color: #f4f4f4;
text-align: center;
}
.button.small {
padding: 0.5rem 1rem;
}
.button:hover {
background-color: #45009d;
}
.button-outline {
border: 2px solid #6700eb;
padding: 1rem 2rem;
color: #6700eb;
text-align: center;
}
.button-outline:hover {
border-color: #45009d;
color: #45009d;
}
pre {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
}
code {
font-size: 0.9rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
margin-top: 3rem;
}
@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}
`}</style>
</div>
)
}

Home.getLayout = (page) => <Layout title="Home">{page}</Layout>

export default Home
HomePage.getLayout = (page) => <Layout title={"Home"}>{page}</Layout>
export default HomePage
Empty file added app/pages/someQuery.ts
Empty file.
5 changes: 2 additions & 3 deletions app/questions/pages/questions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import Layout from "app/layouts/Layout"
import { Head, Link, usePaginatedQuery, useRouter, BlitzPage } from "blitz"
import getQuestions from "app/questions/queries/getQuestions"
import updateChoice from "app/choices/mutations/updateChoice"

import ReactDOM from "react-dom"
import questions from "app/questions/queries/getQuestions"
const ITEMS_PER_PAGE = 100

export const QuestionsList = () => {
Expand Down Expand Up @@ -57,10 +58,8 @@ const QuestionsPage: BlitzPage = () => {
<Head>
<title>Questions</title>
</Head>

<main>
<h1>Questions</h1>

<p>
<Link href="/questions/new">
<a>Create Question</a>
Expand Down
Loading

0 comments on commit f7b049c

Please sign in to comment.