Skip to content

Commit

Permalink
disable submit button and render offline indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Donahue committed May 27, 2022
1 parent 1d58296 commit 4765bdd
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/components/FormAlertWithSubmitButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import withLocalize, {withLocalizePropTypes} from './withLocalize';
import TextLink from './TextLink';
import Text from './Text';
import RenderHTML from './RenderHTML';
import OfflineIndicator from './OfflineIndicator';
import {withNetwork} from './OnyxProvider';

const propTypes = {
/** Whether to show the alert text */
Expand Down Expand Up @@ -95,6 +97,19 @@ const FormAlertWithSubmitButton = (props) => {
);
}

if (props.network.isOffline) {
return (
<View style={[styles.mh5, styles.mb5, styles.flex1, styles.justifyContentEnd, ...props.containerStyles]}>
<Button
success
isDisabled
text={props.buttonText}
/>
<OfflineIndicator />
</View>
);
}

return (
<View style={[styles.mh5, styles.mb5, styles.flex1, styles.justifyContentEnd, ...props.containerStyles]}>
{props.isAlertVisible && (
Expand All @@ -119,4 +134,7 @@ FormAlertWithSubmitButton.propTypes = propTypes;
FormAlertWithSubmitButton.defaultProps = defaultProps;
FormAlertWithSubmitButton.displayName = 'FormAlertWithSubmitButton';

export default withLocalize(FormAlertWithSubmitButton);
export default compose(
withLocalize,
withNetwork(),
)(FormAlertWithSubmitButton);

0 comments on commit 4765bdd

Please sign in to comment.