diff --git a/src/App.jsx b/src/App.jsx index a4dfe7f..2ac121b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -707,6 +707,44 @@ export default function App() { reader.readAsDataURL(file); }; + const handleItemImageUpload = (e) => { + const file = e.target.files[0]; + if (!file) return; + + const reader = new FileReader(); + reader.onload = (event) => { + const img = new Image(); + img.onload = () => { + const canvas = document.createElement('canvas'); + const MAX_SIZE = 800; // Tamanho maior para roupas + let width = img.width; + let height = img.height; + + if (width > height) { + if (width > MAX_SIZE) { + height *= MAX_SIZE / width; + width = MAX_SIZE; + } + } else { + if (height > MAX_SIZE) { + width *= MAX_SIZE / height; + height = MAX_SIZE; + } + } + + canvas.width = width; + canvas.height = height; + const ctx = canvas.getContext('2d'); + ctx.drawImage(img, 0, 0, width, height); + const base64Data = canvas.toDataURL('image/jpeg', 0.8); + + setImageUrlDraft(base64Data); + }; + img.src = event.target.result; + }; + reader.readAsDataURL(file); + }; + const saveProfile = async (e) => { e.preventDefault(); setSavingProfile(true); @@ -1011,7 +1049,7 @@ export default function App() {
- +
@@ -1289,8 +1327,8 @@ export default function App() {

{editingItem ? t('edit') : t('newItem')}

- {editingItem?.imageUrl || imageUrlDraft.startsWith('http') ? ( - + {imageUrlDraft ? ( + ) : (
@@ -1336,7 +1374,29 @@ export default function App() { {itemColors.length === 0 &&

Selecione pelo menos uma cor

}
- setImageUrlDraft(v)} /> +
+ +
+ setImageUrlDraft(e.target.value)} + placeholder="https://..." + className={`w-full p-5 rounded-2xl border-none outline-none focus:ring-4 focus:ring-primary-500/10 font-bold transition-all ${darkMode ? 'bg-gray-700 text-white' : 'bg-gray-100 text-gray-900'}`} + /> +
+
+ OU +
+
+ +
+
{/* Campo de Secções */}