-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds component for updating user status #82
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class="heading"> | ||
{{#if (eq @status "active")}} | ||
<h2 data-test-status>I am doing a task</h2> | ||
{{/if}} | ||
{{#if (eq @status "idle")}} | ||
<h2 data-test-status>I am idle</h2> | ||
{{/if}} | ||
{{#if (eq @status "ooo")}} | ||
<h2 data-test-status>I am OOO</h2> | ||
{{/if}} | ||
</div> | ||
<div class="buttons"> | ||
{{#if (eq @status "active")}} | ||
<button class="buttons__idle" type="button" {{on "click" (fn @onUpdateStatus 'idle')}}><span data-test-button-text>Change status to ‘Idle’</span></button> | ||
<button class="buttons--small" type="button" {{on "click" (fn @onUpdateStatus 'ooo')}}><span>Mark yourself as OOO</span></button> | ||
{{/if}} | ||
{{#if (eq @status "idle")}} | ||
<button class="buttons__active" type="button" data-test-button {{on "click" (fn @onUpdateStatus 'active')}}><span data-test-button-text>Change status to ‘Doing a task’</span></button> | ||
<button class="buttons--small" type="button" {{on "click" (fn @onUpdateStatus 'ooo')}}><span>Mark yourself as OOO</span></button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A modifier class is added along side a base class. You can check out http://getbem.com/naming/ or reach out to me if you have any queries :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah right! Thank you :) |
||
{{/if}} | ||
{{#if (eq @status "ooo")}} | ||
<button class="buttons--small" type="button" {{on "click" (fn @onUpdateStatus 'active')}}><span>Mark yourself as Active again</span></button> | ||
{{/if}} | ||
</div> | ||
Comment on lines
+12
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here, the view seems to be doing a bunch of logic handling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah Okay :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import ENV from 'website-my/config/environment'; | ||
|
||
const BASE_URL = ENV.BASE_API_URL; | ||
|
||
export default class IndexController extends Controller { | ||
@tracked status = this.model; | ||
|
||
@action async updateStatus(status) { | ||
this.status = status; | ||
try { | ||
const response = await fetch(`${BASE_URL}/users/self`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why the fetching of data is happening in the controller and not the route. Also are we not using Ember Data? |
||
method: 'PATCH', | ||
body: JSON.stringify({ | ||
status, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
credentials: 'include', | ||
}); | ||
console.log(response); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No stray console logs in prod please :) |
||
} catch (error) { | ||
console.error('Error : ', error); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Route from '@ember/routing/route'; | ||
import ENV from 'website-my/config/environment'; | ||
|
||
const API_BASE_URL = ENV.BASE_API_URL; | ||
|
||
export default class TasksRoute extends Route { | ||
model = async () => { | ||
const response = await fetch(`${API_BASE_URL}/users/self`, { | ||
credentials: 'include', | ||
}); | ||
const userData = await response.json(); | ||
|
||
return userData.status; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.heading h2{ | ||
color: #0034a5; | ||
margin-bottom: 40px; | ||
margin-top: 50px; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.buttons { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.buttons__idle { | ||
font-size: 1rem; | ||
color: #e49504; | ||
font-weight: 600; | ||
border: 1px solid #e49504; | ||
padding: 20px; | ||
width: 18%; | ||
margin-bottom: 40px; | ||
border-radius: 10px; | ||
background: #ffff; | ||
} | ||
|
||
.buttons__active { | ||
font-size: 1rem; | ||
font-weight: 600; | ||
color: #16a334; | ||
border: 1px solid #16a334; | ||
border-radius: 10px; | ||
padding: 20px; | ||
margin-bottom: 40px; | ||
background: #ffff; | ||
} | ||
|
||
.buttons--small { | ||
font-size: 0.6rem; | ||
font-weight: 600; | ||
color: #0034a5; | ||
border: none; | ||
background: #ffff; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
Index page works! | ||
<UserStatus | ||
@status={{this.status}} | ||
@onUpdateStatus={{this.updateStatus}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems repetitive, I would suggest to instead set the string in the js file and simply have a single
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay