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

View File

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