Changes
This commit is contained in:
parent
9774c54c2c
commit
ad886b7da3
@ -19,7 +19,6 @@ const NotesDirectory = ({
|
|||||||
refetchProfile,
|
refetchProfile,
|
||||||
isLoading,
|
isLoading,
|
||||||
contactProfile, // This contactProfile now reliably includes firstName, middleName, lastName, and fullName
|
contactProfile, // This contactProfile now reliably includes firstName, middleName, lastName, and fullName
|
||||||
contactProfile, // This contactProfile now reliably includes firstName, middleName, lastName, and fullName
|
|
||||||
setProfileContact,
|
setProfileContact,
|
||||||
}) => {
|
}) => {
|
||||||
const [IsActive, setIsActive] = useState(true);
|
const [IsActive, setIsActive] = useState(true);
|
||||||
@ -30,7 +29,6 @@ const NotesDirectory = ({
|
|||||||
|
|
||||||
const [IsSubmitting, setIsSubmitting] = useState(false);
|
const [IsSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [showEditor, setShowEditor] = useState(false);
|
const [showEditor, setShowEditor] = useState(false);
|
||||||
const [showEditor, setShowEditor] = useState(false);
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -71,7 +69,6 @@ const NotesDirectory = ({
|
|||||||
const updatedProfile = {
|
const updatedProfile = {
|
||||||
...cached_contactProfile.data,
|
...cached_contactProfile.data,
|
||||||
notes: [...(cached_contactProfile.data.notes || []), createdNote],
|
notes: [...(cached_contactProfile.data.notes || []), createdNote],
|
||||||
notes: [...(cached_contactProfile.data.notes || []), createdNote],
|
|
||||||
};
|
};
|
||||||
cacheData("Contact Profile", {
|
cacheData("Contact Profile", {
|
||||||
contactId: contactProfile?.id,
|
contactId: contactProfile?.id,
|
||||||
@ -83,10 +80,8 @@ const NotesDirectory = ({
|
|||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
showToast("Note added successfully!", "success");
|
showToast("Note added successfully!", "success");
|
||||||
setShowEditor(false);
|
setShowEditor(false);
|
||||||
setShowEditor(false);
|
|
||||||
setIsActive(true);
|
setIsActive(true);
|
||||||
refetch(contactProfile?.id, true);
|
refetch(contactProfile?.id, true);
|
||||||
refetch(contactProfile?.id, true);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
const msg =
|
const msg =
|
||||||
@ -98,11 +93,8 @@ const NotesDirectory = ({
|
|||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
setValue("note", "");
|
setValue("note", "");
|
||||||
setShowEditor(false);
|
setShowEditor(false);
|
||||||
setValue("note", "");
|
|
||||||
setShowEditor(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleSwitch = () => {
|
const handleSwitch = () => {
|
||||||
setIsActive((prevIsActive) => {
|
setIsActive((prevIsActive) => {
|
||||||
const newState = !prevIsActive;
|
const newState = !prevIsActive;
|
||||||
@ -121,7 +113,6 @@ const NotesDirectory = ({
|
|||||||
: contactNotes || [];
|
: contactNotes || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-start mt-10">
|
|
||||||
<div className="text-start mt-10">
|
<div className="text-start mt-10">
|
||||||
<div className="d-flex align-items-center justify-content-between">
|
<div className="d-flex align-items-center justify-content-between">
|
||||||
<div className="row w-100 align-items-center">
|
<div className="row w-100 align-items-center">
|
||||||
@ -141,14 +132,18 @@ const NotesDirectory = ({
|
|||||||
: "hidden",
|
: "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-toggle-slider">
|
||||||
<span className="switch-on"></span>
|
<span className="switch-on"></span>
|
||||||
<span className="switch-off"></span>
|
<span className="switch-off"></span>
|
||||||
</span>
|
</span>
|
||||||
<span className="switch-label">Include Deleted Notes</span>
|
<span className="switch-label">Include Deleted Notes</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
{!showEditor && (
|
{!showEditor && (
|
||||||
<div className="d-flex justify-content-end">
|
<div className="d-flex justify-content-end">
|
||||||
<button
|
<button
|
||||||
@ -179,11 +174,11 @@ const NotesDirectory = ({
|
|||||||
<div className="card m-2 mb-5 position-relative">
|
<div className="card m-2 mb-5 position-relative">
|
||||||
<span
|
<span
|
||||||
type="button"
|
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"
|
aria-label="Close"
|
||||||
onClick={() => setShowEditor(false)}
|
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>
|
</span>
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<Editor
|
<Editor
|
||||||
@ -193,7 +188,6 @@ const NotesDirectory = ({
|
|||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
/>
|
/>
|
||||||
{errors.note && (
|
|
||||||
{errors.note && (
|
{errors.note && (
|
||||||
<p className="text-danger small mt-1">{errors.note.message}</p>
|
<p className="text-danger small mt-1">{errors.note.message}</p>
|
||||||
)}
|
)}
|
||||||
@ -232,4 +226,4 @@ const NotesDirectory = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NotesDirectory;
|
export default NotesDirectory;
|
Loading…
x
Reference in New Issue
Block a user