Added card successfull upload message
This commit is contained in:
parent
11a7d10e38
commit
19a4b8b43c
@ -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>
|
||||||
) : (
|
) : (
|
||||||
''
|
''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
interface IErrorStatus {
|
interface IErrorStatus {
|
||||||
successful: boolean;
|
successful?: boolean;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user