Skip to content

Commit

Permalink
Added update confirmation modal
Browse files Browse the repository at this point in the history
Clean up log and commented out code

More console statements removed

Add language and icons to modal
  • Loading branch information
dhochbaum-dcp authored and pratishta committed Nov 22, 2024
1 parent bb63a37 commit 168b5d4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
18 changes: 15 additions & 3 deletions client/app/components/subscription-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default class SubscriptionFormComponent extends Component {

isSubmitting = false;

showSubscriptionUpdateConfirmationModal = false;
updateStatus = "none";

Check failure on line 16 in client/app/components/subscription-form.js

View workflow job for this annotation

GitHub Actions / Tests

Expected blank line between class members

Check failure on line 16 in client/app/components/subscription-form.js

View workflow job for this annotation

GitHub Actions / Tests

Strings must use singlequote

previousSubscriptions = {};
previousIsCommunityDistrict = false;

Check failure on line 19 in client/app/components/subscription-form.js

View workflow job for this annotation

GitHub Actions / Tests

Expected blank line between class members

Expand Down Expand Up @@ -130,7 +133,6 @@ export default class SubscriptionFormComponent extends Component {
}
}

console.log(requestBody);
const response = await fetch(`${ENV.host}/subscribers${this.args.isUpdate ? (`/`+ this.args.id) : ''}`, {
method: this.args.isUpdate ? 'PATCH' : 'POST',
headers: {
Expand All @@ -140,11 +142,21 @@ export default class SubscriptionFormComponent extends Component {
});

await response.json();
console.log("response", response);

if (!response.ok) throw await response.json();
if (!response.ok) {
set(this, 'showSubscriptionUpdateConfirmationModal', true);
set(this, 'updateStatus', "error");
throw await response.json();
}

if (!this.args.isUpdate) window.location.pathname = '/subscribed';

set(this, 'isSubmitting', false);

if(this.args.isUpdate) {
set(this, 'showSubscriptionUpdateConfirmationModal', true);
set(this, 'updateStatus', "success");
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Component from '@ember/component';

export default class SubscriptionUpdateConfirmationModalComponent extends Component {
}
2 changes: 0 additions & 2 deletions client/app/routes/subscription-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default Route.extend({

const body = await response.json();
if (!response.ok) throw await response.json();
console.log("body", body)

var subscriptions = { CW: (body.subscriptions["CW"] === 1) };
const districts = lookupCommunityDistrict();
Expand All @@ -20,7 +19,6 @@ console.log("body", body)
subscriptions[district.code] = false;
}
}
console.log("model", { email: body.email, subscriptions })
return { id, email: body.email, subscriptions };
},
});
26 changes: 25 additions & 1 deletion client/app/styles/modules/_m-subscription-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,28 @@ input[type=checkbox] {

.update-type-label {
padding-left: 10px;
}
}

.subscription-update-confirmation-modal {
font-size: 1.25rem;
div > span.frown {
color: $red-muted;
}
span {

color:#008e50;
}
p {
font-size: 1rem;
}
display: flex;
align-items: center;
gap: 1rem;
}

.home-button {
display: flex;
width: 100%;
justify-content: center;
// padding-top: 200px;
}
4 changes: 2 additions & 2 deletions client/app/templates/components/subscription-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
</li>
<li>
<div class="update-type-item">
{{log "isCommunityDistrict" isCommunityDistrict}}
<Input @id="community-district-checkbox" @type="checkbox" @checked={{isCommunityDistrict}}
{{on "change" this.closeAllAccordions}}/>
<div class="update-type-label">
Expand Down Expand Up @@ -74,4 +73,5 @@
{{/if}}
<a class="button primary no-margin {{if this.canBeSubmitted "" "disabled"}}" type="submit" {{action "subscribe"}}>{{if this.args.isUpdate "Update" "Subscribe"}}</a>
</div>
</form>
</form>
<SubscriptionUpdateConfirmationModal @showSubscriptionUpdateConfirmationModal={{showSubscriptionUpdateConfirmationModal}} @updateStatus={{updateStatus}} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{#if this.showSubscriptionUpdateConfirmationModal}}
<div class="reveal-overlay" style="display:block; background-color: rgba(241, 242, 244, 0.45)">
<div class="reveal-overlay-target"></div>
<div class="reveal info-modal" role="dialog" aria-hidden="false" tabindex="-1" style="display:block;"
data-test-info-modal>
<div class="subscription-update-confirmation-modal">
{{#if (eq this.updateStatus "success")}}
<div><span>{{fa-icon icon='check-circle' prefix='far' size='2x'}}</span></div>
<div>Your subscription settings have been updated.
<p>The changes will be reflected in the system in a few minutes.</p>
</div>
{{else if (eq this.updateStatus "error")}}
<div>
<span class="frown">{{fa-icon icon='frown' prefix='far' size='2x'}}</span>
</div>
<div> <p> There was an error with your submission. Please try again in a few minutes.</p>
</div>
{{/if}}
</div>

<div class="home-button">
<LinkTo class="button primary align-middle" @route="show-geography">Home</LinkTo>
</div>
</div>
</div>
{{/if}}
6 changes: 0 additions & 6 deletions client/app/templates/subscription-update.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
<p></p>
<div class="update-type-question">To unsubscribe from a Community District or Citywide, uncheck the selected options below.</div>
</div>

{{log "this.model.subscriptions" this.model.subscriptions}}
{{log "this.model.email" this.model.email}}

{{log "this.model.id" this.model.id}}

<SubscriptionForm @subscriptions={{this.model.subscriptions}} @email={{this.model.email}} @isUpdate={{true}} @id={{this.model.id}}>
<div class="subscribe-section">
<div class="subscribe-input-group">
Expand Down
8 changes: 2 additions & 6 deletions server/src/subscriber/subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ export class SubscriberService {
* @returns {object}
*/
async checkCreate(importId: string, @Res() response, counter: number = 0, checksBeforeFail: number, pauseBetweenChecks: number, errorInfo: any) {
console.log("checking again");
if(counter >= checksBeforeFail) {
if(counter >= checksBeforeFail) {
console.error({
code: 408,
message: `Polling limit of ${checksBeforeFail} checks with a ${pauseBetweenChecks/1000} second delay between each has been reached.`,
Expand Down Expand Up @@ -263,13 +262,10 @@ export class SubscriberService {
}
}

console.log("request", request);

// https://www.twilio.com/docs/sendgrid/api-reference/contacts/add-or-update-a-contact
try {
const result = await this.client.request(request);
console.log(result);
return { isError: false, result: result };
return { isError: false, result: result };
} catch (error) {
return { isError: true, ...error };
}
Expand Down

0 comments on commit 168b5d4

Please sign in to comment.