Skip to content

Commit

Permalink
sample app ui fix: user details and points show wrong UI info (#150)
Browse files Browse the repository at this point in the history
* adopt point error

* cleanup other states

* address feedback

* address feedback for permission reducer
  • Loading branch information
khairul-alam-licon authored Aug 3, 2021
1 parent 7462434 commit 92ebbaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions js-miniapp-sample/src/pages/user-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const dataFetchReducer = (state: State, action: Action) => {
return {
...initialState,
isPointsLoading: false,
isError: true,
isPointsError: true,
};

default:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions js-miniapp-sample/src/services/permissions/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 92ebbaa

Please sign in to comment.