fix: validate document uploads and allow clearing expiry dates
This commit is contained in:
@@ -262,12 +262,14 @@ export function getDocument(email, id) {
|
||||
}
|
||||
|
||||
/** Belge üst verisi: son kullanma / kategori (süre takibi için). */
|
||||
export function updateDocument(email, id, { sonKullanma, kategori } = {}) {
|
||||
export function updateDocument(email, id, patch = {}) {
|
||||
return withDb((db) => {
|
||||
const hasDate = Object.hasOwn(patch,'sonKullanma');
|
||||
const hasCategory = Object.hasOwn(patch,'kategori');
|
||||
const r = db.prepare(`UPDATE belgeler SET
|
||||
son_kullanma = COALESCE(?, son_kullanma),
|
||||
kategori = COALESCE(?, kategori)
|
||||
WHERE id=? AND email=?`).run(sonKullanma ?? null, kategori ?? null, id, email);
|
||||
son_kullanma = CASE WHEN ? THEN ? ELSE son_kullanma END,
|
||||
kategori = CASE WHEN ? THEN ? ELSE kategori END
|
||||
WHERE id=? AND email=?`).run(Number(hasDate), patch.sonKullanma ?? null, Number(hasCategory), patch.kategori ?? null, id, email);
|
||||
return r.changes > 0;
|
||||
}, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user