changed page titles
updated certain authentication logic added enter keydown handler to complete certain fields
This commit is contained in:
parent
893c5c415f
commit
cde8a5dc29
7 changed files with 43 additions and 7 deletions
|
|
@ -16,7 +16,6 @@ fetch(`${import.meta.env.VITE_BACKEND_URL}/ping`, options)
|
||||||
// if auth ok, set isAuthenticated to true
|
// if auth ok, set isAuthenticated to true
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
isAuthenticated.value = true;
|
isAuthenticated.value = true;
|
||||||
console.log(isAuthenticated);
|
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,8 @@ const router = VueRouter.createRouter({
|
||||||
routes,
|
routes,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
document.title = to.meta.title;
|
||||||
|
next();
|
||||||
|
}),
|
||||||
Vue.createApp(App).use(router).mount("#app");
|
Vue.createApp(App).use(router).mount("#app");
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,26 @@ import Post from "../views/Post.vue";
|
||||||
import Login from "../views/Login.vue";
|
import Login from "../views/Login.vue";
|
||||||
import Signup from "../views/Signup.vue";
|
import Signup from "../views/Signup.vue";
|
||||||
import User from "../views/User.vue";
|
import User from "../views/User.vue";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
export const routes = [
|
export const routes = [
|
||||||
{ path: "/", component: Home },
|
{ path: "/", component: Home, meta: { title: "myPlace()" } },
|
||||||
{ path: "/post/:postID", component: Post },
|
{
|
||||||
{ path: "/login", component: Login },
|
path: "/post/:postID",
|
||||||
{ path: "/user/new_user", component: Signup },
|
component: Post,
|
||||||
{ path: "/user/:userID", component: User },
|
meta: { title: "myPlace() - Post" },
|
||||||
|
},
|
||||||
|
{ path: "/login", component: Login, meta: { title: "myPlace() - Login" } },
|
||||||
|
{
|
||||||
|
path: "/user/new_user",
|
||||||
|
component: Signup,
|
||||||
|
meta: { title: "myPlace() - Join" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/user/:userID",
|
||||||
|
component: User,
|
||||||
|
meta: { title: "myPlace() - User" },
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,11 @@ const attemptLogin = (username, password) => {
|
||||||
id="username"
|
id="username"
|
||||||
class="bg-zinc-900 border p-5"
|
class="bg-zinc-900 border p-5"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@keydown.enter="attemptLogin(username, password)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@keydown.enter="attemptLogin(username, password)"
|
||||||
@click="attemptLogin(username, password)"
|
@click="attemptLogin(username, password)"
|
||||||
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex justify-center border"
|
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex justify-center border"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ getPost();
|
||||||
|
|
||||||
// submit comment
|
// submit comment
|
||||||
const submitComment = async (text, name) => {
|
const submitComment = async (text, name) => {
|
||||||
|
console.log(name);
|
||||||
// create JSON object and proper headers
|
// create JSON object and proper headers
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
@ -219,17 +220,28 @@ const deletePost = async () => {
|
||||||
>
|
>
|
||||||
<label for="comment_author">Your name: </label>
|
<label for="comment_author">Your name: </label>
|
||||||
<input
|
<input
|
||||||
|
@keydown.enter="submitComment(commentText, commentAuthor)"
|
||||||
id="comment_author"
|
id="comment_author"
|
||||||
class="bg-zinc-900 border p-5"
|
class="bg-zinc-900 border p-5"
|
||||||
v-model="commentAuthor"
|
v-model="commentAuthor"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
v-if="!isAuthenticated"
|
||||||
|
@keydown.enter="submitComment(commentText, commentAuthor)"
|
||||||
@click="submitComment(commentText, commentAuthor)"
|
@click="submitComment(commentText, commentAuthor)"
|
||||||
class="hover:bg-emerald-700 py-5 w-[8rem] flex justify-center border"
|
class="hover:bg-emerald-700 py-5 w-[8rem] flex justify-center border"
|
||||||
>
|
>
|
||||||
✅ Submit
|
✅ Submit
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
@keydown.enter="submitComment(commentText, currentUser)"
|
||||||
|
@click="submitComment(commentText, currentUser)"
|
||||||
|
class="hover:bg-emerald-700 py-5 w-[8rem] flex justify-center border"
|
||||||
|
>
|
||||||
|
✅ Submit
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,11 @@ const createUser = (username, password) => {
|
||||||
id="username"
|
id="username"
|
||||||
class="bg-zinc-900 border p-5"
|
class="bg-zinc-900 border p-5"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@keydown.enter="createUser(username, password)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@keydown.enter="createUser(username, password)"
|
||||||
@click="createUser(username, password)"
|
@click="createUser(username, password)"
|
||||||
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex border justify-center"
|
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex border justify-center"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,11 @@ const logout = () => {
|
||||||
id="username"
|
id="username"
|
||||||
class="bg-zinc-900 border p-5"
|
class="bg-zinc-900 border p-5"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@keydown.enter="editUser(username, password)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@keydown.enter="editUser(username, password)"
|
||||||
@click="editUser(username, password)"
|
@click="editUser(username, password)"
|
||||||
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex border justify-center"
|
class="mt-2 hover:bg-emerald-700 py-5 w-[8rem] flex border justify-center"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue