Skip to content

Conversation

@Lucaslgd02
Copy link
Contributor

Describe your changes

Add the possibility to move an existing table

How to test the feature

Go to POS table
Toggle edit mode
move an existing table

Issue ticket number and link

Closes #220

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Documentation has been updated as required
    If a single item in this checklist is not checked, the pull request cannot be accepted

@Lucaslgd02 Lucaslgd02 requested a review from alecorvec October 1, 2025 08:07
@Lucaslgd02 Lucaslgd02 self-assigned this Oct 1, 2025
@Lucaslgd02 Lucaslgd02 linked an issue Oct 1, 2025 that may be closed by this pull request
2 tasks
@JulesGresset JulesGresset requested a review from Copilot October 1, 2025 22:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the functionality to move existing tables in the POS table interface when in edit mode. It enables drag-and-drop repositioning of tables that have already been placed on the board.

  • Integrates react-dnd drag functionality into existing DroppableTable components
  • Updates the drop handler to differentiate between creating new tables and moving existing ones
  • Adds visual feedback during dragging with opacity changes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Components/TablesView/DroppableTable.js Adds useDrag hook and drag reference to enable existing tables to be draggable
src/Components/TablesView/TablesView.js Updates drop handler to handle both new table creation and existing table movement
src/tests/Components/TableView/DroppableTable.test.js Adds react-dnd mocks for testing the new drag functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +60 to +65
const offset = monitor.getSourceClientOffset();
if (!offset) return;

const containerRect = dropArea.getBoundingClientRect();
const left = offset.x;
const top = offset.y;
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name offset is reused in both branches but represents different types of offsets (delta vs source client offset). Consider using more descriptive names like sourceOffset to distinguish their purposes and improve code clarity.

Copilot uses AI. Check for mistakes.
Comment on lines 124 to 133
return (
<div onClick={() => onTableClick(table.orderId)} name={table.id} className={`${table.type === "circle" ? "rounded-full" : ""} border-4 absolute col-span-1 grid grid-flow-row ${inEdit === true ? `bg-grey-bg ${border} grid-rows-2` : table.time === "00:00" ? `bg-kitchen-green ${fuseBorder} grid-rows-3` : `bg-kitchen-yellow ${fuseBorder} grid-rows-3`} justify-center justify-items-center`} style={{height: `${table.h / tableSize}vw`, width: `${table.w / tableSize}vw`, top: table.top, left: table.left}}>
<div ref={inEdit ? drag : null} onClick={() => onTableClick(table.orderId)} name={table.id} className={`${table.type === "circle" ? "rounded-full" : ""} border-4 absolute col-span-1 grid grid-flow-row ${inEdit === true ? `bg-grey-bg ${border} grid-rows-2` : table.time === "00:00" ? `bg-kitchen-green ${fuseBorder} grid-rows-3` : `bg-kitchen-yellow ${fuseBorder} grid-rows-3`} justify-center justify-items-center`} style={{height: `${table.h / tableSize}vw`,width: `${table.w / tableSize}vw`,top: table.top,left: table.left,opacity: isDragging ? 0.5 : 1}}>
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is extremely long and difficult to read. Consider breaking down the className construction and style object into separate variables or using template literals with line breaks for better maintainability.

Copilot uses AI. Check for mistakes.
@JulesGresset JulesGresset self-requested a review October 2, 2025 11:28
Copy link
Member

@JulesGresset JulesGresset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Features works as expected.
Some comments from Copilot to be resolved before merge.

@@ -1,8 +1,18 @@
/* eslint-disable react/prop-types */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing the linter in this file?

@Lucaslgd02 Lucaslgd02 enabled auto-merge November 11, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possibility to move an existing table

3 participants