From 92ebbaa187d2be226650166e6165dae087d89404 Mon Sep 17 00:00:00 2001 From: Khairul Alam Licon Date: Tue, 3 Aug 2021 16:52:45 +0900 Subject: [PATCH] sample app ui fix: user details and points show wrong UI info (#150) * adopt point error * cleanup other states * address feedback * address feedback for permission reducer --- js-miniapp-sample/src/pages/user-details.js | 8 ++++---- js-miniapp-sample/src/services/permissions/reducers.js | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js-miniapp-sample/src/pages/user-details.js b/js-miniapp-sample/src/pages/user-details.js index 1008b4ac7..f32fb2d52 100644 --- a/js-miniapp-sample/src/pages/user-details.js +++ b/js-miniapp-sample/src/pages/user-details.js @@ -190,7 +190,7 @@ export const dataFetchReducer = (state: State, action: Action) => { return { ...initialState, isPointsLoading: false, - isError: true, + isPointsError: true, }; default: @@ -417,7 +417,7 @@ function UserDetails(props: UserDetailsProps) { disabled={true} className={classes.formInput} id="input-points-standard" - error={state.isError || hasDeniedPermission} + error={state.isPointsError || hasDeniedPermission} label={'Points (Standard)'} value={ hasDeniedPermission @@ -433,7 +433,7 @@ function UserDetails(props: UserDetailsProps) { disabled={true} className={classes.formInput} id="input-points-term" - error={state.isError || hasDeniedPermission} + error={state.isPointsError || hasDeniedPermission} label={'Points (Time-Limited)'} value={ hasDeniedPermission @@ -448,7 +448,7 @@ function UserDetails(props: UserDetailsProps) { disabled={true} className={classes.formInput} id="input-points-cash" - error={state.isError || hasDeniedPermission} + error={state.isPointsError || hasDeniedPermission} label={'Points (Rakuten Cash)'} value={ hasDeniedPermission diff --git a/js-miniapp-sample/src/services/permissions/reducers.js b/js-miniapp-sample/src/services/permissions/reducers.js index 2129f4c92..940a22c7b 100644 --- a/js-miniapp-sample/src/services/permissions/reducers.js +++ b/js-miniapp-sample/src/services/permissions/reducers.js @@ -11,11 +11,13 @@ const grantedPermissionsReducer = ( ): CustomPermissionName[] => { switch (action.type) { case REQUEST_PERMISSIONS_SUCCESS: - return action.permissions + const array = action.permissions .filter( (permission) => permission.status === CustomPermissionStatus.ALLOWED ) - .map((permission) => permission.name); + .map((permission) => permission.name) + .concat(state); + return Array.from(new Set(array)) default: return state; }