clear form after adding (problem with category clearing)

This commit is contained in:
2025-05-20 18:26:50 +02:00
parent 00fbe8b655
commit 9962dc1e55
3 changed files with 20 additions and 13240 deletions

View File

@@ -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;

View File

@@ -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">

File diff suppressed because it is too large Load Diff