Added card successfull upload message

This commit is contained in:
Dmitriy Shishkov 2020-09-23 20:45:19 +05:00
parent 11a7d10e38
commit 19a4b8b43c
No known key found for this signature in database
GPG Key ID: D76D70029F55183E
2 changed files with 6 additions and 6 deletions

View File

@ -17,9 +17,7 @@ type props = {
const UploadForm: React.FC<props> = ({ setLoading, token }) => {
const { push: historyPush } = useHistory();
const [errorStatus, setErrorStatus] = useState<IErrorStatus>({
successful: true
});
const [errorStatus, setErrorStatus] = useState<IErrorStatus>({});
useEffect(() => {
if (!token) {
@ -31,7 +29,7 @@ const UploadForm: React.FC<props> = ({ setLoading, token }) => {
<form
id="uploadForm"
onSubmit={(e) => {
setErrorStatus({ successful: true });
setErrorStatus({});
handleFormSubmit(
e,
'api/card/create',
@ -75,7 +73,9 @@ const UploadForm: React.FC<props> = ({ setLoading, token }) => {
<input type="file" name="image" id="image" />
</aside>
{!errorStatus.successful ? (
{errorStatus.successful ? (
<p className="successText">Успешно загружено</p>
) : errorStatus.successful === false ? (
<p className="errorText">{errorStatus.errorMessage}</p>
) : (
''

View File

@ -1,5 +1,5 @@
interface IErrorStatus {
successful: boolean;
successful?: boolean;
errorMessage?: string;
}