lbry-desktop/ui/component/publishFormErrors/view.jsx

59 lines
1.8 KiB
React
Raw Normal View History

// @flow
import React from 'react';
import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses';
import { isNameValid } from 'util/lbryURI';
2019-10-03 23:40:54 +02:00
import { INVALID_NAME_ERROR } from 'constants/claim';
type Props = {
title: ?string,
name: ?string,
bid: ?string,
bidError: ?string,
editingURI: ?string,
filePath: ?string,
isStillEditing: boolean,
uploadThumbnailStatus: string,
2021-04-16 04:52:41 +02:00
thumbnail: string,
thumbnailError: boolean,
waitForFile: boolean,
};
function PublishFormErrors(props: Props) {
const {
name,
title,
bid,
bidError,
editingURI,
filePath,
isStillEditing,
uploadThumbnailStatus,
2021-04-16 04:52:41 +02:00
thumbnail,
thumbnailError,
waitForFile,
} = props;
// These are extra help
// If there is an error it will be presented as an inline error as well
const isUploadingThumbnail = uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS;
const thumbnailUploaded = uploadThumbnailStatus === THUMBNAIL_STATUSES.COMPLETE && thumbnail;
return (
<div className="error__text">
{waitForFile && <div>{__('Choose a replay file, or select None')}</div>}
{!title && <div>{__('A title is required')}</div>}
{!name && <div>{__('A URL is required')}</div>}
2021-10-13 15:30:50 +02:00
{name && !isNameValid(name) && INVALID_NAME_ERROR}
{!bid && <div>{__('A deposit amount is required')}</div>}
{bidError && <div>{__('Please check your deposit amount.')}</div>}
{isUploadingThumbnail && <div>{__('Please wait for thumbnail to finish uploading')}</div>}
2022-09-20 00:39:45 +02:00
{thumbnailError && !thumbnailUploaded && <div>{__('Thumbnail is invalid.')}</div>}
2020-07-30 08:46:56 +02:00
{editingURI && !isStillEditing && !filePath && (
<div>{__('Please reselect a file after changing the LBRY URL')}</div>
)}
</div>
);
}
export default PublishFormErrors;