contentoh-components-library 21.4.77 → 21.4.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -9,28 +11,18 @@ exports.GroupRow = exports.Container = void 0;
9
11
 
10
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
11
13
 
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
14
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
13
15
 
14
16
  var _variables = require("../../../global-files/variables");
15
17
 
16
- var _templateObject, _templateObject2;
18
+ var _templateObject, _templateObject2, _templateObject3;
19
+
20
+ var fadeIn = (0, _styledComponents.keyframes)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n"])));
17
21
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n border: 1px solid ", ";\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n }\n\n .title-edit {\n width: 100%;\n font-family: ", ", sans-serif;\n font-size: 17px;\n font-weight: 500;\n line-height: 20px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n }\n\n .details-edit {\n width: 100%;\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n margin: 5px 0 10px;\n }\n .container-save-add {\n width: 100%;\n display: flex;\n justify-content: space-between;\n margin-top: 20px;\n }\n .button-add {\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n text-transform: capitalize;\n border: none;\n }\n .table-groups-edit {\n width: 100%;\n min-width: 288px;\n border: 1px solid ", ";\n border-radius: 5px;\n }\n .table-groups-max{\n min-width: 288px;\n border: 1px solid ", ";\n border-radius: 5px;\n display:grid;\n grid-template-columns: repeat(2, 1fr);\n }\n .modal-save {\n .contentModal {\n width: 25%;\n }\n }\n"])), _variables.GlobalColors.gray_light, _variables.FontFamily.RobotoMedium, _variables.GlobalColors.black, _variables.FontFamily.RobotoMedium, _variables.GlobalColors.gray, _variables.FontFamily.RobotoRegular, _variables.GlobalColors.magenta_s2, _variables.GlobalColors.gray_light, _variables.GlobalColors.gray_light);
22
+ var Container = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n .header {\n width: 100%;\n display: flex;\n justify-content: space-between;\n }\n .close-button {\n min-width: 24px;\n height: 24px;\n background-color: transparent;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n transition: background-color 0.3s ease, opacity 0.3s ease;\n display: flex;\n justify-content: center;\n align-items: center;\n -webkit-filter: grayscale(100%);\n filter: grayscale(100%);\n opacity:0.4;\n img {\n width: 10px;\n height: 10px;\n }\n\n &:hover {\n background-color: ", ";\n -webkit-filter: grayscale(0);\n filter: grayscale(0);\n opacity:1;\n }\n }\n .contentModal {\n position: absolute;\n top: 10%;\n z-index: 20;\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 100%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n border: 1px solid ", ";\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n }\n\n .title-edit {\n width: 100%;\n font-family: ", ", sans-serif;\n font-size: 17px;\n font-weight: 500;\n line-height: 20px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n }\n\n .details-edit {\n width: 100%;\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n margin: 5px 0 10px;\n }\n .container-save-add {\n width: 100%;\n display: flex;\n justify-content: space-between;\n margin-top: 20px;\n }\n .button-add {\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n text-transform: capitalize;\n border: none;\n background: transparent;\n border-radius: 20px;\n &:hover {\n background-color: ", ";\n }\n }\n .table-groups-edit {\n width: 100%;\n min-width: 288px;\n border: 1px solid ", ";\n border-radius: 5px;\n }\n .table-groups-max {\n min-width: 288px;\n border: 1px solid ", ";\n border-radius: 5px;\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n }\n .modal-save {\n .contentModal {\n width: 25%;\n }\n }\n"])), _variables.GlobalColors.blue_light, _variables.GlobalColors.gray_light, _variables.FontFamily.RobotoMedium, _variables.GlobalColors.black, _variables.FontFamily.RobotoMedium, _variables.GlobalColors.gray, _variables.FontFamily.RobotoRegular, _variables.GlobalColors.magenta_s2, _variables.GlobalColors.blue_light, _variables.GlobalColors.gray_light, _variables.GlobalColors.gray_light);
19
23
 
20
24
  exports.Container = Container;
21
25
 
