Skip to content

Commit

Permalink
Merge pull request #31520 from software-mansion-labs/ts-migration/exc…
Browse files Browse the repository at this point in the history
…eeded-comment-length
  • Loading branch information
cead22 authored Dec 18, 2023
2 parents e344aa0 + 790b602 commit d297354
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import PropTypes from 'prop-types';
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import Text from './Text';

const propTypes = {
shouldShowError: PropTypes.bool.isRequired,
};

const defaultProps = {};

function ExceededCommentLength(props) {
function ExceededCommentLength() {
const styles = useThemeStyles();
const {numberFormat, translate} = useLocalize();

if (!props.shouldShowError) {
return null;
}
return (
<Text
style={[styles.textMicro, styles.textDanger, styles.chatItemComposeSecondaryRow, styles.mlAuto, styles.pl2]}
Expand All @@ -28,8 +18,6 @@ function ExceededCommentLength(props) {
);
}

ExceededCommentLength.propTypes = propTypes;
ExceededCommentLength.defaultProps = defaultProps;
ExceededCommentLength.displayName = 'ExceededCommentLength';

export default ExceededCommentLength;
2 changes: 1 addition & 1 deletion src/components/LocaleContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type LocaleContextProps = {
translate: <TKey extends TranslationPaths>(phraseKey: TKey, ...phraseParameters: Localize.PhraseParameters<Localize.Phrase<TKey>>) => string;

/** Formats number formatted according to locale and options */
numberFormat: (number: number, options: Intl.NumberFormatOptions) => string;
numberFormat: (number: number, options?: Intl.NumberFormatOptions) => string;

/** Converts a datetime into a localized string representation that's relative to current moment in time */
datetimeToRelative: (datetime: string) => string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function ReportActionCompose({
>
{!isSmallScreenWidth && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}
<ReportTypingIndicator reportID={reportID} />
<ExceededCommentLength shouldShowError={hasExceededMaxCommentLength} />
{hasExceededMaxCommentLength && <ExceededCommentLength />}
</View>
</OfflineWithFeedback>
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function ReportActionItemMessageEdit(props) {
</View>
</View>
</View>
<ExceededCommentLength shouldShowError={hasExceededMaxCommentLength} />
{hasExceededMaxCommentLength && <ExceededCommentLength />}
</>
);
}
Expand Down

0 comments on commit d297354

Please sign in to comment.