yes
This commit is contained in:
@@ -1,15 +1,42 @@
|
||||
<template>
|
||||
<div>
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet,
|
||||
asperiores assumenda dolor ea esse eum itaque iure libero magni, nam
|
||||
porro, quas reiciendis repellat soluta sunt! Accusantium eum omnis
|
||||
quasi.
|
||||
<nav>
|
||||
<ul>
|
||||
<li class="text-blue-200">
|
||||
<router-link class="underline" to="/signin"
|
||||
>Sign In</router-link
|
||||
>
|
||||
</li>
|
||||
<li class="text-blue-200">
|
||||
<router-link class="underline" to="/register"
|
||||
>Register</router-link
|
||||
>
|
||||
</li>
|
||||
<li class="text-blue-200">
|
||||
<button class="underline" @click="logout">Sign Out</button>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<client-only>
|
||||
<div v-if="$auth.$state.loggedIn">
|
||||
User: {{ $auth.$state.user }}
|
||||
</div>
|
||||
</client-only>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Home',
|
||||
options: {
|
||||
auth: false, // FIXME: auth: 'guest'
|
||||
},
|
||||
methods: {
|
||||
async logout() {
|
||||
this.$store.commit('notes/clear')
|
||||
await this.$auth.logout()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<div class="container p-4 mx-auto bg-gray-700">
|
||||
<h1 class="text-center">My Notes</h1>
|
||||
<input
|
||||
id="search"
|
||||
name="search"
|
||||
class="block p-2 my-2 appearance-none w-full bg-transparent border-white-200 border-b focus:border-red-500"
|
||||
placeholder="search"
|
||||
aria-label="search"
|
||||
/>
|
||||
<div v-for="note in notes" :key="note.uuid">
|
||||
<div class="flex justify-between items-center">
|
||||
<h2 class="text-lg">{{ note.title }}</h2>
|
||||
<div class="py-2">
|
||||
<span
|
||||
v-for="(tag, index) in note.tags"
|
||||
:key="index"
|
||||
class="inline-block text-sm bg-gray-500 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 ml-2"
|
||||
>{{ tag }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'Notes',
|
||||
computed: {
|
||||
...mapState('notes', ['notes', 'isInitialized']),
|
||||
},
|
||||
mounted() {
|
||||
this.load()
|
||||
},
|
||||
methods: {
|
||||
...mapActions('notes', ['load']),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div
|
||||
class="h-screen container mx-auto h-full flex justify-center items-center"
|
||||
>
|
||||
<div class="w-full md:w-1/2 lg:w-1/3">
|
||||
<h1 class="font-semibold text-lg mb-6 text-center">
|
||||
Create an Account
|
||||
</h1>
|
||||
<div
|
||||
class="bg-gray-800 border-teal-500 p-8 border-t-8 bg-white mb-6 rounded-lg shadow-lg"
|
||||
>
|
||||
<form @submit.prevent="register">
|
||||
<div
|
||||
v-if="showError"
|
||||
class="bg-red-500 border-l-4 border-red-700 text-red-200 p-4 mb-4"
|
||||
role="alert"
|
||||
>
|
||||
<p class="font-bold">Error</p>
|
||||
<p>{{ error }}</p>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label
|
||||
for="username"
|
||||
class="font-bold text-grey-darker block mb-2"
|
||||
>
|
||||
Username
|
||||
</label>
|
||||
<input
|
||||
id="username"
|
||||
v-model="form.username"
|
||||
name="username"
|
||||
class="shadow focus:shadow-outline block appearance-none w-full bg-gray-700 border-gray-500 hover:border-gray-500 px-2 py-2 rounded shadow"
|
||||
placeholder="Your Username"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label
|
||||
for="password"
|
||||
class="font-bold text-grey-darker block mb-2"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
v-model="form.password"
|
||||
name="password"
|
||||
type="password"
|
||||
class="shadow focus:shadow-outline block appearance-none w-full bg-gray-700 border-gray-500 hover:border-gray-500 px-2 py-2 rounded shadow"
|
||||
placeholder="Your Password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label
|
||||
for="confirm"
|
||||
class="font-bold text-grey-darker block mb-2"
|
||||
>
|
||||
Confirm your password
|
||||
</label>
|
||||
<input
|
||||
id="confirm"
|
||||
v-model="confirm"
|
||||
name="confirm"
|
||||
type="password"
|
||||
class="shadow focus:shadow-outline block appearance-none w-full bg-gray-700 border-gray-500 hover:border-gray-500 px-2 py-2 rounded shadow"
|
||||
placeholder="Confirm your Password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mt-6">
|
||||
<button
|
||||
type="submit"
|
||||
class="w-full bg-teal-500 hover:bg-teal-400 text-white font-bold py-2 px-4 rounded"
|
||||
>
|
||||
Sign In
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p class="text-gray-200 text-sm">
|
||||
Already have an account?
|
||||
<nuxt-link
|
||||
to="/signin"
|
||||
class="no-underline text-blue-500 font-bold"
|
||||
>Sign in
|
||||
</nuxt-link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SignIn',
|
||||
options: {
|
||||
auth: false, // FIXME: auth: 'guest'
|
||||
},
|
||||
data: () => ({
|
||||
confirm: '',
|
||||
form: {
|
||||
username: '',
|
||||
password: '',
|
||||
},
|
||||
error: '',
|
||||
showError: false,
|
||||
}),
|
||||
methods: {
|
||||
register() {
|
||||
this.$axios
|
||||
.post('/user', this.form)
|
||||
.then(() => this.$router.push('/signin'))
|
||||
.catch((e) => {
|
||||
if (e.response) {
|
||||
this.error = e.response.data.error
|
||||
this.showError = true
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
head: () => ({
|
||||
title: 'Sign in',
|
||||
}),
|
||||
}
|
||||
</script>
|
||||
@@ -54,8 +54,10 @@
|
||||
<div class="text-center">
|
||||
<p class="text-gray-200 text-sm">
|
||||
Don't have an account?
|
||||
<a href="#" class="no-underline text-blue-500 font-bold"
|
||||
>Create an Account</a
|
||||
<nuxt-link
|
||||
to="/register"
|
||||
class="no-underline text-blue-500 font-bold"
|
||||
>Create an Account</nuxt-link
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
@@ -81,9 +83,7 @@ export default {
|
||||
.loginWith('local', {
|
||||
data: this.form,
|
||||
})
|
||||
.then(function (response) {})
|
||||
// eslint-disable-next-line handle-callback-err
|
||||
.catch(function (error) {})
|
||||
.then(() => this.$router.push('/'))
|
||||
},
|
||||
},
|
||||
head: () => ({
|
||||
|
||||
Reference in New Issue
Block a user