Skip to content

Commit e154c0f

Browse files
authored
Merge pull request #44 from SyTW2526/feature/refactor
Feature/refactor
2 parents f4e2c0b + 1502f58 commit e154c0f

Some content is hidden

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

58 files changed

+1447
-443
lines changed

client/package-lock.json

Lines changed: 167 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"coverage": "vitest run --coverage --coverage.include '**/src/*'"
1616
},
1717
"dependencies": {
18+
"@hookform/resolvers": "^5.2.2",
1819
"@radix-ui/react-alert-dialog": "^1.1.15",
1920
"@radix-ui/react-avatar": "^1.1.11",
2021
"@radix-ui/react-dialog": "^1.1.15",
@@ -39,9 +40,11 @@
3940
"radix-ui": "^1.4.3",
4041
"react": "^19.1.1",
4142
"react-dom": "^19.1.1",
43+
"react-hook-form": "^7.68.0",
4244
"react-i18next": "^16.3.5",
4345
"react-redux": "^9.2.0",
4446
"recharts": "^2.15.4",
47+
"socket.io-client": "^4.8.1",
4548
"tailwind-merge": "^3.3.1",
4649
"tailwindcss": "^4.1.16",
4750
"zod": "^4.1.12"

client/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import ContactsPage from "@/pages/public/contactsPage";
1111
import ProtectedRoute from "@/components/auth/protectedRoute";
1212
import Footer from "@/components/footer";
1313
import AppMenubar from "@/components/appMenubar";
14+
import { useSocket } from "@/hooks/useSocket";
1415

1516
export default function App() {
17+
useSocket();
1618
const { isAuthenticated } = useAuth();
1719
const publicRoute = (Page: React.ComponentType) =>
1820
isAuthenticated ? <Navigate to="/dashboard" replace /> : <Page />;

client/src/components/createDialogs/createListDialog.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useLists } from "@/hooks/useLists";
88
import { useTranslation } from "react-i18next";
99
import type { List } from "@/types/tasks-system/list";
1010

11-
// Props para modo controlado (usado como diálogo anidado)
1211
interface ControlledProps {
1312
mode: "controlled";
1413
open: boolean;
@@ -18,7 +17,6 @@ interface ControlledProps {
1817
) => void;
1918
}
2019

21-
// Props para modo standalone (usado como componente independiente)
2220
interface StandaloneProps {
2321
mode?: "standalone";
2422
trigger?: React.ReactNode;
@@ -35,7 +33,6 @@ function CreateListDialogUnified(props: CreateListDialogUnifiedProps) {
3533

3634
const resetForm = () => setFormData({ name: "", description: "" });
3735

38-
// Handler para modo standalone
3936
const handleStandaloneSubmit = () => {
4037
if (!formData.name.trim()) return false;
4138

@@ -48,7 +45,6 @@ function CreateListDialogUnified(props: CreateListDialogUnifiedProps) {
4845
return true;
4946
};
5047

51-
// Handler para modo controlado
5248
const handleControlledSubmit = (e: React.FormEvent) => {
5349
e.preventDefault();
5450
if (!formData.name.trim()) return;
@@ -99,7 +95,6 @@ function CreateListDialogUnified(props: CreateListDialogUnifiedProps) {
9995
</>
10096
);
10197

102-
// Modo controlado: usa FormDialog
10398
if (isControlled) {
10499
return (
105100
<FormDialog
@@ -117,7 +112,6 @@ function CreateListDialogUnified(props: CreateListDialogUnifiedProps) {
117112
);
118113
}
119114

120-
// Modo standalone: usa CreateDialog
121115
return (
122116
<CreateDialog
123117
trigger={props.trigger}
@@ -132,15 +126,12 @@ function CreateListDialogUnified(props: CreateListDialogUnifiedProps) {
132126
);
133127
}
134128

135-
// Export por defecto: modo standalone
136129
export default CreateListDialogUnified;
137130

138-
// Export nombrado para modo controlado
139131
export function CreateListDialog(props: Omit<ControlledProps, "mode">) {
140132
return <CreateListDialogUnified mode="controlled" {...props} />;
141133
}
142134

143-
// Export nombrado para modo standalone (alias)
144135
export function CreateListDialogStandalone(props: {
145136
children?: React.ReactNode;
146137
}) {

client/src/components/createDialogs/createTaskDialog.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CreateDialog } from "@/components/ui/createDialog";
22
import { TaskFormFields } from "@/components/forms/TaskFormFields";
33
import { CreateListDialog } from "@/components/createDialogs/createListDialog";
44
import { useTaskForm } from "@/hooks/useTaskForm";
5-
import { useLists } from "@/hooks/useLists";
5+
66
import { useTranslation } from "react-i18next";
77
import type { Task } from "@/types/tasks-system/task";
88

@@ -24,7 +24,6 @@ export default function CreateTaskDialog({
2424
showCreateList = true,
2525
}: CreateTaskDialogProps) {
2626
const { t } = useTranslation();
27-
const { canAccess, isOwner } = useLists();
2827
const {
2928
formData,
3029
updateField,
@@ -34,14 +33,7 @@ export default function CreateTaskDialog({
3433
handleListCreated,
3534
handleSubmit,
3635
resetForm,
37-
} = useTaskForm(editTask);
38-
39-
// Filter lists to only show those where user has EDIT+ permission
40-
const filteredLists = filterByEditPermission
41-
? accessibleLists.filter(
42-
(list) => isOwner(list.id) || canAccess(list.id, "EDIT"),
43-
)
44-
: accessibleLists;
36+
} = useTaskForm(editTask, { filterByEditPermission });
4537

4638
const handleOpenChange = (isOpen: boolean) => {
4739
if (!isOpen && !editTask) {
@@ -52,7 +44,6 @@ export default function CreateTaskDialog({
5244

5345
const handleFormSubmit = () => {
5446
const success = handleSubmit(() => {
55-
// Cerrar el diálogo después de enviar exitosamente
5647
handleOpenChange(false);
5748
});
5849
return success;
@@ -77,7 +68,7 @@ export default function CreateTaskDialog({
7768
<TaskFormFields
7869
formData={formData}
7970
updateField={updateField}
80-
accessibleLists={filteredLists}
71+
accessibleLists={accessibleLists}
8172
onCreateList={() => setListDialogOpen(true)}
8273
showCreateList={showCreateList}
8374
/>

client/src/components/dashboard/dashboardCharts.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import { Bar, BarChart, Pie, PieChart, Cell, XAxis, YAxis } from "recharts";
99
import { useTranslation } from "react-i18next";
1010

11-
// Constante para el radio de las barras
1211
const BAR_RADIUS = 8;
1312

1413
interface ChartDataItem {
@@ -100,7 +99,6 @@ export function WeeklyTasksChart({ data, config }: WeeklyTasksChartProps) {
10099
const isFirst = keysWithValue[0] === dataKey;
101100
const isLast = keysWithValue[keysWithValue.length - 1] === dataKey;
102101

103-
// Determinar tipo de radius
104102
if (!isFirst && !isLast) {
105103
return <rect x={x} y={y} width={width} height={height} fill={fill} />;
106104
}

0 commit comments

Comments
 (0)