Table App - Copy this React, Tailwind Component to your project
Dựa vào api này mà build 1 table app.get('/danhsachthietbi client', async (req, res) => { const { phongbanId } = req.query poolMySQL.getConnection((err, connection) => { if (err) { console.error('Error getting MySQL connection:', err) res.status(500).send('Internal Server Error') return } connection.query( ` SELECT bh.BaoHuHongThietBi_id, dv.name, pb.TenPhongBan, gb.Giaybao, vd.Problem_name, bh.NgayBaoHuHong, bh.GhiChu, st.Status_name, dt.NgayCapNhat FROM baohuhongthietbi bh JOIN dm_trangthaigiaybaosuachua gb ON bh.Giaybao_id = gb.Giaybao_id JOIN dm_phongban pb ON bh.Phongban_id = pb.Phongban_id JOIN device_detail dv ON bh.Device_detail_id = dv.Device_detail_id JOIN dm_problem vd ON bh.Problem_id = vd.Problem_id JOIN baohuhongthietbi_detail dt ON bh.BaoHuHongThietBi_id = dt.BaoHuHongThietBi_id JOIN dm_status st ON dt.Status_Id = st.status_Id WHERE bh.Phongban_id = ${phongbanId} AND (bh.BaoHuHongThietBi_id, dt.NgayCapNhat) IN ( SELECT bh_inner.BaoHuHongThietBi_id, MAX(dt_inner.NgayCapNhat) FROM baohuhongthietbi_detail dt_inner JOIN baohuhongthietbi bh_inner ON dt_inner.BaoHuHongThietBi_id = bh_inner.BaoHuHongThietBi_id GROUP BY bh_inner.BaoHuHongThietBi_id ) ORDER BY bh.NgayBaoHuHong DESC; `, (err, results) => { connection.release() // Return the connection to the pool if (err) { console.error('Error executing query:', err) res.status(500).send('Internal Server Error') return } res.json(results) } ) }) })
