Skip to content

Commit

Permalink
Updating profile styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Areeba-Imran committed Feb 18, 2022
2 parents d0286c6 + 8d6ce98 commit b714783
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 44 deletions.
7 changes: 1 addition & 6 deletions models/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const eventSchema = new Schema({
type: String,
required: true
},

creater: {
type: Schema.Types.ObjectId,
ref: 'User'
Expand All @@ -18,10 +17,7 @@ const eventSchema = new Schema({
type: String,
required: true
},
endTime: {
type: String,
required: true
},
endTime: String,
location: {
type: String,
required: true
Expand All @@ -37,7 +33,6 @@ const eventSchema = new Schema({

tags: [String],
publicId: String,
tags: [String]
});

const Event = mongoose.model('Event', eventSchema);
Expand Down
11 changes: 5 additions & 6 deletions routes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ router.post('/new', uploadEventImages.single('img'), (req, res, next) => {
const img = req.file.path
const creater = req.session.user._id
const publicId = req.file.filename
Event.create({ img, publicId, title, creater, startDate, startTime, endTime, location, description, tags })

Event.create({ img, publicId, title, creater, startDate, startTime, endTime, location, description, tags: tags.split(",") })
.then(eventFromDB => {
console.log(eventFromDB)
res.redirect('/event/' + eventFromDB._id)
Expand Down Expand Up @@ -48,15 +49,13 @@ router.get("/search", (req, res, next) => {
router.get("/:id", (req, res, next) => {
const id = req.params.id
console.log(id)
Event.findById(id)
.populate('creater')
Event.findById(id).populate('creater')
.then(event => {
console.log(event)
let showDelete;
if (!req.session.user) {
showDelete = false
}
else {
} else {
showDelete = req.session.user._id == event.creater._id
console.log(showDelete)
}
Expand Down Expand Up @@ -105,7 +104,7 @@ router.get('/:id/delete', (req, res, next) => {
if (event.img) {
cloudinary.uploader.destroy(event.publicId)
}
res.redirect('/')
res.redirect('/profile')
})
.catch(err => next(err))
})
Expand Down
5 changes: 3 additions & 2 deletions routes/recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ router.post('/new', uploadRecipeImages.single('url'), (req, res, next) => {
//filter the empty inputs
const filteredIngredients = ingredients.filter((ingredient) => ingredient.length > 0)
const filteredInstructions = instructions.filter((step) => step.length > 0)
//create a new recipe in the db
Recipe.create({ url, publicId, name, description, source, cooktime, servings, calories, ingredients: filteredIngredients, instructions: filteredInstructions, tags, creater })

//create a new recipe in the db
Recipe.create({ url, publicId, name, description, source, cooktime, servings, calories, ingredients: filteredIngredients, instructions: filteredInstructions, tags: tags.split(","), creater })
.then(recipeFromDB => {
console.log(recipeFromDB)
res.redirect('/recipe/' + recipeFromDB._id)
Expand Down
13 changes: 11 additions & 2 deletions views/event/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
{{#with event}}
<div class="event-details-box">
<div class="join-event">
<<<<<<< HEAD
<img src="{{cloudinaryResize this.img "c_fill,w_500,h_400"}}" alt="Image of the {{title}} event">
=======
{{#if img}}
<img src="{{cloudinaryResize this.img "c_fill,w_500,h_400"}}" alt="Image of the {{title}} event">
{{/if}}
>>>>>>> 8d6ce98b3693b41f2cfb20d5334e070114146c8f
<div>
<p>⏰{{startDate}}, {{startTime}} - {{endTime}}</p>
<h1>{{title}}</h1>
<p>Created by {{creater.name}}</p>
<button type="submit" class="read-more-event">Join this event</button>
<p class="participant">{{participant}} people are going</p>
</div>
</div>

<div class="event-main-content">
<div>
<h6>📍 {{Location}}</h6>
<h6>📍{{location}}</h6>
<h6>Description: {{description}}</h6>
<h6>Tags: {{tags}}</h6>
{{#if tags}}
<h6>Tags:{{tags}}</h6>
{{/if}}
</div>

<div class="adjust-event-btn">
Expand Down
12 changes: 6 additions & 6 deletions views/event/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
</div>
<div class="mb-3">
<label for="title" class="form-label">Event Title<span>*</span></label>
<input type="text" class="form-control" name="title" value={{event.title}} required>
<input type="text" class="form-control" name="title" value="{{event.title}}" required>
</div>
<div class="row g-2">
<div class="col-md-6">
<label for="startDate" class="form-label">Start Date<span>*</span></label>
<input type="date" class="form-control start-date" name="startDate" min="{{dateNow}}" pattern="\d{4}-\d{2}-\d{2}" value={{event.startDate}} required>
<input type="date" class="form-control start-date" name="startDate" min="{{dateNow}}" pattern="\d{4}-\d{2}-\d{2}" value="{{event.startDate}}" required>
</div>
</div>
<div class="row g-2">
<div class="col-md-6">
<label for="startTime" class="form-label">Start Time<span>*</span></label>
<input type="time" class="form-control" name="startTime" value={{event.startTime}} required>
<input type="time" class="form-control" name="startTime" value="{{event.startTime}}" required>
</div>
<div class="col-md-6">
<label for="endTime" class="form-label">End Time</label>
<input type="time" class="form-control" name="endTime" value={{event.endTime}}>
<input type="time" class="form-control" name="endTime" value="{{event.endTime}}">
</div>
</div>
<div class="mb-3">
<label for="location" class="form-label">Location(city)<span>*</span></label>
<select class="form-control" name="location" value={{event.location}} required>
<select class="form-control" name="location" value="{{event.location}}" required>
<option>Berlin</option>
<option>Frankfurt</option>
<option>Hamburg</option>
Expand All @@ -43,7 +43,7 @@
</div>
<div class="mb-3">
<label for="tags" class="form-label">Tags</label>
<input type="text" class="form-control" name="tags" data-role="tagsinput" value={{event.tags}}>
<input type="text" class="form-control" name="tags" data-role="tagsinput" value="{{event.tags}}">
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button class="btn btn-primary" type="submit">Edit the event</button>
Expand Down
15 changes: 8 additions & 7 deletions views/event/new-event.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<h1>Create your Event 🥳</h1>
<form action="/event/new" method="POST" enctype="multipart/form-data">
<div class="mb-3">
<label for="img" class="form-label">Upload your event photo (optional)</label>
<input type="file" class="form-control" name="img">
<label for="img" class="form-label">Upload your event photo<span>*</span></label>
<input type="file" class="form-control" name="img" required>
</div>
<div class="mb-3">
<label for="title" class="form-label">Event Title<span>*</span></label>
Expand All @@ -30,11 +30,12 @@
<div class="mb-3">
<label for="location" class="form-label">Location(city)<span>*</span></label>
<select class="form-control" name="location" required>
<option>Berlin</option>
<option>Frankfurt</option>
<option>Hamburg</option>
<option>Munich</option>
<option>Others</option>
<option selected>Select City</option>
<option value="Berlin">Berlin</option>
<option value="Frankfurt">Frankfurt</option>
<option value="Hamburg">Hamburg</option>
<option value="Munich">Munich</option>
<option value="Others">Others</option>
</select>
</div>
<div class="mb-3">
Expand Down
2 changes: 1 addition & 1 deletion views/event/search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a href="/event/{{id}}"><img src="{{cloudinaryResize img "c_fill,w_400,h_300"}}" alt="image of {{title}}" class="img-fluid"></a>
<h2><a href="/event/{{id}}">{{title}}</a></h2>
<p>⏰{{startDate}}, {{startTime}} - {{endTime}}</p>
<h6>📍 {{Location}}</h6>
<h6>📍 {{location}}</h6>
<a href="/event/{{id}}"><button class="read-more-event">Find Out More</button></a>

</div>
Expand Down
4 changes: 4 additions & 0 deletions views/recipe/detail.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@
<div class="ingredients">
<h3>Ingredients: </h3>
{{#each ingredients}}
{{#if this}}
<input type="checkbox"> <label class="ingredient-name">{{this}}</label><br>
{{/if}}
{{/each}}
</div>

<div class="instructions-div">
<h3>Instructions: </h3>
<ol>
{{#each instructions}}
{{#if this}}
<li class="instruction">{{this}}</li>
{{/if}}
{{/each}}
</ol>
</div>
Expand Down
31 changes: 17 additions & 14 deletions views/recipe/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,53 @@
</div>
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" name="name" placeholder="Grandma's dumpling" value={{recipe.name}}>
<input type="text" class="form-control" name="name" placeholder="Grandma's dumpling" value="{{recipe.name}}">
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea value={{recipe.description}} class="form-control" name="description" rows="3"
placeholder="Introduce us about your recipe - who inspired it, who you cooked it for, on which occasion you cooked or why it's special... "></textarea>
<textarea class="form-control" name="description" rows="3">{{recipe.description}}</textarea>
</div>
<div class="mb-3">
<label for="source" class="form-label">Origin (optional)</label>
<input type="text" class="form-control" name="source" placeholder="get inspired from...">
<input type="text" class="form-control" name="source" placeholder="get inspired from..." value="{{recipe.source}}" >
</div>
<div class="mb-3">
<label for="cooktime" class="form-label">Cook time</label>
<input type="number" class="form-control" name="cooktime" placeholder="">
<input type="number" class="form-control" name="cooktime" placeholder="" value="{{recipe.cooktime}}">
</div>
<div class="mb-3">
<label for="servings" class="form-label">Servings</label>
<input type="number" class="form-control" name="servings" placeholder="">
<input type="number" class="form-control" name="servings" placeholder="" value="{{recipe.servings}}">
</div>
<div class="mb-3">
<label for="calories" class="form-label">Calories</label>
<input type="number" class="form-control" name="calories" placeholder="">
<input type="number" class="form-control" name="calories" placeholder="" value="{{recipe.calories}}">
</div>
<div class="mb-3 ingredients-container">
<label for="ingredients" class="form-label">Ingredients</label>
<input type="text" class="form-control" name="ingredients" placeholder="250gr flour">
<input type="text" class="form-control" name="ingredients" placeholder="100ml milk">
<input type="text" class="form-control" name="ingredients" placeholder="250gr chicken breast">
{{#each recipe.ingredients}}
<input type="text" class="form-control" name="ingredients" placeholder="250gr flour" value="{{this}}">
{{/each}}
{{!-- <input type="text" class="form-control" name="ingredients" placeholder="100ml milk" value="{{recipe.ingredients}}">
<input type="text" class="form-control" name="ingredients" placeholder="250gr chicken breast" value="{{recipe.ingredients}}"> --}}
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary add-ingredients" type="button">Add more ingredients</button>
</div>
<div class="mb-3 instruction-steps">
<label for="instructions" class="form-label">Instructions</label>
<textarea class="form-control" name="instructions" rows="3" placeholder="Step1"></textarea>
<textarea class="form-control" name="instructions" rows="3" placeholder="Step2"></textarea>
<textarea class="form-control" name="instructions" rows="3" placeholder="Step3"></textarea>
{{#each recipe.instructions}}
<textarea class="form-control" name="instructions" rows="3" placeholder="Step1">{{this}}</textarea>
{{!-- <textarea class="form-control" name="instructions" rows="3" placeholder="Step2"></textarea> --}}
{{!-- <textarea class="form-control" name="instructions" rows="3" placeholder="Step3"></textarea> --}}
{{/each}}
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary add-steps" type="button">Add more steps</button>
</div>
<div class="mb-3">
<label for="tags" class="form-label">Tags</label>
<input type="text" class="form-control" name="tags" placeholder="">
<input type="text" class="form-control" name="tags" placeholder="" value="{{recipe.tags}}">
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button class="btn btn-primary" type="submit">Edit your recipe</button>
Expand Down

0 comments on commit b714783

Please sign in to comment.