Navbar and Post Schema Fixes
This commit is contained in:
@@ -10,22 +10,6 @@ function Mobile() {
|
|||||||
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
||||||
Welcome, {isAuthenticated ? session.username : ""} !!
|
Welcome, {isAuthenticated ? session.username : ""} !!
|
||||||
</h1>
|
</h1>
|
||||||
{isAuthenticated ? (
|
|
||||||
<div>
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/logout">Logout</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="flex gap-4">
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/login?screen_hint=signup">Sign up</a>
|
|
||||||
</button>
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/login?screen_hint=login">Log in</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -38,23 +22,6 @@ function Web() {
|
|||||||
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
<h1 className="text-3xl sm:text-4xl font-bold tracking-[-.01em] text-center sm:text-left">
|
||||||
Welcome, {isAuthenticated ? session.username : ""} !!
|
Welcome, {isAuthenticated ? session.username : ""} !!
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{isAuthenticated ? (
|
|
||||||
<div>
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/logout">Logout</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="flex gap-4">
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/login?screen_hint=signup">Sign up</a>
|
|
||||||
</button>
|
|
||||||
<button type="button" className="btn bg-surface-500">
|
|
||||||
<a href="/auth/login?screen_hint=login">Log in</a>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import {
|
|||||||
Home as IconHome,
|
Home as IconHome,
|
||||||
BookText as BookImage,
|
BookText as BookImage,
|
||||||
Coins as CoinsImage,
|
Coins as CoinsImage,
|
||||||
|
User as UserImage,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
const Footer = () => {
|
const Footer = () => {
|
||||||
|
|
||||||
|
const { isAuthenticated } = useDevice();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4 flex flex-col items-center gap-4 bg-surface-900">
|
<div className="p-4 flex flex-col items-center gap-4 bg-surface-900">
|
||||||
<Navigation.Bar className="flex justify-around w-full">
|
<Navigation.Bar className="flex justify-around w-full">
|
||||||
@@ -23,6 +25,11 @@ const Footer = () => {
|
|||||||
<Navigation.Tile label="Points Guide" href="/pointsguide" className="flex flex-col items-center">
|
<Navigation.Tile label="Points Guide" href="/pointsguide" className="flex flex-col items-center">
|
||||||
<CoinsImage />
|
<CoinsImage />
|
||||||
</Navigation.Tile>
|
</Navigation.Tile>
|
||||||
|
{isAuthenticated ? (
|
||||||
|
<Navigation.Tile label="Profile" href="/profile" className="flex flex-col items-center">
|
||||||
|
<UserImage />
|
||||||
|
</Navigation.Tile>
|
||||||
|
) : null}
|
||||||
</Navigation.Bar>
|
</Navigation.Bar>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useDevice } from "../context/DeviceContext";
|
||||||
|
|
||||||
const NavBar = () => {
|
const NavBar = () => {
|
||||||
|
const { isAuthenticated } = useDevice();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="sticky top-0 z-50 shadow-xl text-black dark:text-white bg-surface-800">
|
<nav className="sticky top-0 z-50 shadow-xl text-black dark:text-white bg-surface-800">
|
||||||
<div className="container mx-auto px-4">
|
<div className="container mx-auto px-4">
|
||||||
@@ -30,6 +33,24 @@ const NavBar = () => {
|
|||||||
Points Guide
|
Points Guide
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="justify-self-end">
|
||||||
|
{isAuthenticated ? (
|
||||||
|
<div>
|
||||||
|
<button type="button" className="btn bg-surface-500">
|
||||||
|
<a href="/auth/logout">Logout</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="flex gap-4">
|
||||||
|
<button type="button" className="btn bg-surface-500">
|
||||||
|
<a href="/auth/login?screen_hint=signup">Sign up</a>
|
||||||
|
</button>
|
||||||
|
<button type="button" className="btn bg-surface-500">
|
||||||
|
<a href="/auth/login?screen_hint=login">Log in</a>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -6,25 +6,62 @@ const reqString = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const postSchema = new mongoose.Schema({
|
const postSchema = new mongoose.Schema({
|
||||||
|
id: reqString,
|
||||||
imageDes: reqString,
|
imageDes: reqString,
|
||||||
timeStamp: Date,
|
timeStamp: Date,
|
||||||
reactions: Array,
|
reactions: Array,
|
||||||
|
userId: reqString,
|
||||||
});
|
});
|
||||||
|
|
||||||
export class Pickup {
|
export class Post {
|
||||||
model: mongoose.Model<any>;
|
model: mongoose.Model<any>;
|
||||||
upsert: any;
|
upsert: any;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.model = mongoose.model('post', postSchema);
|
this.model = mongoose.model('posts', postSchema);
|
||||||
this.upsert = { upsert: true };
|
this.upsert = { upsert: true };
|
||||||
}
|
}
|
||||||
async create(imageDes: string, reactions: Array<any>) {
|
|
||||||
|
makeId(length: number) {
|
||||||
|
var result = [];
|
||||||
|
var characters = 'abcdefghijklmnopqrstuvwxyz012345678901234567890123456789';
|
||||||
|
var charactersLength = characters.length;
|
||||||
|
for ( var i = 0; i < length; i++ ) {
|
||||||
|
result.push(characters.charAt(Math.floor(Math.random() * charactersLength)));
|
||||||
|
}
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(userId:string, imageDes: string) {
|
||||||
const newEntry = new this.model({
|
const newEntry = new this.model({
|
||||||
|
id: this.makeId(5),
|
||||||
imageDes: imageDes,
|
imageDes: imageDes,
|
||||||
timeStamp: new Date().toISOString(),
|
timeStamp: new Date().toISOString(),
|
||||||
reactions: reactions,
|
reactions: [],
|
||||||
|
userId: userId
|
||||||
});
|
});
|
||||||
await newEntry.save();
|
await newEntry.save();
|
||||||
return newEntry;
|
return newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getById(id: string) {
|
||||||
|
return await this.model.findOne({ id: id });
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAll() {
|
||||||
|
return await this.model.find({});
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAllByUserId(userId: string) {
|
||||||
|
return await this.model.find({ userId: userId });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: string, imageDes: string) {
|
||||||
|
return await this.model.updateOne({ id: id }, { imageDes: imageDes });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: string) {
|
||||||
|
return await this.model.deleteOne({ id: id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Post;
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
import User from "./User";
|
import User from "./User";
|
||||||
|
import Post from "./Post";
|
||||||
|
|
||||||
class DB {
|
class DB {
|
||||||
users: User;
|
users: User;
|
||||||
|
posts: Post;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.users = new User();
|
this.users = new User();
|
||||||
|
this.posts = new Post();
|
||||||
this.connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user