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) {
|
||||
notice.image.forEach(imageUri => {
|
||||
uploadImage(response.data.noticeId, imageUri);
|
||||
});
|
||||
for (const imageUri of notice.image) {
|
||||
await uploadImage(response.data.noticeId, imageUri);
|
||||
}
|
||||
}
|
||||
|
||||
return response.data;
|
||||
|
||||
@@ -27,7 +27,7 @@ import {useRouter} from "expo-router";
|
||||
|
||||
export default function CreateNotice() {
|
||||
const router = useRouter();
|
||||
const {addNotice} = useNoticesStore();
|
||||
const {addNotice, fetchNotices} = useNoticesStore();
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [price, setPrice] = useState("");
|
||||
@@ -103,6 +103,8 @@ export default function CreateNotice() {
|
||||
|
||||
if (result) {
|
||||
console.log("Notice created successfully with ID: ", result.noticeId);
|
||||
await fetchNotices();
|
||||
clearForm();
|
||||
router.push("/(tabs)/notices");
|
||||
}
|
||||
} 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 (
|
||||
<ScrollView h="$80" w="$80">
|
||||
<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