diff --git a/src/components/Directory/ManageBucket.jsx b/src/components/Directory/ManageBucket.jsx index ef8b5e54..bf48d8fe 100644 --- a/src/components/Directory/ManageBucket.jsx +++ b/src/components/Directory/ManageBucket.jsx @@ -12,13 +12,12 @@ import EmployeeList from "./EmployeeList"; import { useAllEmployees, useEmployees } from "../../hooks/useEmployees"; import { useSortableData } from "../../hooks/useSortableData"; import ConfirmModal from "../common/ConfirmModal"; -import {useHasUserPermission} from "../../hooks/useHasUserPermission"; -import {DIRECTORY_ADMIN, DIRECTORY_MANAGER} from "../../utils/constants"; -import {useProfile} from "../../hooks/useProfile"; +import { useHasUserPermission } from "../../hooks/useHasUserPermission"; +import { DIRECTORY_ADMIN, DIRECTORY_MANAGER } from "../../utils/constants"; +import { useProfile } from "../../hooks/useProfile"; -const ManageBucket = () => -{ - const {profile} =useProfile() +const ManageBucket = () => { + const { profile } = useProfile(); const [bucketList, setBucketList] = useState([]); const { employeesList } = useAllEmployees(false); const [selectedEmployee, setSelectEmployee] = useState([]); @@ -27,9 +26,9 @@ const ManageBucket = () => const [isSubmitting, setSubmitting] = useState(false); const [selected_bucket, select_bucket] = useState(null); const [deleteBucket, setDeleteBucket] = useState(null); - const [ searchTerm, setSearchTerm ] = useState( "" ); - const DirManager = useHasUserPermission( DIRECTORY_MANAGER ) - const DirAdmin = useHasUserPermission(DIRECTORY_ADMIN) + const [searchTerm, setSearchTerm] = useState(""); + const DirManager = useHasUserPermission(DIRECTORY_MANAGER); + const DirAdmin = useHasUserPermission(DIRECTORY_ADMIN); const { items: sortedBuckteList, requestSort, @@ -228,7 +227,7 @@ const ManageBucket = () =>

Manage Buckets

-
+
{action_bucket ? (
{!action_bucket ? ( -
+
- +
{bucket.description} {bucket.numberOfContacts} - - {(DirManager || + {(DirManager || DirAdmin || bucket?.createdBy?.id === profile?.employeeInfo?.id) && (
- { select_bucket(bucket); setAction_bucket(true); - }} + }} > { +const NoteCardDirectory = ({ + refetchProfile, + refetchNotes, + noteItem, + contactId, + setProfileContact, +}) => { const [editing, setEditing] = useState(false); const [editorValue, setEditorValue] = useState(noteItem.note); const [isLoading, setIsLoading] = useState(false); - const [ isDeleting, setIsDeleting ] = useState( false ); - const [isActivProcess,setActiveProcessing]= useState(false) + const [isDeleting, setIsDeleting] = useState(false); + const [isActivProcess, setActiveProcessing] = useState(false); const handleUpdateNote = async () => { try { setIsLoading(true); @@ -51,8 +57,8 @@ const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, se cacheData("Contact Profile", updatedProfile); } setEditing(false); - setIsLoading( false ); - + setIsLoading(false); + showToast("Note Updated successfully", "success"); } catch (error) { setIsLoading(false); @@ -66,8 +72,11 @@ const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, se const handleDeleteNote = async (activeStatue) => { try { - activeStatue ? setActiveProcessing(true) : setIsDeleting(true) - const resp = await DirectoryRepository.DeleteNote(noteItem.id,activeStatue); + activeStatue ? setActiveProcessing(true) : setIsDeleting(true); + const resp = await DirectoryRepository.DeleteNote( + noteItem.id, + activeStatue + ); setProfileContact((prev) => ({ ...prev, notes: prev.notes.filter((note) => note.id !== noteItem.id), @@ -91,11 +100,14 @@ const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, se cacheData("Contact Profile", updatedCache); } - setIsDeleting( false ); - setActiveProcessing( false ) - refetchNotes( contactId, false ) - refetchProfile(contactId) - showToast(`Note ${activeStatue ? "Restored":"Deleted"} Successfully`, "success"); + setIsDeleting(false); + setActiveProcessing(false); + refetchNotes(contactId, false); + refetchProfile(contactId); + showToast( + `Note ${activeStatue ? "Restored" : "Deleted"} Successfully`, + "success" + ); } catch (error) { setIsDeleting(false); const msg = @@ -107,11 +119,15 @@ const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, se }; return (
-
-
- {noteItem.isActive ? ( - <> - setEditing(true)} - > +
+ {noteItem.isActive ? ( + <> + setEditing(true)} + > - {!isDeleting ? ( - handleDeleteNote(!noteItem.isActive)} - > - ) : ( -
- Loading... + {!isDeleting ? ( + handleDeleteNote(!noteItem.isActive)} + > + ) : ( +
+ Loading... +
+ )} + + ) : isActivProcess ? ( + + ) : ( + handleDeleteNote(!noteItem.isActive)} + title="Restore" + > + )}
- )} - - ) : isActivProcess ? ( - < i className='bx bx-loader-alt bx-spin text-primary' >
- ) : ( - handleDeleteNote(!noteItem.isActive)} - title="Restore" - > - )} -
- -

diff --git a/src/components/Directory/NotesDirectory.jsx b/src/components/Directory/NotesDirectory.jsx index 87707596..b8128ef6 100644 --- a/src/components/Directory/NotesDirectory.jsx +++ b/src/components/Directory/NotesDirectory.jsx @@ -16,13 +16,18 @@ const schema = z.object({ note: z.string().min(1, { message: "Note is required" }), }); -const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileContact }) => { +const NotesDirectory = ({ + refetchProfile, + isLoading, + contactProfile, + setProfileContact, +}) => { const [IsActive, setIsActive] = useState(true); - const {contactNotes,refetch} = useContactNotes( contactProfile?.id, true ); + const { contactNotes, refetch } = useContactNotes(contactProfile?.id, true); const [NotesData, setNotesData] = useState(); const [IsSubmitting, setIsSubmitting] = useState(false); - const [addNote, setAddNote] = useState(false); + const [addNote, setAddNote] = useState(true); const { register, handleSubmit, @@ -70,7 +75,7 @@ const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileCo setValue("note", ""); setIsSubmitting(false); showToast("Note added successfully!", "success"); - setAddNote(false); + setAddNote(true); setIsActive(true); } catch (error) { setIsSubmitting(false); @@ -85,14 +90,12 @@ const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileCo const onCancel = () => { setValue("note", ""); }; - const handleSwitch = () => - { - setIsActive( !IsActive ) - if ( IsActive ) - { - refetch(contactProfile?.id, false) + const handleSwitch = () => { + setIsActive(!IsActive); + if (IsActive) { + refetch(contactProfile?.id, false); } - } + }; return (
@@ -103,7 +106,7 @@ const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileCo handleSwitch(!IsActive)} + onChange={() => handleSwitch(!IsActive)} value={IsActive} /> @@ -114,24 +117,11 @@ const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileCo {/* */} - Show Including Inactive Notes + Show Including Inactive Notes -
-
- setAddNote(!addNote)} - > - {/* */} - {addNote ? "close" : "Add Note"} - -
+ {addNote && (
)} +
+ setAddNote(!addNote)} + > + {addNote ? "Hide Editor" : "Add Note"} + +
{isLoading && (
@@ -154,32 +152,31 @@ const NotesDirectory = ({refetchProfile, isLoading, contactProfile, setProfileCo
)} {!isLoading && - [...(IsActive ? contactProfile?.notes || [] : contactNotes || [])] - .reverse() - .map((noteItem) => ( - - ))} + [...(IsActive ? contactProfile?.notes || [] : contactNotes || [])] + .reverse() + .map((noteItem) => ( + + ))} {IsActive && (
{!isLoading && contactProfile?.notes.length == 0 && !addNote && ( -
No Notes Found
+
No Notes Found
)}
)} {!IsActive && (
{!isLoading && contactNotes.length == 0 && !addNote && ( -
No Notes Found
+
No Notes Found
)}
)} diff --git a/src/components/Directory/ProfileContactDirectory.jsx b/src/components/Directory/ProfileContactDirectory.jsx index 8494f2c6..f986aab8 100644 --- a/src/components/Directory/ProfileContactDirectory.jsx +++ b/src/components/Directory/ProfileContactDirectory.jsx @@ -11,7 +11,7 @@ const ProfileContactDirectory = ({ contact, setOpen_contact, closeModal }) => { const [profileContact, setProfileContact] = useState(); const [expanded, setExpanded] = useState(false); const description = contactProfile?.description || ""; - const limit = 100; + const limit = 500; const toggleReadMore = () => setExpanded(!expanded); @@ -107,10 +107,10 @@ const ProfileContactDirectory = ({ contact, setOpen_contact, closeModal }) => {

Created :

-
  • - - {moment(contactProfile.createdAt).format("MMMM, DD YYYY")} -
  • +
  • + + {moment(contactProfile.createdAt).format("MMMM, DD YYYY")} +
  • )} @@ -202,8 +202,11 @@ const ProfileContactDirectory = ({ contact, setOpen_contact, closeModal }) => { )} -
    - +
    +
    +

    Description :

    +
    +
    {displayText} {isLong && ( { {expanded ? "Read less" : "Read more"} )} - +
    +
    +
    {/* Left: Quill Format Buttons */}