project-booster-vue 10.32.0 → 10.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/projects/project-hub/PbProjectHub.vue +1 -14
- package/src/components/projects/projects-list/PbProjectHub.vue +1 -14
- package/src/components/scenario/PbScenario-Demo-Project.stories.js +10 -10
- package/src/stores/state.ts +0 -2
- package/src/stores/store.ts +0 -2
- package/src/components/consent/PbConsent.vue +0 -147
- package/src/components/projects/project-hub/PbProjectHub-Features-Consent.stories.mdx +0 -123
- package/src/services/api/consentApi.ts +0 -27
- package/src/services/api/mocks/consentMock.js +0 -25
- package/src/stores/modules/consentStore.ts +0 -79
package/package.json
CHANGED
|
@@ -392,14 +392,7 @@
|
|
|
392
392
|
</m-flex>
|
|
393
393
|
</div>
|
|
394
394
|
</m-flex>
|
|
395
|
-
|
|
396
|
-
<div class="pb-project-hub__section-header">
|
|
397
|
-
<div class="pb-project-hub__section-title" ref="pbConsent">Souscription newsletter</div>
|
|
398
|
-
</div>
|
|
399
|
-
<div class="pb-project-hub__section-content">
|
|
400
|
-
<pb-consent />
|
|
401
|
-
</div>
|
|
402
|
-
</m-flex>
|
|
395
|
+
|
|
403
396
|
<m-flex
|
|
404
397
|
v-if="!readOnly"
|
|
405
398
|
class="pb-project-hub__section pb-project-hub__section-separator"
|
|
@@ -692,7 +685,6 @@ import PbEstimatesList from '../../estimates/PbEstimatesList.vue';
|
|
|
692
685
|
import PbLoader from '../../loader/PbLoader.vue';
|
|
693
686
|
import PbProjectAttributes from '../project-attributes/PbProjectAttributes.vue';
|
|
694
687
|
import PbRestitution from '../../restitution/PbRestitution.vue';
|
|
695
|
-
import PbConsent from '../../consent/PbConsent.vue';
|
|
696
688
|
import ESTIMATES_PAYLOAD from './../../estimates/estimates-payload.json';
|
|
697
689
|
import { Tool } from '@/types/pb/Tool';
|
|
698
690
|
import { Configuration } from '@/types/pb/Configuration';
|
|
@@ -761,7 +753,6 @@ export default defineComponent({
|
|
|
761
753
|
PbLoader,
|
|
762
754
|
PbProjectAttributes,
|
|
763
755
|
PbRestitution,
|
|
764
|
-
PbConsent,
|
|
765
756
|
PbAppointmentNotification,
|
|
766
757
|
},
|
|
767
758
|
|
|
@@ -884,10 +875,6 @@ export default defineComponent({
|
|
|
884
875
|
configurationsLoadError: 'getConfigurationsLoadError',
|
|
885
876
|
}),
|
|
886
877
|
|
|
887
|
-
...mapGetters('consent', {
|
|
888
|
-
isMailConsentDisplayed: 'isMailConsentDisplayed',
|
|
889
|
-
}),
|
|
890
|
-
|
|
891
878
|
...mapGetters('inhabitants', {
|
|
892
879
|
isInhabitantDisplayed: 'isInhabitantDisplayed',
|
|
893
880
|
currentInhabitantId: 'getCurrentInhabitantId',
|
|
@@ -393,14 +393,7 @@
|
|
|
393
393
|
</m-flex>
|
|
394
394
|
</div>
|
|
395
395
|
</m-flex>
|
|
396
|
-
|
|
397
|
-
<div class="pb-project-hub__section-header">
|
|
398
|
-
<div class="pb-project-hub__section-title" ref="pbConsent">Souscription newsletter</div>
|
|
399
|
-
</div>
|
|
400
|
-
<div class="pb-project-hub__section-content">
|
|
401
|
-
<pb-consent />
|
|
402
|
-
</div>
|
|
403
|
-
</m-flex>
|
|
396
|
+
|
|
404
397
|
<m-flex
|
|
405
398
|
v-if="!readOnly"
|
|
406
399
|
class="pb-project-hub__section pb-project-hub__section-separator"
|
|
@@ -702,7 +695,6 @@ import PbLoader from '../../loader/PbLoader.vue';
|
|
|
702
695
|
import PbMOpinion from '../../mopinion/PbMOpinion.vue';
|
|
703
696
|
import PbProjectAttributes from '../project-attributes/PbProjectAttributes.vue';
|
|
704
697
|
import PbRestitution from '../../restitution/PbRestitution.vue';
|
|
705
|
-
import PbConsent from '../../consent/PbConsent.vue';
|
|
706
698
|
import ESTIMATES_PAYLOAD from './../../estimates/estimates-payload.json';
|
|
707
699
|
import cloneDeep from 'lodash.clonedeep';
|
|
708
700
|
import { Tool } from '@/types/pb/Tool';
|
|
@@ -772,7 +764,6 @@ export default defineComponent({
|
|
|
772
764
|
PbMOpinion,
|
|
773
765
|
PbProjectAttributes,
|
|
774
766
|
PbRestitution,
|
|
775
|
-
PbConsent,
|
|
776
767
|
},
|
|
777
768
|
|
|
778
769
|
props: {
|
|
@@ -894,10 +885,6 @@ export default defineComponent({
|
|
|
894
885
|
configurationsLoadError: 'getConfigurationsLoadError',
|
|
895
886
|
}),
|
|
896
887
|
|
|
897
|
-
...mapGetters('consent', {
|
|
898
|
-
isMailConsentDisplayed: 'isMailConsentDisplayed',
|
|
899
|
-
}),
|
|
900
|
-
|
|
901
888
|
...mapGetters('inhabitants', {
|
|
902
889
|
isInhabitantDisplayed: 'isInhabitantDisplayed',
|
|
903
890
|
currentInhabitantId: 'getCurrentInhabitantId',
|
|
@@ -57,43 +57,43 @@ const generateStory =
|
|
|
57
57
|
|
|
58
58
|
export const estimateNewConstructionPrep = generateStory(
|
|
59
59
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/6e3e9d6d-a019-4c1c-8d25-002a4ebfcb46',
|
|
60
|
-
{ 'X-gateway-apikey': '
|
|
60
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
61
61
|
);
|
|
62
62
|
export const estimateDressingPrep = generateStory(
|
|
63
63
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/10df6aa4-4ae0-41a0-93e3-dc66eb9d39c8',
|
|
64
|
-
{ 'X-gateway-apikey': '
|
|
64
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
65
65
|
);
|
|
66
66
|
export const estimateBookcasePrep = generateStory(
|
|
67
67
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/88d96e4c-685b-4275-8eae-f50828fe4755',
|
|
68
|
-
{ 'X-gateway-apikey': '
|
|
68
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
69
69
|
);
|
|
70
70
|
export const estimateKitchenPrep = generateStory(
|
|
71
71
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/068160b2-b28a-46fa-8fd6-4775450fa7b4',
|
|
72
|
-
{ 'X-gateway-apikey': '
|
|
72
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
73
73
|
);
|
|
74
74
|
export const estimateInsulationPrep = generateStory(
|
|
75
75
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/60100496-92ea-49ab-8a43-c08afa57cd60',
|
|
76
|
-
{ 'X-gateway-apikey': '
|
|
76
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
77
77
|
);
|
|
78
78
|
export const estimateTvPrep = generateStory(
|
|
79
79
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/dc5370cf-0761-43a0-8309-ced76be08d8b',
|
|
80
|
-
{ 'X-gateway-apikey': '
|
|
80
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
81
81
|
);
|
|
82
82
|
export const estimateStoragePrep = generateStory(
|
|
83
83
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/e39126db-03f7-4b07-975a-97b4cf603ef1',
|
|
84
|
-
{ 'X-gateway-apikey': '
|
|
84
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
85
85
|
);
|
|
86
86
|
export const estimateHeatingPrep = generateStory(
|
|
87
87
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/eaba8264-620d-475e-830f-89166b49a667',
|
|
88
|
-
{ 'X-gateway-apikey': '
|
|
88
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
89
89
|
);
|
|
90
90
|
export const estimateBathroomPrep = generateStory(
|
|
91
91
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/c9c4df50-cbcb-4265-b9a7-6645d3adb03b',
|
|
92
|
-
{ 'X-gateway-apikey': '
|
|
92
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
93
93
|
);
|
|
94
94
|
export const estimateFloorPrep = generateStory(
|
|
95
95
|
'https://ccdp-prep.priv.nprd.api.devportal.adeo.cloud/api-project-booster-budget-estimate/v1/scenarios/LMFR_FLOOR',
|
|
96
|
-
{ 'X-gateway-apikey': '
|
|
96
|
+
{ 'X-gateway-apikey': 'XXXX' },
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
export const projectDeclarationGenericPrep = generateStory(
|
package/src/stores/state.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AppointmentQualificationState } from '@/stores/modules/appointmentQualificationStore';
|
|
2
2
|
import { ConfigurationsState } from '@/stores/modules/configurationsStore';
|
|
3
|
-
import { ConsentState } from '@/stores/modules/consentStore';
|
|
4
3
|
import { EstimatesState } from '@/stores/modules/estimatesStore';
|
|
5
4
|
import { InhabitantsState } from '@/stores/modules/inhabitantsStore';
|
|
6
5
|
import { MetaDataState } from '@/stores/modules/metaDataStore';
|
|
@@ -11,7 +10,6 @@ import { TrezorState } from './modules/trezorStore';
|
|
|
11
10
|
export interface State {
|
|
12
11
|
appointmentQualification: AppointmentQualificationState;
|
|
13
12
|
configurations: ConfigurationsState;
|
|
14
|
-
consent: ConsentState;
|
|
15
13
|
estimates: EstimatesState;
|
|
16
14
|
inhabitants: InhabitantsState;
|
|
17
15
|
metaData: MetaDataState;
|
package/src/stores/store.ts
CHANGED
|
@@ -6,7 +6,6 @@ import metadataStore from './modules/metaDataStore';
|
|
|
6
6
|
import projectsStore from './modules/projectsStore';
|
|
7
7
|
import toolsStore from './modules/toolsStore';
|
|
8
8
|
import documentsStore from './modules/documentsStore';
|
|
9
|
-
import consentStore from './modules/consentStore';
|
|
10
9
|
import productsStore from './modules/productsStore';
|
|
11
10
|
import trezorStore from './modules/trezorStore';
|
|
12
11
|
import timifyStore from './modules/timifyStore';
|
|
@@ -26,7 +25,6 @@ export default {
|
|
|
26
25
|
documents: cloneDeep(documentsStore),
|
|
27
26
|
documentsPlans: cloneDeep(documentsStore),
|
|
28
27
|
documentsPictures: cloneDeep(documentsStore),
|
|
29
|
-
consent: consentStore,
|
|
30
28
|
products: productsStore,
|
|
31
29
|
trezor: trezorStore,
|
|
32
30
|
timify: timifyStore,
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<m-flex direction="column" full-width class="pb-consent">
|
|
3
|
-
<span class="pb-consent__label">
|
|
4
|
-
Faites le plein d’inspirations et de promotions pour votre projet chaque semaine en vous abonnant à notre
|
|
5
|
-
newsletter
|
|
6
|
-
</span>
|
|
7
|
-
<m-flex
|
|
8
|
-
v-if="isMailConsentUpdating"
|
|
9
|
-
class="pb-consent__loading"
|
|
10
|
-
direction="column"
|
|
11
|
-
align-items="center"
|
|
12
|
-
justify-content="center"
|
|
13
|
-
align-content="center"
|
|
14
|
-
>
|
|
15
|
-
<pb-animable-loader class="pb-consent__loading-loader" />
|
|
16
|
-
<div class="pb-consent__loading-label">Chargement...</div>
|
|
17
|
-
</m-flex>
|
|
18
|
-
<m-flex v-else class="pb-consent__actions">
|
|
19
|
-
<m-button
|
|
20
|
-
class="pb-consent__actions--button"
|
|
21
|
-
label="S'abonner à la newsletter"
|
|
22
|
-
theme="bordered"
|
|
23
|
-
@click="handleUpdateConsent"
|
|
24
|
-
v-if="!errorUpdateMailConsent && !isMailConsentUpdated"
|
|
25
|
-
/>
|
|
26
|
-
<m-notification
|
|
27
|
-
v-if="isMailConsentUpdated"
|
|
28
|
-
class="pb-consent__actions--notification"
|
|
29
|
-
type="success"
|
|
30
|
-
text="Merci, votre inscription à la newsletter est confirmée"
|
|
31
|
-
/>
|
|
32
|
-
<m-notification
|
|
33
|
-
v-if="errorUpdateMailConsent"
|
|
34
|
-
class="pb-consent__actions--notification"
|
|
35
|
-
type="warning"
|
|
36
|
-
text="Une erreur est survenue"
|
|
37
|
-
link-label="Merci de réessayer"
|
|
38
|
-
@link-click="handleRetry"
|
|
39
|
-
/>
|
|
40
|
-
</m-flex>
|
|
41
|
-
</m-flex>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
import { computed, defineComponent, onMounted } from 'vue';
|
|
46
|
-
import { useStore } from 'vuex';
|
|
47
|
-
import MButton from '../mozaic/buttons/MButton.vue';
|
|
48
|
-
import MFlex from '../mozaic/flex/MFlex.vue';
|
|
49
|
-
import MNotification from '../mozaic/notifications/MNotification.vue';
|
|
50
|
-
import PbAnimableLoader from '../loader/PbAnimableLoader.vue';
|
|
51
|
-
|
|
52
|
-
export default defineComponent({
|
|
53
|
-
name: 'PbConsent',
|
|
54
|
-
|
|
55
|
-
components: {
|
|
56
|
-
MButton,
|
|
57
|
-
MFlex,
|
|
58
|
-
MNotification,
|
|
59
|
-
PbAnimableLoader,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
setup() {
|
|
63
|
-
const store = useStore();
|
|
64
|
-
const isMailConsentUpdating = computed(() => store.getters['consent/isMailConsentUpdating']);
|
|
65
|
-
const isMailConsentUpdated = computed(() => store.getters['consent/isMailConsentUpdated']);
|
|
66
|
-
const errorUpdateMailConsent = computed(() => store.getters['consent/getErrorUpdateMailConsent']);
|
|
67
|
-
|
|
68
|
-
const handleUpdateConsent = () => {
|
|
69
|
-
store.dispatch('sendEventToBus', {
|
|
70
|
-
code: 'UPDATE-MAIL-CONSENT',
|
|
71
|
-
payload: {},
|
|
72
|
-
});
|
|
73
|
-
store.dispatch('consent/updateMailConsent');
|
|
74
|
-
|
|
75
|
-
setTimeout(() => {
|
|
76
|
-
if (isMailConsentUpdated.value) {
|
|
77
|
-
store.dispatch('consent/setMailConsentDisplayed', false);
|
|
78
|
-
}
|
|
79
|
-
}, 2000);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const handleRetry = () => {
|
|
83
|
-
store.dispatch('sendEventToBus', {
|
|
84
|
-
code: 'RETRY-UPDATE-MAIL-CONSENT',
|
|
85
|
-
payload: {},
|
|
86
|
-
});
|
|
87
|
-
store.dispatch('consent/updateMailConsent');
|
|
88
|
-
|
|
89
|
-
setTimeout(() => {
|
|
90
|
-
if (isMailConsentUpdated.value) {
|
|
91
|
-
store.dispatch('consent/setMailConsentDisplayed', false);
|
|
92
|
-
}
|
|
93
|
-
}, 2000);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
onMounted(() => {
|
|
97
|
-
store.dispatch('sendEventToBus', {
|
|
98
|
-
code: 'DISPLAY-MAIL-CONSENT',
|
|
99
|
-
payload: {},
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
isMailConsentUpdating,
|
|
105
|
-
isMailConsentUpdated,
|
|
106
|
-
errorUpdateMailConsent,
|
|
107
|
-
handleUpdateConsent,
|
|
108
|
-
handleRetry,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
</script>
|
|
113
|
-
|
|
114
|
-
<style lang="scss" scoped>
|
|
115
|
-
@import 'pb-variables';
|
|
116
|
-
|
|
117
|
-
.pb-consent {
|
|
118
|
-
&__label {
|
|
119
|
-
@include set-font-face('regular');
|
|
120
|
-
@include set-font-scale('06', 'm');
|
|
121
|
-
|
|
122
|
-
color: $color-grey-900;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
&__actions {
|
|
126
|
-
width: 100%;
|
|
127
|
-
|
|
128
|
-
&--notification {
|
|
129
|
-
width: 100%;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
&--button {
|
|
133
|
-
margin-top: $mu150;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
&__loading {
|
|
138
|
-
margin: auto;
|
|
139
|
-
padding-top: $mu100;
|
|
140
|
-
|
|
141
|
-
&-loader {
|
|
142
|
-
height: $mu300;
|
|
143
|
-
width: $mu300;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
</style>
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Story, Meta, Canvas } from '@storybook/addon-docs';
|
|
2
|
-
import { nestedAppDecorator } from '../../../../.storybook/nested-app-decorator';
|
|
3
|
-
import PbProjectHub from './PbProjectHub';
|
|
4
|
-
import store from '../../../stores/store';
|
|
5
|
-
import { rest } from 'msw';
|
|
6
|
-
import { internalServerErrorResolver } from '../../../services/api/mocks/commonMock';
|
|
7
|
-
import { getProjectByIdResolver } from '../../../services/api/mocks/projectsMock';
|
|
8
|
-
import {
|
|
9
|
-
getMailConsentToUpdateResolver,
|
|
10
|
-
getMailConsentUpdatedResolver,
|
|
11
|
-
putConsentsUpdateResolver,
|
|
12
|
-
putConsentsUpdateWithDelayResolver,
|
|
13
|
-
} from '../../../services/api/mocks/consentMock';
|
|
14
|
-
|
|
15
|
-
<Meta
|
|
16
|
-
title="Project Booster/Components/Projects/PbProjectHub 🦠/Features/Consent (Mail)"
|
|
17
|
-
component={PbProjectHub}
|
|
18
|
-
parameters={{
|
|
19
|
-
layout: 'fullscreen',
|
|
20
|
-
}}
|
|
21
|
-
decorators={[
|
|
22
|
-
nestedAppDecorator(store, [
|
|
23
|
-
{
|
|
24
|
-
name: 'ProjectHub',
|
|
25
|
-
path: '/',
|
|
26
|
-
component: PbProjectHub,
|
|
27
|
-
beforeEnter: async (to, from, next, store) => {
|
|
28
|
-
store.dispatch('projects/loadProject', '001');
|
|
29
|
-
store.dispatch('consent/checkMailConsent');
|
|
30
|
-
next();
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
]),
|
|
34
|
-
]}
|
|
35
|
-
/>
|
|
36
|
-
|
|
37
|
-
export const TemplateSandbox = (args, { argTypes }) => ({
|
|
38
|
-
props: Object.keys(argTypes),
|
|
39
|
-
template: `<div style="margin: 0 auto;min-height: 100vh;width: 100%;">
|
|
40
|
-
<router-view v-slot="{ Component }">
|
|
41
|
-
<component :is="Component" :key="$route.fullPath" />
|
|
42
|
-
</router-view>
|
|
43
|
-
</div>`,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
# 🦠 `PbProjectHub` - Component
|
|
47
|
-
|
|
48
|
-
The `PbProjectHub` component to access your project.
|
|
49
|
-
|
|
50
|
-
## Showcase with consent section to display
|
|
51
|
-
|
|
52
|
-
<Canvas>
|
|
53
|
-
<Story
|
|
54
|
-
name="Showcase with consent section"
|
|
55
|
-
parameters={{
|
|
56
|
-
controls: { disable: true },
|
|
57
|
-
msw: [
|
|
58
|
-
rest.get('/api/inhabitant-projects/:projectId', getProjectByIdResolver),
|
|
59
|
-
rest.get('/api/users/current/consents', getMailConsentToUpdateResolver),
|
|
60
|
-
rest.put('/api/users/current/consents', putConsentsUpdateResolver),
|
|
61
|
-
],
|
|
62
|
-
}}
|
|
63
|
-
height="100vh"
|
|
64
|
-
>
|
|
65
|
-
{TemplateSandbox.bind({})}
|
|
66
|
-
</Story>
|
|
67
|
-
</Canvas>
|
|
68
|
-
|
|
69
|
-
## Showcase with consent section to hide
|
|
70
|
-
|
|
71
|
-
<Canvas>
|
|
72
|
-
<Story
|
|
73
|
-
name="Showcase with consent section hidden"
|
|
74
|
-
parameters={{
|
|
75
|
-
controls: { disable: true },
|
|
76
|
-
msw: [
|
|
77
|
-
rest.get('/api/inhabitant-projects/:projectId', getProjectByIdResolver),
|
|
78
|
-
rest.get('/api/users/current/consents', getMailConsentUpdatedResolver),
|
|
79
|
-
],
|
|
80
|
-
}}
|
|
81
|
-
height="100vh"
|
|
82
|
-
>
|
|
83
|
-
{TemplateSandbox.bind({})}
|
|
84
|
-
</Story>
|
|
85
|
-
</Canvas>
|
|
86
|
-
|
|
87
|
-
## Showcase with failure on update consent
|
|
88
|
-
|
|
89
|
-
<Canvas>
|
|
90
|
-
<Story
|
|
91
|
-
name="Showcase with update failure"
|
|
92
|
-
parameters={{
|
|
93
|
-
controls: { disable: true },
|
|
94
|
-
msw: [
|
|
95
|
-
rest.get('/api/inhabitant-projects/:projectId', getProjectByIdResolver),
|
|
96
|
-
rest.get('/api/users/current/consents', getMailConsentToUpdateResolver),
|
|
97
|
-
rest.put('/api/users/current/consents', internalServerErrorResolver),
|
|
98
|
-
],
|
|
99
|
-
}}
|
|
100
|
-
height="100vh"
|
|
101
|
-
>
|
|
102
|
-
{TemplateSandbox.bind({})}
|
|
103
|
-
</Story>
|
|
104
|
-
</Canvas>
|
|
105
|
-
|
|
106
|
-
## Showcase with delay on update
|
|
107
|
-
|
|
108
|
-
<Canvas>
|
|
109
|
-
<Story
|
|
110
|
-
name="Showcase with delay on update"
|
|
111
|
-
parameters={{
|
|
112
|
-
controls: { disable: true },
|
|
113
|
-
msw: [
|
|
114
|
-
rest.get('/api/inhabitant-projects/:projectId', getProjectByIdResolver),
|
|
115
|
-
rest.get('/api/users/current/consents', getMailConsentToUpdateResolver),
|
|
116
|
-
rest.put('/api/users/current/consents', putConsentsUpdateWithDelayResolver),
|
|
117
|
-
],
|
|
118
|
-
}}
|
|
119
|
-
height="100vh"
|
|
120
|
-
>
|
|
121
|
-
{TemplateSandbox.bind({})}
|
|
122
|
-
</Story>
|
|
123
|
-
</Canvas>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { escape } from '../../services/htmlEscape';
|
|
2
|
-
import { createProjectBoosterApiClient } from './apiConfigUtils';
|
|
3
|
-
|
|
4
|
-
export const clientApi = createProjectBoosterApiClient();
|
|
5
|
-
|
|
6
|
-
export const updateConsentApiClient = (config: { apiKey: string; baseUrl: string }) => {
|
|
7
|
-
if (config.apiKey) {
|
|
8
|
-
clientApi.defaults.headers.common['X-ClientApiKey'] = config.apiKey;
|
|
9
|
-
}
|
|
10
|
-
if (config.baseUrl) {
|
|
11
|
-
clientApi.defaults.baseURL = config.baseUrl;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const getConsents = async () => {
|
|
16
|
-
const response = await clientApi.get('/users/current/consents');
|
|
17
|
-
|
|
18
|
-
return JSON.parse(
|
|
19
|
-
JSON.stringify(response.data).replace(/:"([^"]+)"/g, (match, $1) => {
|
|
20
|
-
return `: "${escape($1)}"`;
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const updateMailConsent = async (mailConsent: boolean) => {
|
|
26
|
-
return await clientApi.put('/users/current/consents', { mail: mailConsent });
|
|
27
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const getMailConsentToUpdateResolver = (req, res, ctx) => {
|
|
2
|
-
return res.once(
|
|
3
|
-
ctx.status(200),
|
|
4
|
-
ctx.json({
|
|
5
|
-
mail: false,
|
|
6
|
-
}),
|
|
7
|
-
);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const getMailConsentUpdatedResolver = (req, res, ctx) => {
|
|
11
|
-
return res.once(
|
|
12
|
-
ctx.status(200),
|
|
13
|
-
ctx.json({
|
|
14
|
-
mail: true,
|
|
15
|
-
}),
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const putConsentsUpdateResolver = (req, res, ctx) => {
|
|
20
|
-
return res.once(ctx.status(204));
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const putConsentsUpdateWithDelayResolver = (req, res, ctx) => {
|
|
24
|
-
return res.once(ctx.delay(1000), ctx.status(204));
|
|
25
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { updateMailConsent, getConsents } from '../../services/api/consentApi';
|
|
2
|
-
import { ActionContext } from 'vuex';
|
|
3
|
-
import { State } from '../state';
|
|
4
|
-
|
|
5
|
-
export interface ConsentState {
|
|
6
|
-
isMailConsentDisplayed: boolean;
|
|
7
|
-
isMailConsentUpdated: boolean;
|
|
8
|
-
isMailConsentUpdating: boolean;
|
|
9
|
-
errorUpdateMailConsent: Error;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type ConsentContext = ActionContext<ConsentState, State>;
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
namespaced: true,
|
|
16
|
-
|
|
17
|
-
state: {
|
|
18
|
-
isMailConsentDisplayed: false,
|
|
19
|
-
isMailConsentUpdated: false,
|
|
20
|
-
isMailConsentUpdating: false,
|
|
21
|
-
errorUpdateMailConsent: null,
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
getters: {
|
|
25
|
-
isMailConsentDisplayed(state: ConsentState) {
|
|
26
|
-
return state.isMailConsentDisplayed;
|
|
27
|
-
},
|
|
28
|
-
isMailConsentUpdated(state: ConsentState) {
|
|
29
|
-
return state.isMailConsentUpdated;
|
|
30
|
-
},
|
|
31
|
-
getErrorUpdateMailConsent(state: ConsentState) {
|
|
32
|
-
return state.errorUpdateMailConsent;
|
|
33
|
-
},
|
|
34
|
-
isMailConsentUpdating(state: ConsentState) {
|
|
35
|
-
return state.isMailConsentUpdating;
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
mutations: {
|
|
40
|
-
setIsMailConsentDisplayed(state: ConsentState, isDisplayed: boolean) {
|
|
41
|
-
state.isMailConsentDisplayed = isDisplayed;
|
|
42
|
-
},
|
|
43
|
-
setIsMailConsentUpdated(state: ConsentState, isUpdated: boolean) {
|
|
44
|
-
state.isMailConsentUpdated = isUpdated;
|
|
45
|
-
},
|
|
46
|
-
setErrorUpdateMailConsent(state: ConsentState, error: Error) {
|
|
47
|
-
state.errorUpdateMailConsent = error;
|
|
48
|
-
},
|
|
49
|
-
setIsMailConsentUpdating(state: ConsentState, isUpdating: boolean) {
|
|
50
|
-
state.isMailConsentUpdating = isUpdating;
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
actions: {
|
|
55
|
-
async checkMailConsent({ commit }: ConsentContext) {
|
|
56
|
-
try {
|
|
57
|
-
const consents = await getConsents();
|
|
58
|
-
if (!consents.mail) {
|
|
59
|
-
commit('setIsMailConsentDisplayed', true);
|
|
60
|
-
}
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error(error);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
setMailConsentDisplayed({ commit }: ConsentContext, isDisplayed: boolean) {
|
|
66
|
-
commit('setIsMailConsentDisplayed', isDisplayed);
|
|
67
|
-
},
|
|
68
|
-
async updateMailConsent({ commit }: ConsentContext) {
|
|
69
|
-
commit('setIsMailConsentUpdating', true);
|
|
70
|
-
try {
|
|
71
|
-
await updateMailConsent(true);
|
|
72
|
-
commit('setIsMailConsentUpdated', true);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
commit('setErrorUpdateMailConsent', error);
|
|
75
|
-
}
|
|
76
|
-
commit('setIsMailConsentUpdating', false);
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|