Skip to content
Snippets Groups Projects
Commit 81001c38 authored by Ludvig Damberg's avatar Ludvig Damberg
Browse files
parents 29c85b74 72e338f5
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,10 @@ const postSchema = new mongoose.Schema({ ...@@ -5,6 +5,10 @@ const postSchema = new mongoose.Schema({
type:String, type:String,
required:true required:true
}, },
recipe:{
type:String,
required:true
},
description:{ description:{
type:String, type:String,
required:true required:true
...@@ -13,6 +17,7 @@ const postSchema = new mongoose.Schema({ ...@@ -13,6 +17,7 @@ const postSchema = new mongoose.Schema({
type: String, type: String,
required: false required: false
} }
}) })
const postModel = mongoose.model("Post",postSchema) const postModel = mongoose.model("Post",postSchema)
......
...@@ -3,12 +3,13 @@ import { Paper } from '@mui/material' ...@@ -3,12 +3,13 @@ import { Paper } from '@mui/material'
import { useState } from 'react' import { useState } from 'react'
import axios from 'axios' import axios from 'axios'
import {AiOutlineCamera} from 'react-icons/ai' import {AiOutlineCamera} from 'react-icons/ai'
import styles from '../styles/styles.module.css'
const Post = () => { const Post = () => {
const [name,setName] = useState("") const [name,setName] = useState("")
const [description,setDescription] = useState("") const [description,setDescription] = useState("")
const [recipe,setRecipe] = useState("")
const [imageData,setImageData] = useState('') const [imageData,setImageData] = useState('')
...@@ -19,11 +20,13 @@ const Post = () => { ...@@ -19,11 +20,13 @@ const Post = () => {
formData.append('name',name) formData.append('name',name)
formData.append('description',description) formData.append('description',description)
formData.append('recipe',recipe)
formData.append('photo',imageData) formData.append('photo',imageData)
axios.post("http://localhost:5000/save", axios.post("http://localhost:5000/save",
formData formData
) )
.then((res) => { .then((res) => {
console.log(res.data) console.log(res.data)
}).catch(err=> console.log(err)) }).catch(err=> console.log(err))
...@@ -37,16 +40,22 @@ const Post = () => { ...@@ -37,16 +40,22 @@ const Post = () => {
} }
return ( return (
<div className='post-container'> <div className={styles.post_container}>
<input className='post-input1' value={name} onChange={(e) => setName(e.target.value)} placeholder='name' type='text'/> <h1>Make your drink!</h1>
<p>Add a picture here 👉👉:</p> <input className={styles.post_input1} value={name} onChange={(e) => setName(e.target.value)} placeholder='Title of your drink' type='text'/>
<label className='pick-file' htmlFor="file_picker"> <textarea className={styles.post_input2} value={recipe} onChange={(e) => setRecipe(e.target.value)} placeholder='Recipe:' type='text'/>
<textarea className={styles.post_input2} value={description} onChange={(e) => setDescription(e.target.value)} placeholder='How to make it...' type='text' cols = '40' rows="5"/>
<div className={styles.addpicture}>
<p >Add a picture here 👉👉:</p>
<label className={styles.pick_file} htmlFor={styles.file_picker}>
<AiOutlineCamera/> <AiOutlineCamera/>
<input hidden type='file' name='file_picker' id='file_picker' onChange={(e) => setImageData(e.target.files[0])}/> <input hidden type="file" name={styles.file_picker} id={styles.file_picker} onChange={(e) => setImageData(e.target.files[0])}/>
</label> </label>
</div>
<button onClick={createPost}>Upload</button>
<input className='post-input2' value={description} onChange={(e) => setDescription(e.target.value)} placeholder='description' type='text'/>
<button onClick={createPost}>Upload</button>
</div> </div>
) )
......
import React from 'react' import React,{ useState, useEffect } from 'react'
import styles from '../styles/styles.module.css'
import axios from 'axios'
import Upvote from './Upvote'
const Posts = () => { const Posts = () => {
const [posts,setPosts] = useState([]) const [posts,setPosts] = useState([])
...@@ -27,13 +29,17 @@ const Posts = () => { ...@@ -27,13 +29,17 @@ const Posts = () => {
<div> <div>
<div>{posts.map((post) => { <div>{posts.map((post) => {
return( return(
<div className={styles.posts_container} key={post._id}> <div className={styles.posts_container} key={post._id}>
<div className={styles.post_img_container}>
<img className={styles.img} src={`http://localhost:5000/uploads/${post.photo}`}/> <img className={styles.img} src={`http://localhost:5000/uploads/${post.photo}`}/>
</div>
<div> <div>
<h1>{post.name}</h1> <h1>{post.name}</h1>
<p>{post.description}</p> <p>Recipe: {post.recipe}</p>
<p>Descrption: {post.description}</p>
</div> </div>
<Upvote/>
</div> </div>
) )
})}</div> })}</div>
......
import React, { useState } from 'react';
import axios from 'axios'
import styles from '../styles/styles.module.css'
const Upvote = () => {
const [count, setCount] = useState(0);
const increment = () => {
setCount(count + 1)
}
const decrement = () => {
setCount(count - 1)
}
if (count<0){
setCount(0);
}
// const formData = new FormData()
//formData.append('Upvotes',count);
//axios.post("http://localhost:5000/save",
// formData
// )
return (
<div className = {styles.upvote}>
<button className={styles.upvote} onClick={increment}>
+
</button>
<div>{count}</div>
<button className={styles.upvote} onClick={decrement}>
-
</button>
</div>
)
}
export default Upvote;
\ No newline at end of file
import React from 'react' import React from 'react'
import {useState, useRef, useEffect} from 'react'
import styles from '../styles/login.module.css' import styles from '../styles/login.module.css'
import LoginForm from '../components/LoginForm' import LoginForm from '../components/LoginForm'
const Login = () => { const Login = () => {
const userRef = useRef();
const errRef = useRef();
const[password,setPassword] = useState("")
const[email,setEmail] = useState("")
const [errMsg, setErrMsg] = useState('');
const [success, setSuccess] = useState(false);
return ( return (
<div className={styles.parent}> <div className={styles.parent}>
<div className={styles.left}> <div className={styles.left}>
......
p{ p{
color:white; color:white;
} }
input{ input{
font-family: 'Poppins', sans-serif; font-family: 'Poppins', sans-serif;
text-align: start;
margin-left:10px;
}
textarea{
font-family: 'Poppins', sans-serif;
text-align: start;
margin-left:10px;
} }
.Header{ .Header{
height: 90vh; height: 90vh;
...@@ -25,11 +33,13 @@ input{ ...@@ -25,11 +33,13 @@ input{
color: rgb(255, 240, 153); color: rgb(255, 240, 153);
font-size: 350%; font-size: 350%;
} }
.pick_file { .pick_file {
color: rgb(67, 1, 128); color: rgb(67, 1, 128);
font-size: 35px; font-size: 35px;
margin:0; margin:10px;
display: flex;
display: inline;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
...@@ -44,7 +54,7 @@ input{ ...@@ -44,7 +54,7 @@ input{
display: flex; /* Add display flex to center image vertically */ display: flex; /* Add display flex to center image vertically */
align-items: center; /* Center image vertically */ align-items: center; /* Center image vertically */
justify-content: center; /* Center image horizontally */ justify-content: center; /* Center image horizontally */
} }
.image_container img { .image_container img {
...@@ -54,6 +64,7 @@ object-fit: cover; ...@@ -54,6 +64,7 @@ object-fit: cover;
} }
.text_container{ .text_container{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -96,10 +107,11 @@ object-fit: cover; ...@@ -96,10 +107,11 @@ object-fit: cover;
margin-bottom: 15px; margin-bottom: 15px;
} }
.post_container{ .post_container{
min-height: 35vh; min-height: 35vh;
margin: auto; margin: auto;
width: 50vw; width: 600px;
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -109,46 +121,76 @@ object-fit: cover; ...@@ -109,46 +121,76 @@ object-fit: cover;
-webkit-backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
border-radius: 10px; border-radius: 10px;
box-shadow: 0 8px 23px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 8px 23px 0 rgba(0, 0, 0, 0.2);
box-align: center;
}
.post_container h1{
box-align: center;
margin-left: 26%;
} }
.post_input1{ .post_input1{
border: none; border: none;
background-color: rgb(11, 58, 58); background-color: rgb(26, 100, 100);
width: 300px; width: 500px;
height: 30px; height: 30px;
color: aliceblue; color: aliceblue;
outline: none; outline: none;
margin: 10px; margin-left: 50px;
margin-bottom: 10px;
margin-top: 15px; margin-top: 15px;
border-radius:4px;
} }
.post_input2{ .post_input2{
border: none; border: none;
background-color: rgb(11, 58, 58); background-color: rgb(26, 100, 100);
width: 1000px; width: 500px;
height: 200px; height: 100px;
color: aliceblue; color: rgb(250, 250, 250);
outline: none; outline: none;
margin: 10px; margin-left: 50px;
margin-bottom: 10px;
margin-right: 20px;
border-radius:4px;
} }
.post_container button{ .post_container button{
background: rgb(150, 172, 110); background: rgb(150, 172, 110);
color: white; color: white;
font-weight: bold; font-weight: bold;
font-size: 18px;
border: none; border: none;
width: 100px; width: 200px;
height: 40px; height: 80px;
margin-left: 15px; margin-left: 35%;
margin-bottom: 5px; margin-bottom: 25px;
font-family: 'Poppins', sans-serif; font-family: 'Poppins', sans-serif;
border-radius: 5px; border-radius: 5px;
}
.upvote{
background-color: rgb(25, 100, 100);
height: 30px;
width:30px;
box-align: center;
font-size: 18px;
font-family: 'Poppins', sans-serif;
border-radius: 5px;
border: none;
color: white;
}
.upvote button{
background: rgb(150, 172, 110);
color: white;
margin: auto;
} }
.posts_container{ .posts_container{
min-height: 35vh; min-height: 35vh;
margin: auto; margin: auto;
margin-top: 30px; margin-top: 30px;
width: 50vw;
width: 900px;
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -158,4 +200,37 @@ object-fit: cover; ...@@ -158,4 +200,37 @@ object-fit: cover;
-webkit-backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
border-radius: 10px; border-radius: 10px;
box-shadow: 0 8px 23px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 8px 23px 0 rgba(0, 0, 0, 0.2);
}
.post_img_container{
width: 300px; /* set width of image container */
height: 300px; /* set height of image container */
border-radius: 50%; /* make image container circular */
overflow: hidden;
display: flex; /* Add display flex to center image vertically */
align-items: center; /* Center image vertically */
justify-content: center; /* Center image horizontally */
margin-left: 5%;
margin-right: 10%;
margin-top:5%;
margin-bottom:5%;
}
.post_img_container img{
height: 100%;
width: 100%;
object-fit: cover;
}
.addpicture{
text-align: center;
margin-right: 30px;
margin-left:31%;
margin-bottom: 30px;
height:50px;
width:500px;
display:flex;
}
::placeholder {
color:aliceblue;
text-align: start;
} }
\ No newline at end of file
{
"name": "TDDD27",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment