From a21b5a1f7e2a8f42b2556684e33925a303337f59 Mon Sep 17 00:00:00 2001 From: Tim <47184194+imgde@users.noreply.github.com> Date: Fri, 13 Jun 2025 19:26:17 +0200 Subject: [PATCH] Initial ItemsInfo (to be improved) --- 00-backend/datasource/database.sqlite | Bin 2629632 -> 2629632 bytes .../public/locales/de/translation.json | 9 +- .../public/locales/en/translation.json | 9 +- 01-frontend/src/components/Item.tsx | 1 + .../src/helper/adminpanel/ItemsInfo.tsx | 202 ++++++++++++++++-- 5 files changed, 202 insertions(+), 19 deletions(-) diff --git a/00-backend/datasource/database.sqlite b/00-backend/datasource/database.sqlite index 6049a259d37110ba512e0de9f0161af59168be62..3ed449be160ab76c9e4f80af9c6b89856adf952c 100644 GIT binary patch delta 451 zcmZY4JxCjI9L90)CEl5ri%nx~lhY=e`iDb=F1lDURCH)!6@(08d5nod*LJ8PsD-Cp z99lZuBB-E~6s5i-ojlP(D>w#%3ZhFXb#M?|^)klcw|qa#^P6>+q}jXs5|v6{&6iSX z4unL=ghHr*|vFQO&8no6qatD>G)^Q`7E|#+O$!Z_m;P zn@R8C@Osy&WY15Q71_*HwBy_KRc7t=<<1~?|Hk^i-|2^q71}NfrLODh^p39NZOb2`(kz zqGM+t!L<*dAAJ4l+3WwmZ+hd0*0DFfMtEXc_#zN9VpfF0h?b7EdB zh()m^mc@!#6>Fj)nxZAvMO$>lhUkh-u_d;}j>w0&msh_RjEeBheZKE!6Tch{+)14G zOfqG@<3syoy0zQ%%$%Bmy{b3Tp}mWKlMmaD0{c_!Rc^Pqs9av&RPG>rJjyQ1wichtiger text ", + price100: 1000, + stock: 100, + stockExpected: 1200, + category: "garden", + rating: 5, + discount100: 21, + }, + { + id: "2", + uuid: "uuid12312412", + name: "Schlauch", + description: "Schlauchiger Schlauch für Schlauchige Angelegenheiten", + price100: 10, + stock: 50, + stockExpected: 100, + category: "technicalComponents", + rating: 10, + discount100: 21, + }, + ] + + //TODO: get per REST + const [rows, setRows] = useState(_rows); + const [selectedRows, setSelectedRows] = useState>(new Set()); + + const handleSelectionChange = (newSelection: GridRowSelectionModel) => { + setSelectedRows(newSelection.ids); + }; + + const handleDeleteSelected = async () => { + selectedRows.forEach((row) => { + //TODO: send delete command, or send deleteall + console.log(row); + }) + + setRows(rows.filter((row) => !selectedRows.has(row.id))); + }; + + const columns: GridColDef<(typeof rows)[number]>[] = [ + {field: 'id', headerName: 'ID', width: 60}, + { + field: 'uuid', + headerName: "UUID", + type: "string", + width: 120, + editable: true + }, + { + field: 'name', + headerName: t('name'), + width: 150, + editable: true, + }, + { + field: 'category', + headerName: t('category'), + width: 150, + editable: true, + }, + { + field: 'description', + headerName: t('description'), + width: 150, + editable: true, + }, + { + field: 'price100', + headerName: t('price100'), + width: 100, + editable: true, + type: 'number' + }, + { + field: 'discount100', + headerName: t('discount100'), + width: 120, + editable: true, + type: 'number' + }, + { + field: 'stock', + headerName: t('stock'), + width: 100, + editable: true, + type: 'number', + renderCell: params => + }, + { + field: 'rating', + headerName: t('rating'), + width: 100, + editable: true, + type: 'number', + renderCell: params => + }, + { //edit billing information button + field: "actualPrice", + headerName: t('actualPrice'), + width: 90, + editable: false, + valueGetter: (_, row) => (row.price100 / 100 * ((100-row.discount100)/100)).toFixed(2) + }, + { + field: 'images', + headerName: t('images'), + width: 90, + editable: false, + renderCell: params => handleIconEdit(params.row)}> , + } + ]; + + useEffect(() => { + console.log(mapValueToColor(0,10,2)) + console.log(mapValueToColor(0,10,7)) + }, []); return ( - - 🚧 Under construction... - + ( + + + + )}} + showToolbar + processRowUpdate={(updatedRow, originalRow) => { + setRows(rows.map(row => row.id === updatedRow.id ? updatedRow : row)); + //TODO: make REST callback + return updatedRow; + }} + /> ); }