clear form after adding (problem with category clearing)
This commit is contained in:
@@ -33,9 +33,9 @@ export async function createNotice(notice) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.noticeId !== null) {
|
if (response.data.noticeId !== null) {
|
||||||
notice.image.forEach(imageUri => {
|
for (const imageUri of notice.image) {
|
||||||
uploadImage(response.data.noticeId, imageUri);
|
await uploadImage(response.data.noticeId, imageUri);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import {useRouter} from "expo-router";
|
|||||||
|
|
||||||
export default function CreateNotice() {
|
export default function CreateNotice() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {addNotice} = useNoticesStore();
|
const {addNotice, fetchNotices} = useNoticesStore();
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [price, setPrice] = useState("");
|
const [price, setPrice] = useState("");
|
||||||
@@ -103,6 +103,8 @@ export default function CreateNotice() {
|
|||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
console.log("Notice created successfully with ID: ", result.noticeId);
|
console.log("Notice created successfully with ID: ", result.noticeId);
|
||||||
|
await fetchNotices();
|
||||||
|
clearForm();
|
||||||
router.push("/(tabs)/notices");
|
router.push("/(tabs)/notices");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -141,6 +143,20 @@ export default function CreateNotice() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearForm = () => {
|
||||||
|
setTitle("");
|
||||||
|
setDescription("");
|
||||||
|
setPrice("");
|
||||||
|
setCategory("");
|
||||||
|
setImage([]);
|
||||||
|
setError({
|
||||||
|
title: false,
|
||||||
|
description: false,
|
||||||
|
price: false,
|
||||||
|
category: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView h="$80" w="$80">
|
<ScrollView h="$80" w="$80">
|
||||||
<FormControl className="p-4 border rounded-lg border-outline-300">
|
<FormControl className="p-4 border rounded-lg border-outline-300">
|
||||||
|
|||||||
13236
ArtisanConnect/package-lock.json
generated
13236
ArtisanConnect/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user