Skip to content

Commit bc60809

Browse files
authored
Merge pull request #7 from bert27/refactor/architecture-cleanup-and-irrigation-unification
1. Domain-Driven Refactoring (Irrigation Module) Renamed IMockState to IIrrigationData to decouple domain logic from simulation implementation. Improved task typing by using actual Day objects instead of primitive strings. Unified service architecture to be source-agnostic (Hardware vs. Simulation). 2. Interface Standardization & Prefixing (Drinks Module) Implemented I prefix for core interfaces: Cocktail → ICocktail, Bottle → IBottle. Updated all child components, hooks, and services to utilize these standardized types. 3. Mock Data Reorganization Moved all simulation data from data/ to a dedicated mocks/ directory. Renamed constants for clarity: availableCocktails → MOCK_COCKTAILS, initialBottles → MOCK_BOTTLES. 4. Connectivity & Build Fixes Vite Migration: Updated .env variables from REACT_APP_ to VITE_ prefix to ensure they are correctly loaded in the new build system. UX Improvements: Added a "Retry Connection" button in the SimulationAlert component to allow users to manually exit reactive mock mode. Path Aliases: Fixed broken relative imports by standardizing the use of @/ path aliases across the car and drinks modules. 5. Testing & Quality Assurance Resolved 16/16 tests in the drinks module (fixing JSDOM navigation errors and act() warnings). Verified production build success (npm run build).
2 parents cd9b475 + 9fb8817 commit bc60809

File tree

61 files changed

+1036
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1036
-648
lines changed

client/.env

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
REACT_APP_REMOTE_IP=http://192.168.1.96
2-
REACT_APP_ROBOT_IP=http://192.168.1.97
3-
REACT_APP_DRINKS_IP=http://192.168.1.83
4-
REACT_APP_IRRIGATION_IP=http://192.168.1.145
1+
VITE_REMOTE_IP=http://192.168.1.96
2+
VITE_ROBOT_IP=http://192.168.1.97
3+
VITE_DRINKS_IP=http://192.168.1.83
4+
VITE_IRRIGATION_IP=http://192.168.1.145
55
WDS_SOCKET_PORT=0
66
VITE_MOCK_SERVER=false

