image upload and keep if not changed

This commit is contained in:
Julian Krauser 2025-04-30 10:43:11 +02:00
parent 91ede95530
commit 939c982c40
2 changed files with 16 additions and 8 deletions

View file

@ -74,10 +74,14 @@ export const useSettingStore = defineStore("setting", {
return res;
});
},
async uploadImage(data: { key: "club.logo" | "club.icon"; value?: File }[]): Promise<AxiosResponse<any, any>> {
async uploadImage(
data: { key: "club.logo" | "club.icon"; value?: File | "keep" }[]
): Promise<AxiosResponse<any, any>> {
const formData = new FormData();
for (let entry of data) {
if (entry.value) formData.append(entry.key, entry.value);
if (entry.value) {
formData.append(typeof entry.value == "string" ? entry.key : entry.key.split(".")[1], entry.value);
}
}
return await http
.put("/admin/setting/images", formData, {