Skip to content

Commit

Permalink
fix/MINI-5698 separate userDetails and points button state (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
shohiebsense authored Dec 15, 2022
1 parent e08178d commit a0dcc9c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions js-miniapp-sample/src/pages/user-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,15 @@ function UserDetails(props: UserDetailsProps) {
const [state, dispatch] = useReducer(dataFetchReducer, initialState);
const classes = useStyles();

const buttonClassname = clsx({
[classes.buttonFailure]: state.isError,
[classes.buttonSuccess]: !state.isError,
});
const userDetailsButtonClassname = getButtonState(state.isError);
const pointsButtonClassname = getButtonState(state.isPointsError);

function getButtonState(isError: boolean) {
return clsx({
[classes.buttonFailure]: isError,
[classes.buttonSuccess]: !isError,
});
}

function requestUserDetails() {
const permissionsList = [
Expand Down Expand Up @@ -474,7 +479,7 @@ function UserDetails(props: UserDetailsProps) {
variant="contained"
color="primary"
classes={{ root: classes.button }}
className={buttonClassname}
className={userDetailsButtonClassname}
disabled={state.isLoading}
data-testid="fetchUserButton"
>
Expand Down Expand Up @@ -502,7 +507,7 @@ function UserDetails(props: UserDetailsProps) {
variant="contained"
color="primary"
classes={{ root: classes.button }}
className={buttonClassname}
className={pointsButtonClassname}
disabled={state.isPointsLoading}
data-testid="fetchPointsButton"
>
Expand Down

0 comments on commit a0dcc9c

Please sign in to comment.