This commit is contained in:
Kartik Sharma 2025-07-26 11:42:56 +05:30
parent ef3a62086c
commit 1387b47d07

View File

@ -19,7 +19,6 @@ const NotesDirectory = ({
refetchProfile,
isLoading,
contactProfile, // This contactProfile now reliably includes firstName, middleName, lastName, and fullName
contactProfile, // This contactProfile now reliably includes firstName, middleName, lastName, and fullName
setProfileContact,
}) => {
const [IsActive, setIsActive] = useState(true);
@ -30,7 +29,6 @@ const NotesDirectory = ({
const [IsSubmitting, setIsSubmitting] = useState(false);
const [showEditor, setShowEditor] = useState(false);
const [showEditor, setShowEditor] = useState(false);
const {
register,
handleSubmit,
@ -71,7 +69,6 @@ const NotesDirectory = ({
const updatedProfile = {
...cached_contactProfile.data,
notes: [...(cached_contactProfile.data.notes || []), createdNote],
notes: [...(cached_contactProfile.data.notes || []), createdNote],
};
cacheData("Contact Profile", {
contactId: contactProfile?.id,
@ -83,18 +80,12 @@ const NotesDirectory = ({
setIsSubmitting(false);
showToast("Note added successfully!", "success");
setShowEditor(false);
setShowEditor(false);
setIsActive(true);
refetch(contactProfile?.id, true);
refetch(contactProfile?.id, true);
} catch (error) {
setIsSubmitting(false);
const msg =
error.response?.data?.message ||
error.response?.data?.message ||
error.message ||
"Error occurred during API calling";
"Error occurred during API calling";
error.response?.data?.message || error.message || "Error occurred during API calling";
showToast(msg, "error");
}
};
@ -102,11 +93,8 @@ const NotesDirectory = ({
const onCancel = () => {
setValue("note", "");
setShowEditor(false);
setValue("note", "");
setShowEditor(false);
};
const handleSwitch = () => {
setIsActive((prevIsActive) => {
const newState = !prevIsActive;
@ -125,7 +113,6 @@ const NotesDirectory = ({
: contactNotes || [];
return (
<div className="text-start mt-10">
<div className="text-start mt-10">
<div className="d-flex align-items-center justify-content-between">
<div className="row w-100 align-items-center">
@ -145,14 +132,18 @@ const NotesDirectory = ({
: "hidden",
}}
>
<input type="checkbox" className="switch-input" />
<input
type="checkbox"
className="switch-input"
checked={!IsActive} // checked when showing *in*active notes (i.e., when IsActive is false)
onChange={handleSwitch}
/>
<span className="switch-toggle-slider">
<span className="switch-on"></span>
<span className="switch-off"></span>
</span>
<span className="switch-label">Include Deleted Notes</span>
</label>
{!showEditor && (
<div className="d-flex justify-content-end">
<button
@ -183,11 +174,11 @@ const NotesDirectory = ({
<div className="card m-2 mb-5 position-relative">
<span
type="button"
className="position-absolute top-0 end-0 mt-3 bg-secondary rounded-circle"
className="position-absolute top-0 end-0  mt-3 bg-secondary rounded-circle"
aria-label="Close"
onClick={() => setShowEditor(false)}
>
<i className="bx bx-x fs-5 p-1 text-white"></i>
<i className="bx bx-x fs-5  p-1 text-white"></i>
</span>
<form onSubmit={handleSubmit(onSubmit)}>
<Editor
@ -197,7 +188,6 @@ const NotesDirectory = ({
onCancel={onCancel}
onSubmit={handleSubmit(onSubmit)}
/>
{errors.note && (
{errors.note && (
<p className="text-danger small mt-1">{errors.note.message}</p>
)}
@ -205,8 +195,7 @@ const NotesDirectory = ({
</div>
)}
<div className=" justify-content-start px-1 mt-1">
<div className=" justify-content-start px-1 mt-1">
<div className="justify-content-start px-1 mt-1">
{isLoading && (
<div className="text-center">
{" "}
@ -237,4 +226,4 @@ const NotesDirectory = ({
);
};
export default NotesDirectory;
export default NotesDirectory;