22
- var GroupRow = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 34px;\n margin: 0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-family: Roboto;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n text-decoration: none;\n background: ", ";\n border-bottom: 1px solid ", ";\n input {\n background: ", ";\n color: ", ";\n text-decoration: ", ";\n border: 0;\n padding: 5px 20px;\n }\n\n input:focus {\n border: 0;\n }\n"])), function (_ref) {
23
- var isDeleted = _ref.isDeleted;
24
- return isDeleted ? "#FF7373" : "transparent";
25
- }, _variables.GlobalColors.gray_light, function (_ref2) {
26
- var isDeleted = _ref2.isDeleted;
27
- return isDeleted ? "#FF7373" : "transparent";
28
- }, function (_ref3) {
29
- var isDeleted = _ref3.isDeleted;
30
- return isDeleted ? _variables.GlobalColors.white : _variables.GlobalColors.gray;
31
- }, function (_ref4) {
32
- var isDeleted = _ref4.isDeleted;
33
- return isDeleted ? "line-through" : "none";
34
- });
26
+ var GroupRow = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 34px;\n margin: 0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-family: Roboto;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n text-decoration: none;\n border-bottom: 1px solid ", ";\n padding: 0 8px 0 0;\n input {\n width:100%;\n min-width: 215px;\n background: transparent;\n color: ", ";\n border: 0;\n font-size: 12px;\n font-family:", ", sans-serif;\n padding: 5px 20px;\n ::placeholder {\n color: #CBCBCB;\n }\n }\n\n input:focus {\n border: 0;\n }\n &.editing {\n background-color: ", "; \n color: black;\n input{\n color: ", ";\n }\n }\n\n .save-button,\n .edit-button,\n .delete-button {\n min-width: 24px;\n height: 24px;\n background-color: transparent;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n transition: background-color 0.3s ease, opacity 0.3s ease;\n display: flex;\n justify-content: center;\n align-items: center;\n \n img {\n width: 12px;\n height: 12px;\n }\n \n &:hover {\n background-color: ", ";\n }\n }\n .edit-button,\n .delete-button {\n display: none;\n }\n\n .visible {\n display: flex;\n animation: ", " 0.3s ease-in-out forwards;\n }\n"])), _variables.GlobalColors.gray_light, _variables.GlobalColors.gray, _variables.FontFamily.RobotoRegular, _variables.GlobalColors.blue_light, _variables.GlobalColors.black, _variables.GlobalColors.blue_light, fadeIn);
35
27
 
36
28
  exports.GroupRow = GroupRow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.77",
3
+ "version": "21.4.78",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -0,0 +1,8 @@
1
+ <svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <mask id="mask0_731_2487" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="10" height="10">
3
+ <rect width="10" height="10" fill="#D9D9D9"/>
4
+ </mask>
5
+ <g mask="url(#mask0_731_2487)">
6
+ <path d="M0.769231 10L0 9.23077L4.23077 5L0 0.769231L0.769231 0L5 4.23077L9.23077 0L10 0.769231L5.76923 5L10 9.23077L9.23077 10L5 5.76923L0.769231 10Z" fill="#B64545"/>
7
+ </g>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <mask id="mask0_731_2312" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="12" height="12">
3
+ <rect width="12" height="12" fill="#D9D9D9"/>
4
+ </mask>
5
+ <g mask="url(#mask0_731_2312)">
6
+ <path d="M1.40041 10.5996H2.06071L8.70873 3.95157L8.04843 3.29127L1.40041 9.93929V10.5996ZM10.6146 3.30628L8.69372 1.3854L9.32401 0.755116C9.49409 0.585039 9.70418 0.5 9.9543 0.5C10.2044 0.5 10.4145 0.585039 10.5846 0.755116L11.2449 1.41542C11.415 1.58549 11.5 1.79559 11.5 2.0457C11.5 2.29582 11.415 2.50591 11.2449 2.67599L10.6146 3.30628ZM9.98431 3.93656L2.42087 11.5H0.5V9.57913L8.06344 2.01569L9.98431 3.93656Z" fill="#E33AA9"/>
7
+ </g>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <mask id="mask0_748_1469" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="14" height="14">
3
+ <rect width="14" height="14" fill="#D9D9D9"/>
4
+ </mask>
5
+ <g mask="url(#mask0_748_1469)">
6
+ <path d="M14 3.05278V12.8333C14 13.1444 13.8833 13.4167 13.65 13.65C13.4167 13.8833 13.1444 14 12.8333 14H1.16667C0.855556 14 0.583333 13.8833 0.35 13.65C0.116667 13.4167 0 13.1444 0 12.8333V1.16667C0 0.855556 0.116667 0.583333 0.35 0.35C0.583333 0.116667 0.855556 0 1.16667 0H10.9472L14 3.05278ZM12.8333 3.57778L10.4222 1.16667H1.16667V12.8333H12.8333V3.57778ZM6.99543 11.5694C7.55588 11.5694 8.0338 11.3733 8.42917 10.981C8.82454 10.5886 9.02222 10.1123 9.02222 9.55179C9.02222 8.99134 8.82606 8.51343 8.43374 8.11806C8.04143 7.72269 7.56504 7.525 7.00457 7.525C6.44412 7.525 5.9662 7.72116 5.57083 8.11349C5.17546 8.5058 4.97778 8.98219 4.97778 9.54265C4.97778 10.1031 5.17394 10.581 5.56626 10.9764C5.95858 11.3718 6.43496 11.5694 6.99543 11.5694ZM2.19722 4.97778H9.15833V2.19722H2.19722V4.97778Z" fill="#E33AA9"/>
7
+ </g>
8
+ </svg>
@@ -1,6 +1,6 @@
1
1
  import { Container } from "./styles";
2
2
 
3
- export const TabSection = ({ label, active, onClick }) => {
3
+ export const TabSection = ({ label, active, onClick}) => {
4
4
  return (
5
5
  <Container className={active && "active"} onClick={onClick}>
6
6
  <p>{label}</p>
@@ -2,15 +2,23 @@ import React, { useState, useEffect } from "react";
2
2
  import { Container, ContainerIcon } from "./styles";
3
3
  import Chip from "@mui/material/Chip";
4
4
  import { Button, Menu, MenuItem } from "@mui/material";
5
- import Select from "../../atoms/Select";
5
+ import Select from "@mui/material/Select";
6
6
  import add from "../../../assets/images/Icons/addv2.svg";
7
7
  import { Modal } from "../../organisms/Modal";
8
8
  import { TextField } from "@mui/material/TextField";
9
9
  import { GroupSelect } from "../../molecules/GroupSelect";
10
10
  import options from "../../../assets/images/Icons/options.svg";
11
- import DeleteIcon from '@mui/icons-material/DeleteForeverOutlined';
12
-
13
- export const Phase = ({ id, phases, phaseName, nextPhase, groups, onDeletePhase }) => {
11
+ import DeleteIcon from "@mui/icons-material/DeleteForeverOutlined";
12
+
13
+ export const Phase = ({
14
+ id,
15
+ phases,
16
+ phaseName,
17
+ nextPhase,
18
+ groups,
19
+ onDeletePhase,
20
+ draggable
21
+ }) => {
14
22
  const [selectedValue, setSelectedValue] = useState("");
15
23
  const [chips, setChips] = useState([]);
16
24
  const [groupsSelected, setGroupsSelected] = useState([]);
@@ -23,7 +31,8 @@ export const Phase = ({ id, phases, phaseName, nextPhase, groups, onDeletePhase
23
31
  });
24
32
 
25
33
  const idPhase = id + 1;
26
-
34
+ const [draggedItem, setDraggedItem] = useState(null);
35
+ const [tempItems, setTempItems] = useState([]);
27
36
 
28
37
  const onAdd = () => {
29
38
  if (selectedValue && !groupsSelected.includes(selectedValue)) {
@@ -49,8 +58,6 @@ export const Phase = ({ id, phases, phaseName, nextPhase, groups, onDeletePhase
49
58
  setChips((prevChips) => prevChips.filter((chip) => chip !== chipToRemove));
50
59
  };
51
60
 
52
- // const combinedGroups = [...grupos, ...chips];
53
-
54
61
  const [anchorEl, setAnchorEl] = React.useState(null);
55
62
  const open = Boolean(anchorEl);
56
63
  const handleClick = (event) => {
@@ -83,85 +90,121 @@ export const Phase = ({ id, phases, phaseName, nextPhase, groups, onDeletePhase
83
90
  background: "transparent",
84
91
  border: `1px solid ${isHovered ? "#B64545" : "#F0F0F0"}`,
85
92
  color: `${isHovered ? "#B64545" : "#707070"}`,
86
-
87
93
  }}
88
94
  />
89
95
  );
90
96
  };
91
97
 
92
-
93
- console.log(id, phases, nextPhase, groups)
94
-
98
+ const onDragStartHandler = (e) => {
99
+ e.dataTransfer.effectAllowed = "move";
100
+ e.dataTransfer.setData("text/html", e.target.parentNode);
101
+ e.dataTransfer.setDragImage(e.target.parentNode, 20, 20);
102
+ setDraggedItem(id);
103
+ onDragStart(e, id);
104
+ };
95
105
 
106
+ const onDragOverHandler = (index) => {
107
+ if (!draggedItem || draggedItem === id) {
108
+ return;
109
+ }
96
110
 
111
+ onDragOver(id);
112
+ setDraggedItem(null);
113
+ };
97
114
 
98
- // useEffect(() => initialPhase(),[]);
115
+ const onDragEndHandler = () => {
116
+ onDragEnd();
117
+ setDraggedItem(null);
118
+ };
99
119
 
100
120
  return (
101
- <Container>
102
- {/* {initialPhase()} */}
121
+ <Container
122
+ onDragStart={onDragStartHandler}
123
+ onDragOver={onDragOverHandler}
124
+ onDragEnd={onDragEndHandler}
125
+ draggable={draggable}
126
+ >
103
127
  <div key={idPhase} className="header-phase">
104
- <h2>Fase {idPhase} - {phaseName}</h2>
105
- <div className="text-button-container">
106
- {idPhase === 1 ? (
107
- <p className="text-phase">
108
- Al rechazar en esta fase enviar a proveedor
109
- </p>
110
- ) : (
111
- <div className="phase-sel">
112
- <p className="text-phase">Al rechazar en esta fase enviar a </p>
113
- <Select
114
- width="100px"
115
- valueSelected={nextPhase ? Object.values(nextPhase) : []}
116
- placeholder={`Fase`}
117
- options={phases.map((phase) => phase.phaseName)}
118
- onChange={(e) => {
119
- const selectedPhase = phases.find((phase) => phase.phaseName === e.target.value);
120
- console.log("fase seleccionada", selectedPhase);
121
- setSelectedValue(selectedPhase.nextPhaseIfApproved);
122
- }}
123
- />
124
- <Button
125
- id="basic-button"
126
- aria-controls={open ? "basic-menu" : undefined}
127
- aria-haspopup="true"
128
- aria-expanded={open ? "true" : undefined}
129
- onClick={handleClick}
130
- >
131
- <img src={options} alt="" />
132
- </Button>
133
- <Menu
134
- id="basic-menu"
135
- anchorEl={anchorEl}
136
- open={open}
137
- onClose={handleClose}
138
- MenuListProps={{
139
- "aria-labelledby": "basic-button",
140
- }}
141
- >
142
- <MenuItem onClick={() => onDeletePhase(id)}>Eliminar Fase</MenuItem>
143
- </Menu>
144
- </div>
145
- )}
146
- </div>
128
+ <h2>
129
+ Fase {idPhase} - {phaseName}
130
+ </h2>
131
+ <div className="text-button-container">
132
+ {idPhase === 1 ? (
133
+ <p className="text-phase">
134
+ Al rechazar en esta fase enviar a proveedor
135
+ </p>
136
+ ) : (
137
+ <div className="phase-sel">
138
+ <p className="text-phase">Siguiente Fase </p>
139
+ <Select
140
+ width="100px"
141
+ value={selectedValue !== "" ? selectedValue : nextPhase}
142
+ placeholder={`Fase`}
143
+ onChange={(e) => {
144
+ const selectedPhase = phases.find(
145
+ (phase) => phase.phaseName === e.target.value
146
+ );
147
+ setSelectedValue(selectedPhase.nextPhaseIfApproved);
148
+ }}
149
+ sx={{width: "auto",minWidth:"100px", height: "24px", background:"#F7F7FC", borderRadius:"5px"}}
150
+ MenuProps={{
151
+ PaperProps: {
152
+ style: {
153
+ background: "#F7F7FC",
154
+ },
155
+ },
156
+ }}
157
+ >
158
+ {phases.map((phase) => (
159
+ <MenuItem key={phase.phaseId} value={phase.phaseName} sx={{fontSize:"10px", color:"#262626"}}>
160
+ {phase.phaseName}
161
+ </MenuItem>
162
+ ))}
163
+ </Select>
164
+ <Button
165
+ id="basic-button"
166
+ aria-controls={open ? "basic-menu" : undefined}
167
+ aria-haspopup="true"
168
+ aria-expanded={open ? "true" : undefined}
169
+ onClick={handleClick}
170
+ >
171
+ <img src={options} alt="" />
172
+ </Button>
173
+ <Menu
174
+ id="basic-menu"
175
+ anchorEl={anchorEl}
176
+ open={open}
177
+ onClose={handleClose}
178
+ MenuListProps={{
179
+ "aria-labelledby": "basic-button",
180
+ }}
181
+ >
182
+ <MenuItem onClick={() => onDeletePhase(id)}>
183
+ Eliminar Fase
184
+ </MenuItem>
185
+ </Menu>
186
+ </div>
187
+ )}
147
188
  </div>
189
+ </div>
148
190
 
149
191
  <div className="attributes-container">
150
192
  {groups
151
- .filter((group) => group.groupActive === 1)
152
- .map((group, index) => (
153
- <HoverableChip
154
- key={index}
155
- label={group.groupName}
156
- onDelete={() => handleChipDelete(group)}
157
- />
158
- ))}
193
+ .filter((group) => group.groupActive === 1)
194
+ .map((group, index) => (
195
+ <HoverableChip
196
+ key={index}
197
+ label={group.groupName}
198
+ onDelete={() => handleChipDelete(group)}
199
+ />
200
+ ))}
159
201
  <GroupSelect
160
- options={groups.filter((group) => group.groupActive === 0)
202
+ options={groups
203
+ .filter((group) => group.groupActive === 0)
161
204
  .map((group, index) => ({
162
- id: index,
163
- name: group.groupName
164
- }))}
205
+ id: index,
206
+ name: group.groupName,
207
+ }))}
165
208
  showSearchBar={true}
166
209
  icon={add}
167
210
  placeHolder={"Buscar grupo"}
@@ -4,8 +4,8 @@ import { Phase } from "../../molecules/Phase";
4
4
  import { ButtonV2 } from "../../atoms/ButtonV2";
5
5
  import { Modal } from "../Modal";
6
6
  import axios from "axios";
7
- import {GeneralInputv2} from "../../atoms/GeneralInputv2";
8
7
  import successV2 from "../../../assets/images/Icons/checkv2.svg";
8
+ import { Input } from "@mui/material";
9
9
 
10
10
  export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, token}) => {
11
11
  const [items, setItems] = useState(initialItems);
@@ -13,7 +13,7 @@ export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, t
13
13
  const [tempItems, setTempItems] = useState(items);
14
14
  const [user, setUser] = useState(JSON.parse(sessionStorage.getItem("user")));
15
15
  const [listPhases, setListPhases]= useState([]);
16
- const [newPhaseName, setNewPhaseName] = useState();
16
+ const [newPhaseName, setNewPhaseName] = useState("");
17
17
  const [modalData, setModalData] = useState({
18
18
  show: false,
19
19
  title: "Actualización completa",
@@ -21,46 +21,77 @@ export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, t
21
21
  icon: "success",
22
22
  });
23
23
 
24
- const onDragStart = (e, idx) => {
25
- e.dataTransfer.effectAllowed = "move";
26
- e.dataTransfer.setData("text/html", e.target.parentNode);
27
- e.dataTransfer.setDragImage(e.target.parentNode, 20, 20);
28
- setDraggedItem(items[idx]);
29
- };
24
+ // useEffect(() => {console.log("nuevo",newPhaseName)},[newPhaseName]);
30
25
 
31
- const onDragOver = (index) => {
32
- if (!draggedItem) {
33
- return;
34
- }
35
26
 
36
- if (draggedItem === tempItems[index]) {
37
- return;
38
- }
27
+
28
+ {/*const updatePhases = async () => {
29
+ try {
30
+ console.log("listPhases:", listPhases);
31
+ const updateData = {
32
+ body: {
33
+ updateReferencesOfNodes: listPhases.map((phase) => ({
34
+ name:phase.phaseName,
35
+ isInitialPhase: phase.isInitialPhase,
36
+ phaseId: phase.phaseId,
37
+ nextPhaseIfApproved: phase.nextPhaseIfApproved,
38
+ })),
39
+ },
40
+ path: {
41
+ action: "update",
42
+ },
43
+ headers: {
44
+ Authorization: token,
45
+ },
46
+ };
47
+ console.log("updateData:", updateData);
39
48
 
40
- const draggedIndex = tempItems.findIndex((item) => item === draggedItem);
41
- let updatedItems = [...tempItems];
49
+ const response = await axios.post(
50
+ `${process.env.REACT_APP_PHASES_ENDPOINT}/update`,
51
+ updateData
52
+ );
42
53
 
43
- if (draggedIndex > index) {
44
- updatedItems[draggedIndex] = tempItems[index];
45
- updatedItems[index] = draggedItem;
46
- } else {
47
- updatedItems.splice(draggedIndex, 1);
48
- updatedItems.splice(index, 0, draggedItem);
54
+ // Handle response if needed
55
+ console.log("Update response:", response.data);
56
+ } catch (error) {
57
+ console.error("Error al actualizar fases", error);
49
58
  }
59
+ };*/}
50
60
 
51
- setTempItems(updatedItems);
52
- };
53
61
 
54
- const onDragEnd = () => {
55
- setItems(tempItems);
56
- setDraggedItem(null);
62
+ const handleInputChange = (e) => {
63
+ console.log("nuevo nombre",e.target.value)
64
+ setNewPhaseName(e.target.value);
57
65
  };
58
66
 
59
- useEffect(() => {console.log("nuevo",newPhaseName)},[newPhaseName]);
67
+ const AddPhase = async() => {
68
+ try {
69
+ console.log("fase nueva", newPhaseName);
70
+ {/*const body = {
71
+ name: phaseName,
72
+ retailerGroupsIds: [],
73
+ nextPhaseId: null
74
+ }
75
+ const response = await axios.post(
76
+ `${process.env.REACT_APP_PHASES_ENDPOINT}/create`,
77
+ body,
78
+ {
79
+ headers: {
80
+ Authorization: token,
81
+ },
82
+ }
83
+ );
84
+ const createdPhase = response.data.body;
85
+ console.log(createdPhase)*/}
86
+ } catch (error) {
87
+ console.error("Error al agregar fase:", error);
88
+ }
89
+ }
60
90
 
61
- const handleAddPhase = () => {
91
+ const handleAddPhaseButton = () => {
62
92
  setModalData({
63
93
  show: true,
94
+ className:"modal-add-phase",
64
95
  title:"Agregar fase de revisión",
65
96
  buttons: [
66
97
  <ButtonV2
@@ -69,50 +100,41 @@ export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, t
69
100
  label="Cancelar"
70
101
  size={12}
71
102
  onClick={() => {
72
- handleAcceptModal()
103
+ setModalData((prev) => ({ ...prev, show: false }))
73
104
  }}
74
105
  />,
75
- <ButtonV2
76
- key="btn-Guardar"
77
- type="pink"
78
- label="Guardar"
79
- size={12}
80
- onClick={() => {
81
- handleAcceptModal()
82
- }}
83
- />
106
+ <ButtonV2
107
+ key="btn-Guardar"
108
+ type="pink"
109
+ label="Guardar"
110
+ size={12}
111
+ onClick={async () => {
112
+ setModalData((prev) => ({ ...prev, show: false }));
113
+ await new Promise((resolve) => setTimeout(resolve, 0));
114
+ AddPhase();
115
+ }}
116
+ />
84
117
  ],
85
118
  customComponent: (
86
119
  <div className="container-input-name">
87
120
  <p>Las fases nuevas siempre se agregan al final.<br/>Puedes ordenar las fases arrastrándolas.</p>
88
- <GeneralInputv2
89
- inputType={"text"}
90
- inputName={"input-phase-name"}
91
- inputId={0}
92
- inputValue={newPhaseName}
93
- inputOnChange={(e) => setNewPhaseName(e.target.value)}
94
- inputPlaceholder="Nombre de fase"
95
- />
121
+ <input
122
+ className={`input-phases`}
123
+ placeholder="Nombre de fase"
124
+ value={newPhaseName}
125
+ onChange={handleInputChange}
126
+ />
96
127
  </div>
97
128
  ),
98
129
  });
99
130
  };
100
131
 
101
- const handleAcceptModal = () => {
102
- const newPhaseData = {
103
- id: listPhases.length + 1,
104
- phaseName: newPhaseName, // Utiliza el nuevo nombre de la fase
105
- groupsAssigned: [],
106
- };
107
- setListPhases((prevListPhases) => {
108
- const updatedListPhases = [...prevListPhases, newPhaseData];
109
- console.log("actualizada", updatedListPhases);
110
- return updatedListPhases;
111
- });
112
- setModalData((prev) => ({ ...prev, show: false }));
113
- };
132
+ const handleAcceptModal = (PhaseName) => {
133
+ console.log("nombre",PhaseName)
134
+ AddPhase(PhaseName);
135
+ }
114
136
 
115
- const getPhases = async () => {
137
+ const loadData = async () => {
116
138
  try {
117
139
  const response = await axios.post(
118
140
  `${process.env.REACT_APP_PHASES_ENDPOINT}/get`,
@@ -120,11 +142,11 @@ export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, t
120
142
  {
121
143
  headers: {
122
144
  Authorization: token,
145
+ // Authorization: sessionStorage.getItem("jwt"),
123
146
  },
124
147
  }
125
148
  );
126
-
127
- // console.log("response", response);
149
+
128
150
 
129
151
  const phasesData = JSON.parse(response.data.body).data;
130
152
  const phasesDataArray = [];
@@ -145,10 +167,10 @@ export const DragAndDropPhases = ({items: initialItems, grupos: initialGroups, t
145
167
  });
146
168
  });
147
169
 
148
- // console.table("fases Array", phasesDataArray);
170
+ console.table("fases Array", phasesDataArray);
149
171
  setListPhases(phasesDataArray);
150
172
  } catch (error) {
151
- console.error("Error fetching fases:", error);
173
+ console.error("Error al obtener fases:", error);
152
174
  }
153
175
  };
154
176
 
@@ -175,16 +197,25 @@ const handleDeletePhase = (id) => {
175
197
  });
176
198
  };
177
199
 
200
+ useEffect(() => loadData(),[]);
178
201
 
179
- useEffect(() => getPhases(),[]);
180
-
181
- useEffect(() => {
182
- // console.log("fases lista", listPhases);
183
- }, [listPhases]);
202
+ // useEffect(() => {
203
+ // updatePhases();
204
+ // setModalData((prev) => ({ ...prev, show: false }));
205
+ // }, [listPhases]);
184
206
 
185
- const renderPhase = (idx, phase) => {
207
+ const renderPhase = (phase, idx) => {
186
208
  return (
187
- <Phase key={idx} id={idx} phases={listPhases} phaseName={phase.phaseName} nextPhase={phase.nextPhaseIfApproved} groups={phase.groupsAssigned} onDeletePhase={handleDeletePhase}/>
209
+ <Phase
210
+ key={idx}
211
+ id={idx}
212
+ phases={listPhases}
213
+ phaseName={phase.phaseName}
214
+ nextPhase={phase.nextPhaseIfApproved}
215
+ groups={phase.groupsAssigned}
216
+ onDeletePhase={() => handleDeletePhase(phase.id)}
217
+ draggable
218
+ />
188
219
  );
189
220
  };
190
221
 
@@ -192,7 +223,7 @@ const renderPhase = (idx, phase) => {
192
223
  return (
193
224
  <Container>
194
225
  <Header>
195
- <button className="button-phase" onClick={handleAddPhase}>
226
+ <button className="button-phase" onClick={handleAddPhaseButton}>
196
227
  Agregar fase de revisión
197
228
  </button>
198
229
  <ButtonV2
@@ -223,7 +254,7 @@ const renderPhase = (idx, phase) => {
223
254
  ></ButtonV2>
224
255
  </Header>
225
256
  <ul>
226
- {listPhases.map((phase, idx) => renderPhase(idx, phase, handleDeletePhase))}
257
+ {listPhases.map((phase, idx) => renderPhase(phase, idx))}
227
258
  </ul>
228
259
  <Modal
229
260
  {...modalData}
@@ -30,6 +30,33 @@ ul{
30
30
  color: ${GlobalColors.gray};
31
31
  margin-bottom:15px;
32
32
  }
33
+ .input-phases{
34
+ width:100%;
35
+ height: 30px;
36
+ padding: 8px 10px;
37
+ border-radius: 5px;
38
+ border: 1px solid ${GlobalColors.gray_light};
39
+ ::placeholder {
40
+ font-family: ${FontFamily.RobotoRegular}, sans-serif;
41
+ font-size: 12px;
42
+ font-weight: 400;
43
+ line-height: 14px;
44
+ letter-spacing: 0em;
45
+ text-align: left;
46
+ color: #CBCBCB;
47
+ }
48
+ }
49
+ }
50
+ .modal-add-phase {
51
+ .contentModal{
52
+ min-width:310px;
53
+ }
54
+ header .label-title{
55
+ text-align: left;
56
+ }
57
+ .container-buttons{
58
+ justify-content: flex-end;
59
+ }
33
60
  }
34
61
  `;
35
62