client/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import "./i18n";
33
import "./styles.css";
4-
import { Plant } from "@/pages/plant/plant-page-index";
4+
import { Irrigation } from "@/pages/irrigation/irrigation-page-index";
55
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
66
import { DrinksPage } from "@/pages/drinks/drinks-page";
77
import { SideNavBar } from "@/components/Menu/sidenavbar";
@@ -20,10 +20,10 @@ export const App: React.FC = () => {
2020
<Box component="main" sx={{ flexGrow: 1, overflowX: "hidden" }}>
2121
<Routes>
2222
<Route path="/" element={<CarPage />} />
23-
<Route path="/irrigation" element={<Plant />} />
23+
<Route path="/irrigation" element={<Irrigation />} />
2424
<Route path="/drinks" element={<DrinksPage />} />
2525
<Route path="/drinks/:tabRouter" element={<DrinksPage />} />
26-
<Route path="*" element={<Plant />} />
26+
<Route path="*" element={<Irrigation />} />
2727
</Routes>
2828
</Box>
2929
</Box>

client/src/components/Task/Task.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ export const Task = ({
2424
minutes: 30,
2525
},
2626
index = 0,
27-
eliminateTask = () => {},
27+
eliminateTask = () => { },
2828
}: IPropsTask) => {
2929
const { t } = useTranslation();
3030
return (
3131
<div
32-
className="cardTask_plant"
32+
className="cardTask_irrigation"
3333
key={index}
3434
data-testid={"task"}
3535
>
3636
<div className="delete-btn-container">
37-
<Tooltip title={t('plant.task.delete')}>
38-
<IconButton
39-
onClick={() => eliminateTask(index)}
37+
<Tooltip title={t('irrigation.task.delete')}>
38+
<IconButton
39+
onClick={() => eliminateTask(index)}
4040
className="delete-task-btn"
4141
aria-label="delete"
4242
size="medium"
@@ -46,13 +46,13 @@ export const Task = ({
4646
</Tooltip>
4747
</div>
4848
<div className="title_cardtask">
49-
{t('plant.task.at')} {taskData?.hour}:{taskData?.minutes}
49+
{t('irrigation.task.at')} {taskData?.hour}:{taskData?.minutes}
5050
</div>
51-
<div className="daysTask_plant">
51+
<div className="daysTask_irrigation">
5252
{taskData?.days.map((taskdatac, index) => (
5353
<div key={index}>
5454
{taskdatac?.state && (
55-
<div className="day_task">{t(`plant.days.${taskdatac?.name}`)}</div>
55+
<div className="day_task">{t(`irrigation.days.${taskdatac?.name}`)}</div>
5656
)}
5757
</div>
5858
))}

client/src/components/Task/task.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.tasksList_plant {
1+
.tasksList_irrigation {
22
display: flex;
33
flex-direction: column;
44
gap: 1rem;
@@ -7,21 +7,21 @@
77
padding-right: 0.5rem;
88
}
99

10-
.tasksList_plant::-webkit-scrollbar {
10+
.tasksList_irrigation::-webkit-scrollbar {
1111
width: 6px;
1212
}
1313

14-
.tasksList_plant::-webkit-scrollbar-track {
14+
.tasksList_irrigation::-webkit-scrollbar-track {
1515
background: rgba(255, 255, 255, 0.05);
1616
border-radius: 10px;
1717
}
1818

19-
.tasksList_plant::-webkit-scrollbar-thumb {
19+
.tasksList_irrigation::-webkit-scrollbar-thumb {
2020
background: var(--primary);
2121
border-radius: 10px;
2222
}
2323

24-
.cardTask_plant {
24+
.cardTask_irrigation {
2525
position: relative;
2626
display: flex;
2727
flex-direction: column;
@@ -34,7 +34,7 @@
3434
transition: transform 0.3s ease, box-shadow 0.3s ease;
3535
}
3636

37-
.cardTask_plant:hover {
37+
.cardTask_irrigation:hover {
3838
transform: translateY(-2px);
3939
box-shadow: var(--shadow-premium);
4040
}
@@ -49,7 +49,7 @@
4949
align-items: center;
5050
}
5151

52-
.daysTask_plant {
52+
.daysTask_irrigation {
5353
display: flex;
5454
flex-wrap: wrap;
5555
gap: 0.4rem;

client/src/components/days/DaySelector.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export const DaySelector: React.FC<DaySelectorProps> = ({ day, saveChoose, index
1818
};
1919

2020
return (
21-
<div
22-
className={`days_plant_child ${isActive ? 'active' : ''}`}
21+
<div
22+
className={`days_irrigation_child ${isActive ? 'active' : ''}`}
2323
onClick={toggleDay}
2424
>
2525
<div>{day?.name}</div>
26-
<div className="checkBox_plant_child">
26+
<div className="checkBox_irrigation_child">
2727
{isActive && <CheckIcon className="buttonsvg" />}
2828
</div>
2929
</div>

client/src/components/days/Days.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface DaysProps {
99

1010
export const Days: React.FC<DaysProps> = ({ saveDays, days }) => {
1111
return (
12-
<div className="days_plant">
12+
<div className="days_irrigation">
1313
{days.map((day, index) => (
1414
<DaySelector
1515
day={day}

client/src/components/days/days.css

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.days_plant {
1+
.days_irrigation {
22
display: flex;
33
width: 100%;
44
justify-content: space-around;
@@ -11,7 +11,7 @@
1111
gap: 0.5rem;
1212
}
1313

14-
.days_plant_child {
14+
.days_irrigation_child {
1515
cursor: pointer;
1616
display: flex;
1717
flex-direction: column;
@@ -22,18 +22,18 @@
2222
flex: 1;
2323
}
2424

25-
.days_plant_child:hover {
25+
.days_irrigation_child:hover {
2626
transform: translateY(-3px);
2727
}
2828

29-
.days_plant_child div:first-child {
29+
.days_irrigation_child div:first-child {
3030
font-size: 0.75rem;
3131
font-weight: 600;
3232
color: var(--text-muted);
3333
text-transform: uppercase;
3434
}
3535

36-
.checkBox_plant_child {
36+
.checkBox_irrigation_child {
3737
width: 32px;
3838
height: 32px;
3939
background: rgba(255, 255, 255, 0.05);
@@ -45,12 +45,13 @@
4545
transition: all 0.3s ease;
4646
}
4747

48-
.days_plant_child.active .checkBox_plant_child {
48+
.days_irrigation_child.active .checkBox_irrigation_child {
4949
background: var(--primary-glow);
5050
border-color: var(--primary);
5151
box-shadow: 0 0 10px var(--primary-glow);
5252
}
5353

54+
5455
.buttonsvg {
5556
width: 18px;
5657
height: 18px;

client/src/components/simulation-alert/simulation-alert.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2-
import { Alert, SxProps, Theme } from '@mui/material';
3-
import { SIMULATION_MESSAGE } from '@/utils/simulation';
2+
import { Alert, Box, Button, SxProps, Theme } from '@mui/material';
3+
import { SIMULATION_MESSAGE, resetSimulationMode } from '@/utils/simulation';
4+
import RefreshIcon from '@mui/icons-material/Refresh';
45

56
interface SimulationAlertProps {
67
isMock: boolean;
@@ -13,6 +14,17 @@ export const SimulationAlert: React.FC<SimulationAlertProps> = ({ isMock, sx })
1314
return (
1415
<Alert
1516
severity="info"
17+
action={
18+
<Button
19+
color="inherit"
20+
size="small"
21+
startIcon={<RefreshIcon />}
22+
onClick={resetSimulationMode}
23+
sx={{ fontWeight: 700, textTransform: 'none' }}
24+
>
25+
Reintentar Conexión
26+
</Button>
27+
}
1628
sx={{
1729
mb: 2,
1830
background: "rgba(2, 136, 209, 0.1)",

client/src/config/.!18234!._api.config.ts

Whitespace-only changes.

client/src/config/.!18385!._api.config.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)