Updated app to v0.10, added db seeding.

This commit is contained in:
Martin Sosic 2023-04-07 15:48:24 +02:00 committed by Martin Šošić
parent 218df5d989
commit 2edebdbcb3
4 changed files with 41 additions and 18 deletions

View File

@ -1,20 +1,21 @@
app Thoughts {
wasp: {
version: "^0.9.1"
version: "^0.10.0"
},
title: "Thoughts",
db: { system: PostgreSQL },
db: {
system: PostgreSQL,
seeds: [ import { devSeedBasic } from "@server/seeds.js" ]
},
auth: {
userEntity: User,
methods: {
usernameAndPassword: {}
},
methods: { usernameAndPassword: {} },
onAuthFailedRedirectTo: "/login"
},
dependencies: [
("react-markdown", "6.0.1"),
("color-hash", "2.0.1")
]
],
}
route MainRoute { path: "/", to: MainPage }

View File

@ -1,17 +1,19 @@
import React from 'react'
import { Link } from 'react-router-dom'
import LoginForm from '@wasp/auth/forms/Login'
import { LoginForm } from '@wasp/auth/forms/Login'
import addWaspSourceHeader from './addWaspSourceHeader'
const LoginPage = (props) => {
return (
<>
<LoginForm/>
<br/>
<span>
I don't have an account yet (<Link to="/signup">go to signup</Link>).
</span>
<div style={{maxWidth: "400px", margin: "0 auto"}}>
<LoginForm/>
<br/>
<span>
I don't have an account yet (<Link to="/signup">go to signup</Link>).
</span>
</div>
</>
)
}

View File

@ -1,17 +1,19 @@
import React from 'react'
import { Link } from 'react-router-dom'
import SignupForm from '@wasp/auth/forms/Signup'
import { SignupForm } from '@wasp/auth/forms/Signup'
import addWaspSourceHeader from './addWaspSourceHeader'
const SignupPage = (props) => {
return (
<>
<SignupForm/>
<br/>
<span>
I already have an account (<Link to="/login">go to login</Link>).
</span>
<div style={{maxWidth: "400px", margin: "0 auto"}}>
<SignupForm/>
<br/>
<span>
I already have an account (<Link to="/login">go to login</Link>).
</span>
</div>
</>
)
}

View File

@ -0,0 +1,18 @@
import { createThought } from './actions.js'
export const devSeedBasic = async (prismaClient) => {
const user = await createUser(prismaClient, {
username: "RiuTheDog",
password: "bark1234"
})
await createThought(
{ tagNames: ["animals.cats"], textMarkdown: "## My favorite cats\n - Kira\n - Garfield" },
{ user, entities: { Thought: prismaClient.thought } }
)
}
async function createUser (prismaClient, data) {
const { password, ...newUser } = await prismaClient.user.create({ data })
return newUser
}