-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ mon-pix: create session-results page
- Loading branch information
1 parent
354c502
commit f35c2cf
Showing
9 changed files
with
166 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import PixBackgroundHeader from '@1024pix/pix-ui/components/pix-background-header'; | ||
import PixBlock from '@1024pix/pix-ui/components/pix-block'; | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixMessage from '@1024pix/pix-ui/components/pix-message'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { t } from 'ember-intl'; | ||
import ENV from 'mon-pix/config/environment'; | ||
|
||
export default class DownloadSessionResults extends Component { | ||
@tracked showErrorMessage = false; | ||
@service requestManager; | ||
|
||
@action | ||
async downloadSessionResults() { | ||
this.showErrorMessage = false; | ||
|
||
try { | ||
await this.requestManager.request({ | ||
url: `${ENV.APP.API_HOST}/api/xxx`, | ||
method: 'POST', | ||
body: { token: 'xxx' }, | ||
}); | ||
} catch { | ||
this.showErrorMessage = true; | ||
} | ||
} | ||
|
||
<template> | ||
<PixBackgroundHeader id="main"> | ||
<PixBlock class="download-session-results"> | ||
<form class="download-session-results__form" autocomplete="off"> | ||
|
||
<h1 class="form__title"> | ||
{{t "pages.download-session-results.title"}} | ||
</h1> | ||
|
||
<PixButton @type="submit" @triggerAction={{this.downloadSessionResults}} @size="large" class="form__actions"> | ||
{{t "pages.download-session-results.button.label"}} | ||
</PixButton> | ||
|
||
{{#if this.showErrorMessage}} | ||
<PixMessage @type="error" class="form__error"> | ||
{{t "pages.download-session-results.errors.expiration"}} | ||
</PixMessage> | ||
{{/if}} | ||
</form> | ||
</PixBlock> | ||
</PixBackgroundHeader> | ||
</template> | ||
} |
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,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class DownloadSessionResults extends Route {} |
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,29 @@ | ||
.download-session-results { | ||
max-width: max-content; | ||
margin: 0 auto 32px; | ||
padding: 48px 24px; | ||
|
||
@include device-is('tablet') { | ||
padding: 48px 60px; | ||
} | ||
|
||
&__form { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
.form__title { | ||
@extend %pix-title-m; | ||
|
||
margin-bottom: var(--pix-spacing-4x); | ||
} | ||
|
||
.form__actions { | ||
margin-top: var(--pix-spacing-6x); | ||
} | ||
|
||
.form__error { | ||
margin-top: var(--pix-spacing-4x); | ||
} | ||
} | ||
} |
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,11 @@ | ||
{{page-title (t "pages.download-session-results.title")}} | ||
|
||
<header role="banner"> | ||
<NavbarHeader /> | ||
</header> | ||
|
||
<main role="main"> | ||
<DownloadSessionResults /> | ||
</main> | ||
|
||
<Footer /> |
43 changes: 43 additions & 0 deletions
43
mon-pix/tests/integration/components/download-session-results-test.gjs
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,43 @@ | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import { click } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { t } from 'ember-intl/test-support'; | ||
import DownloadSessionResults from 'mon-pix/components/download-session-results'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
import setupIntlRenderingTest from '../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | download-session-results', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
let requestManagerService; | ||
|
||
hooks.beforeEach(function () { | ||
requestManagerService = this.owner.lookup('service:requestManager'); | ||
sinon.stub(requestManagerService, 'request'); | ||
}); | ||
|
||
test('should display component', async function (assert) { | ||
// given | ||
// when | ||
const screen = await render(<template><DownloadSessionResults /></template>); | ||
|
||
// then | ||
assert.dom(screen.getByRole('heading', { name: t('pages.download-session-results.title'), level: 1 })).exists(); | ||
assert.dom(screen.getByRole('button', { name: t('pages.download-session-results.button.label') })).exists(); | ||
}); | ||
|
||
test('should display the expiration error message', async function (assert) { | ||
// given | ||
requestManagerService.request.rejects({ status: 500 }); | ||
|
||
// when | ||
const screen = await render(hbs`<DownloadSessionResults @showErrorMessage={{this.showErrorMessage}} />`); | ||
const downloadButton = screen.getByRole('button', { name: t('pages.download-session-results.button.label') }); | ||
await click(downloadButton); | ||
|
||
// then | ||
assert.dom(screen.getByText(t('pages.download-session-results.errors.expiration'))).exists(); | ||
}); | ||
}); |
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