-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1572 Subscription Confirmation Page (#1576)
* Added subscription confirmation page * Fixed linting errors. * Moved inline styles to scss
- Loading branch information
1 parent
3477cce
commit 34aece4
Showing
6 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Route from '@ember/routing/route'; | ||
import fetch from 'fetch'; | ||
import ENV from 'labs-zap-search/config/environment'; | ||
|
||
export default Route.extend({ | ||
convertSubscriptionsToHandlebars(subscriptions) { | ||
const handlebars = { citywide: false, boroughs: [] }; | ||
const boros = { | ||
K: 'Brooklyn', | ||
X: 'Bronx', | ||
M: 'Manhattan', | ||
Q: 'Queens', | ||
R: 'Staten Island', | ||
}; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const [key, value] of Object.entries(subscriptions)) { | ||
if (value === 1) { | ||
if (key === 'CW') { | ||
handlebars.citywide = true; | ||
} else if (boros[key[0]]) { | ||
const i = handlebars.boroughs.findIndex(boro => boro.name === boros[key[0]]); | ||
if (i === -1) { | ||
handlebars.boroughs.push({ | ||
name: boros[key[0]], | ||
communityBoards: [parseInt(key.slice(-2), 10)], | ||
}); | ||
} else { | ||
handlebars.boroughs[i].communityBoards.push(parseInt(key.slice(-2), 10)); | ||
} | ||
} | ||
} | ||
} | ||
return handlebars; | ||
}, | ||
|
||
async model({ id }) { | ||
// No need to await for this to finish before making the next request | ||
fetch(`${ENV.host}/subscribers/${id}`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ subscriptions: { confirmed: 1 } }), | ||
}); | ||
|
||
// Go directly into getting the subscriptions | ||
const response = await fetch(`${ENV.host}/subscribers/${id}`); | ||
|
||
const body = await response.json(); | ||
if (!response.ok) throw await response.json(); | ||
|
||
return this.convertSubscriptionsToHandlebars(body); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// -------------------------------------------------- | ||
// Module: Subscribers Confirmation Page | ||
// -------------------------------------------------- | ||
|
||
.padding-top-4 { | ||
padding-top: 4rem !important; | ||
} | ||
.subscribers-confirm { | ||
p { | ||
font-weight: 500; | ||
&.lg { | ||
font-size: 27px; | ||
} | ||
&.md { | ||
font-size: 21px; | ||
} | ||
} | ||
li { | ||
font-weight: 500; | ||
font-size: 16px; | ||
} | ||
button { | ||
text-decoration: none; | ||
color:#F1F2F4; | ||
font-size: 1.25rem; | ||
background:#AE551D; | ||
border-radius: 1rem; | ||
padding: 20px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<div class="cell"> | ||
<div class="grid-container"> | ||
<div class="grid-x grid-padding-x grid-padding-y align-middle align-center subscribers-confirm"> | ||
<div class="cell large-8 padding-top-4"> | ||
<h1 class="header-xxl dcp-orange">Thank You For Subscribing To ZAP Updates.</h1> | ||
<p class="lg">You are currently subscribed to:</p> | ||
{{#if this.model.citywide}} | ||
<p class="md">Citywide</p> | ||
{{/if}} | ||
{{#each this.model.boroughs as |boro|}} | ||
<p class="md">{{boro.name}}:</p> | ||
<ul> | ||
{{#each boro.communityBoards as |district|}} | ||
<li>Community District {{district}}</li> | ||
{{/each}} | ||
</ul> | ||
{{/each}} | ||
<p>To modify subscriptions, <LinkTo @route="show-geography">click here NEEDS TO BE CHANGED TO /subscribers/:id/subscriptions</LinkTo>.</p> | ||
<LinkTo @route="show-geography"> | ||
<button> | ||
Go to Home | ||
</button> | ||
</LinkTo> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters