Refactor receipt handling by removing status options from the server-side logic and simplifying the default status to "New". Update the receipt form to eliminate the status selection, enhancing user experience by focusing on essential fields. Improve image upload handling with WebP conversion support in both receipt creation and editing components.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import * as Collapsible from "$lib/components/ui/collapsible";
|
||||
import { Input } from "$lib/components/ui/input";
|
||||
import { Label } from "$lib/components/ui/label";
|
||||
import { convertImageToWebP } from "$lib/convert-image-to-webp";
|
||||
import { POCKETBASE_BASE_URL } from "$lib/pocketbase";
|
||||
import { enhance } from "$app/forms";
|
||||
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
|
||||
@@ -135,11 +136,23 @@
|
||||
function openReplaceImage() {
|
||||
imageInputEl?.click();
|
||||
}
|
||||
function onImageChange() {
|
||||
async function onImageChange() {
|
||||
const input = imageInputEl;
|
||||
const file = input?.files?.[0] ?? null;
|
||||
selectedImageFile = file;
|
||||
imageFileName = file ? file.name : null;
|
||||
if (!file || !file.type.startsWith("image/")) {
|
||||
selectedImageFile = null;
|
||||
imageFileName = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const webpFile = await convertImageToWebP(file);
|
||||
selectedImageFile = webpFile;
|
||||
imageFileName = webpFile.name;
|
||||
} catch {
|
||||
selectedImageFile = null;
|
||||
imageFileName = null;
|
||||
if (input) input.value = "";
|
||||
}
|
||||
}
|
||||
function imageLoadError() {
|
||||
imageError = true;
|
||||
|
||||
Reference in New Issue
Block a user