-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service-message): change service message when there is at least …
…one notice ont tab
- Loading branch information
Showing
12 changed files
with
70 additions
and
50 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
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 |
---|---|---|
@@ -1,27 +1,36 @@ | ||
import { put, select } from 'redux-saga/effects'; | ||
import { showServiceMessage, TabAction } from 'app/actions'; | ||
import * as R from 'ramda'; | ||
import { showServiceMessage } from 'app/actions'; | ||
import { areTosAccepted } from '../selectors/prefs'; | ||
import { getNbSubscriptions } from '../selectors/subscriptions.selectors'; | ||
import Tab from 'app/lmem/tab'; | ||
|
||
export default function* serviceMessageSaga(tabAction: TabAction) { | ||
export const buildMessages = (messages: string[], nbNotices = 0): string[] => { | ||
const firstMessage = | ||
nbNotices > 0 | ||
? 'Il existe une bulle sur cette page. Pour la visualiser, veuillez finaliser votre configuration.' | ||
: 'Pour poster et recevoir des messages, veuillez finaliser votre configuration.'; | ||
|
||
return R.prepend(firstMessage, messages); | ||
}; | ||
|
||
export default function* serviceMessageSaga(tab: Tab, nbNotices = 0) { | ||
const tosAccepted = yield select(areTosAccepted); | ||
const nbSubscriptions = yield select(getNbSubscriptions); | ||
|
||
if (!tosAccepted) { | ||
yield put( | ||
showServiceMessage( | ||
"Pour voir des bulles ou en créer, merci d'accepter les Conditions Générales d'Utilisation.", | ||
tabAction.meta.tab, | ||
{ label: 'Lire et accepter les CGU', url: '/onboarding' } | ||
) | ||
showServiceMessage(buildMessages([], nbNotices), tab, { | ||
label: 'Lire et accepter les CGU', | ||
url: '/onboarding' | ||
}) | ||
); | ||
} else if (tosAccepted && nbSubscriptions === 0) { | ||
yield put( | ||
showServiceMessage( | ||
'Abonnez vous à des contributeurs pour recevoir leurs messages.', | ||
tabAction.meta.tab, | ||
{ label: "M'abonner", url: '/onboarding/subscribe' } | ||
) | ||
showServiceMessage(buildMessages([], nbNotices), tab, { | ||
label: 'Choisir mes contributeurs', | ||
url: '/settings/suggestions' | ||
}) | ||
); | ||
} | ||
} |
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
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
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
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