@@ -78,27 +87,11 @@ const EditProfileModal = ({ isOpen, onClose, onSubmit, data, agent_id }) => {
className="shadow appearance-none border rounded w-full py-2 px-3 text-textPrimary leading-tight focus:outline-none focus:shadow-outline"
/>
-
-
-
-
-
-
-
+
+
(meta_id, reason para métricas)
+ // TODO: POST => (meta_id, reason para métricas)
setConfirmModalData(serializedFormData);
const response = await fetch(
@@ -139,14 +139,14 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
const handleReactivateUser = async () => {
try {
actualSetIsLoading(true);
-
+
const payload1 = {
meta_id: selectedChat.contact,
agent_id: userUuid,
field: "active",
field_state: "true",
};
-
+
// PUT to change conversation state to active
await axios.put(
`${process.env.REACT_APP_BACKOFFICE_API_URL}/agents/change-conversation-state`,
@@ -158,12 +158,12 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
},
}
);
-
+
const payload2 = {
meta_id: selectedChat.contact,
agent_id: userUuid
};
-
+
await axios.put(
`${process.env.REACT_APP_BACKOFFICE_API_URL}/users/set-user-state?state=agent`,
payload2,
@@ -174,7 +174,7 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
},
}
);
-
+
handleCloseConfirmModal();
} catch (error) {
console.error("Error during reactivation", error);
@@ -186,6 +186,7 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
}
const handleOpenModal = () => {
+ {console.log("Showing edit profile modal")}
(async () => {
actualSetIsLoading(true);
//TODO: PUT THE CORRECT ADMIN VALUE
@@ -211,7 +212,7 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
name: name || "",
address: address || "",
email: email || "",
- client_type: msg || "",
+ client_type: msg || [],
meta_id: meta_id,
});
} else {
@@ -220,7 +221,7 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
name: "",
address: "",
email: "",
- client_type: "",
+ client_type: [],
meta_id: selectedChat.contact,
});
}
@@ -230,7 +231,7 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
name: "",
address: "",
email: "",
- client_type: "",
+ client_type: [],
meta_id: selectedChat.contact,
});
}
@@ -244,42 +245,57 @@ const useProfileModal = (userUuid, idToken, role, externalIsLoading, externalSet
setShowModal(false);
};
+ const formatClientTypeDescription = (clientTypes) => {
+ if (!clientTypes || clientTypes.length === 0) return '';
+ if (clientTypes.length === 1) return clientTypes[0].label;
+ return `${clientTypes[0].label} + ${clientTypes.length - 1} más`;
+ }
+
const handleSubmitModalData = async (formData) => {
- actualSetIsLoading(true);
- console.log("This is the current selectedChat", selectedChat);
- const updatedChat = {
- address: formData.address,
- contact: formData.meta_id,
- email: formData.email,
- imgUrl: selectedChat.imgUrl,
- messaging_product: selectedChat.messaging_product,
- msg: formData.client_type,
- name: formData.name !== "" ? formData.name : formData.meta_id,
- pp: selectedChat.pp,
- time: selectedChat.time,
- unreadMsgs: selectedChat.unreadMsgs,
- };
- updateChat(updatedChat)
-
- const response = await fetch(
- `${process.env.REACT_APP_BACKOFFICE_API_URL}/users/save-user-information`,
- {
- method: "PUT",
- headers: {
- "Content-Type": "application/json",
- 'Authorization': `Bearer ${idToken}`
- },
- body: JSON.stringify(formData),
+ console.log("This is formData in the moment of sending", formData)
+ console.log("This is client type", formData.client_type)
+
+ try {
+ actualSetIsLoading(true);
+ const clientTypeDescription = formatClientTypeDescription(formData.client_type);
+ console.log("This is the current selectedChat", selectedChat);
+ const updatedChat = {
+ address: formData.address,
+ contact: formData.meta_id,
+ email: formData.email,
+ imgUrl: selectedChat.imgUrl,
+ messaging_product: selectedChat.messaging_product,
+ name: formData.name !== "" ? formData.name : formData.meta_id,
+ pp: selectedChat.pp,
+ time: selectedChat.time,
+ unreadMsgs: selectedChat.unreadMsgs,
+ msg: clientTypeDescription,
+ };
+ updateChat(updatedChat)
+
+ const response = await fetch(
+ `${process.env.REACT_APP_BACKOFFICE_API_URL}/users/save-user-information`,
+ {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ 'Authorization': `Bearer ${idToken}`
+ },
+ body: JSON.stringify(formData),
+ }
+ );
+ if (response.ok) {
+ console.log("Submission successful");
+ actualSetIsLoading(false);
+ } else {
+ actualSetIsLoading(false);
+ console.error("Submission failed");
}
- );
- if (response.ok) {
- console.log("Submission successful");
+ setShowModal(false);
+ } catch (error) {
actualSetIsLoading(false);
- } else {
- console.error("Submission failed");
- actualSetIsLoading(true);
+ console.error('Submission failed', error)
}
- setShowModal(false);
};
return {
diff --git a/src/logic/TimeConversion.js b/src/logic/TimeConversion.js
index 6a768e9..f3adbe7 100644
--- a/src/logic/TimeConversion.js
+++ b/src/logic/TimeConversion.js
@@ -8,24 +8,20 @@ const addFiveHours = (dateTimeString) => {
};
function formatDateTime(dateTimeString, source) {
- console.log("Original dateTimeString:", dateTimeString);
moment.locale('es');
const normalizeTime = (timeStr) => {
if (timeStr.includes('.')) {
const normalized = timeStr.replace(/\.\s*m\./gi, '').replace('a', 'AM').replace('p', 'PM');
- console.log("Normalized timeStr:", normalized);
return normalized;
}
return timeStr;
};
const normalizedTime = normalizeTime(dateTimeString);
- console.log("Normalized dateTimeString:", normalizedTime);
if (/^\d{1,2}:\d{2}:\d{2} (\w+)\.? m\.$/i.test(dateTimeString) || /^\d{1,2}:\d{2}:\d{2} (AM|PM)$/i.test(normalizedTime)) {
const formattedTime = moment(normalizedTime, "hh:mm:ss A").format("hh:mm A");
- console.log("Formatted time:", formattedTime);
return formattedTime;
}
@@ -33,10 +29,8 @@ function formatDateTime(dateTimeString, source) {
if(source === 'websocket_messages'){
formattedDateTime = moment(dateTimeString).add(5, 'hours').format("hh:mm A");
- console.log("Formatted dateTime:", formattedDateTime);
} else {
formattedDateTime = moment(dateTimeString).format("DD/MMMM hh:mm A");
- console.log("Formatted dateTime:", formattedDateTime);
}
return formattedDateTime;
diff --git a/tailwind.config.js b/tailwind.config.js
index 402f126..189d28d 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -12,6 +12,10 @@ module.exports = {
bounce: {
'0%, 100%': { transform: 'translateX(0)' },
'50%': { transform: 'translateX(-25%)' },
+ },
+ slideDown: {
+ '0%': { transform: 'translateY(-100%)', opacity: 0 },
+ '100%': { transform: 'translateY(0)', opacity: 1 },
}
},
screens: {
@@ -20,7 +24,8 @@ module.exports = {
animation: {
'fade-in-out': 'fadeInOut 2s infinite',
'flash': 'flash 1s ease-in-out infinite',
- 'bounce': 'bounce 0.5s ease-in-out'
+ 'bounce': 'bounce 0.5s ease-in-out',
+ 'slideDown': 'slideDown 0.5s ease-in-out'
},
colors: {