diff --git a/nextjs/Dockerfile b/nextjs/Dockerfile
index a6d55876d..693651041 100644
--- a/nextjs/Dockerfile
+++ b/nextjs/Dockerfile
@@ -14,5 +14,5 @@ RUN apk add --no-cache bash
RUN apk add --no-cache yarn
-CMD cd /home/app/nextjs && yarn cache dir && yarn cache clean && yarn build && pm2 startOrReload ecosystem.config.js --env production --no-daemon
+CMD cd /home/app/nextjs && yarn cache dir && yarn cache clean && yarn install && yarn build && pm2 startOrReload ecosystem.config.js --env production --no-daemon
diff --git a/nextjs/components/atoms/Webpush.js b/nextjs/components/atoms/Webpush.js
index 60113dd83..48b5e491f 100644
--- a/nextjs/components/atoms/Webpush.js
+++ b/nextjs/components/atoms/Webpush.js
@@ -35,7 +35,7 @@ class WebPush extends Component {
constructor(props) {
super(props)
- }
+ }
componentDidMount() {
if (swRegistration === null) {
@@ -44,12 +44,12 @@ class WebPush extends Component {
}
UNSAFE_componentWillReceiveProps(nextProps) {
+ console.log("isUserSubscribedToPush ::: " + nextProps.isUserSubscribedToPush);
if (this.props.subscriveUserEnabled != nextProps.subscriveUserEnabled && nextProps.subscriveUserEnabled) {
this.onSubscribeUser()
}
-
- if(!!nextProps.isUserSubscribedToPush){
- this.setState({on: true})
+ if (!!nextProps.isUserSubscribedToPush) {
+ this.setState({ on: true })
}
}
@@ -80,99 +80,97 @@ class WebPush extends Component {
}
}
-onSubscribeUser = () => {
- if (swRegistration == null) {
- return
+ onSubscribeUser = () => {
+ if (swRegistration == null) {
+ return
+ }
+
+ swRegistration.pushManager.getSubscription()
+ .then((subscription) => {
+ var isSubscribed = !(subscription === null)
+ if (isSubscribed) {
+ this.onUpdateSubscriptionOnServer(subscription)
+ } else {
+ const applicationServerKey = urlB64ToUint8Array(applicationServerPublicKey)
+ swRegistration.pushManager.subscribe({
+ userVisibleOnly: true,
+ applicationServerKey: applicationServerKey
+ })
+ .then((subscription) => {
+ console.log('User is subscribed.')
+ if (this.onUpdateSubscriptionOnServer) {
+ this.onUpdateSubscriptionOnServer(subscription)
+ }
+ })
+ .catch((err) => {
+ console.log('Failed to subscribe the user: ', err)
+ if (onSubscribeFailed) {
+ this.onSubscriptionFailed(err)
+ }
+ });
+ }
+ })
}
- swRegistration.pushManager.getSubscription()
- .then((subscription) => {
- var isSubscribed = !(subscription === null)
- if (isSubscribed) {
- this.onUpdateSubscriptionOnServer(subscription)
- } else {
- const applicationServerKey = urlB64ToUint8Array(applicationServerPublicKey)
- swRegistration.pushManager.subscribe({
- userVisibleOnly: true,
- applicationServerKey: applicationServerKey
- })
- .then((subscription) => {
- console.log('User is subscribed.')
- if (this.onUpdateSubscriptionOnServer) {
- this.onUpdateSubscriptionOnServer(subscription)
- }
- })
- .catch((err) => {
- console.log('Failed to subscribe the user: ', err)
- if (onSubscribeFailed) {
- this.onSubscriptionFailed(err)
- }
- });
- }
- })
-}
+ onUnSubscribeUser = () => {
+ swRegistration.pushManager.getSubscription()
-onUnSubscribeUser = () => {
- swRegistration.pushManager.getSubscription()
+ .then((subscription) => {
+ if (subscription) {
- .then((subscription) => {
- if (subscription) {
+ return subscription.unsubscribe();
+ }
+ })
+ .then(() =>
+ this.setState(({ on }) => ({ on: false })))
+ //TODO: facultatif update DB
+ // .then(() => {
+ // return fetch(//, {
+ // method: 'POST',
+ // headers: {
+ // 'Content-Type': 'application/json'
+ // },
+ // body: JSON.stringify(subscription)
+ // })
+ // .then((response) => {
+ // if (!response.ok) {
+ // throw new Error('Bad status code from server.');
+ // }
+ // ///TODO bind UI
+ // return true;
+ // })
- return subscription.unsubscribe();
- }
- })
- .then(() =>
- this.setState(({ on }) => ({ on: false })))
- //TODO: facultatif update DB
- // .then(() => {
- // return fetch(//, {
- // method: 'POST',
- // headers: {
- // 'Content-Type': 'application/json'
- // },
- // body: JSON.stringify(subscription)
- // })
- // .then((response) => {
- // if (!response.ok) {
- // throw new Error('Bad status code from server.');
- // }
- // ///TODO bind UI
- // return true;
- // })
+ // })
+ .catch((err) => {
+ console.error('Failed to unsubscribe the user.', err);
- // })
- .catch((err) => {
- console.error('Failed to unsubscribe the user.', err);
+ });
+ }
- });
-}
+ onRegisterServiceWorker = () => {
+ navigator.serviceWorker.register('/static/js/Edeclic-service-worker.js')
+ .then(function (swReg) {
+ console.info('Service Worker is registered', swReg);
-onRegisterServiceWorker = () => {
- navigator.serviceWorker.register('/static/js/Edeclic-service-worker.js')
- .then(function (swReg) {
- console.info('Service Worker is registered', swReg);
+ swRegistration = swReg;
+ })
+ }
- swRegistration = swReg;
- })
-}
-
-render() {
- return ()
-}
+ render() {
+ return ()
+ }
}
WebPush.propTypes = {
}
function mapStateToProps(state) {
-
-
return {
- isUserSubscribedToPush: state.isUserSubscribedToPush
-};
+ isUserSubscribedToPush: state.user.isUserSubscribedToPush
+ };
}
export default connect(mapStateToProps, { subscribeUserToPushRequest })(WebPush);
diff --git a/nextjs/out/sitemap_local.xml b/nextjs/out/sitemap_local.xml
index 00914726b..cb6ca7a18 100644
--- a/nextjs/out/sitemap_local.xml
+++ b/nextjs/out/sitemap_local.xml
@@ -8,7 +8,7 @@
2019-09-17
,
https://app.talentstube.com/Confidentialite
- 2019-10-18
+ 2019-11-04
,
https://app.talentstube.com/Entreprises
2019-09-17
@@ -20,7 +20,7 @@
2019-10-14
,
https://app.talentstube.com/MentionsLegales
- 2019-10-18
+ 2019-11-04
,
https://app.talentstube.com/Offres
2019-10-16
diff --git a/nextjs/package.json b/nextjs/package.json
index 7ca331421..7a4e3e865 100644
--- a/nextjs/package.json
+++ b/nextjs/package.json
@@ -69,6 +69,7 @@
"dev": "cross-env PORT=3000 node server.js",
"build": "next build && yarn postExport && yarn copysw && yarn copySiteMap",
"start": "cross-env PORT=8000 NODE_ENV=production node server.js",
+ "startPreprod": "cross-env PORT=8000 NODE_ENV=preproduction node server.js",
"pm2-prod": "yarn build && pm2 start --name 'next' -- start",
"bs": "yarn build && yarn start",
"test": "yarn cypress run",
diff --git a/nextjs/reducers/user.js b/nextjs/reducers/user.js
index fff179ee6..10e655059 100644
--- a/nextjs/reducers/user.js
+++ b/nextjs/reducers/user.js
@@ -181,19 +181,20 @@ export function user(state = {
return {
...state,
loading: false,
- pushSubscribed: true
+ isUserSubscribedToPush: true
}
case SUBSCRIBE_USER_TO_PUSH_FAILURE:
return {
...state,
loading: false,
- pushSubscribed: false,
+ isUserSubscribedToPush: false,
errors: action.err,
}
case FETCH_USER_SUBSCRIPTION_TO_PUSH_REQUEST:
return {
...state,
loading: true,
+ isUserSubscribedToPush: false,
}
case FETCH_USER_SUBSCRIPTION_TO_PUSH_SUCCESS:
return {