modified not url

This commit is contained in:
Pramod Mahajan 2025-05-28 19:06:51 +05:30
parent f9ad47ef54
commit 3dd901a81f
2 changed files with 44 additions and 33 deletions

View File

@ -10,18 +10,16 @@ import moment from "moment";
import { cacheData, getCachedData } from "../../slices/apiDataManager"; import { cacheData, getCachedData } from "../../slices/apiDataManager";
import NoteCardDirectory from "./NoteCardDirectory"; import NoteCardDirectory from "./NoteCardDirectory";
import showToast from "../../services/toastService"; import showToast from "../../services/toastService";
import {useContactNotes} from "../../hooks/useDirectory"; import { useContactNotes } from "../../hooks/useDirectory";
const schema = z.object({ const schema = z.object({
note: z.string().min(1, { message: "Note is required" }), note: z.string().min(1, { message: "Note is required" }),
}); });
const NotesDirectory = ( {isLoading, contactProfile, setProfileContact} ) => const NotesDirectory = ({ isLoading, contactProfile, setProfileContact }) => {
{ const [IsActive, setIsActive] = useState(true);
const [ IsActive, setIsActive ] = useState( true ) const { contactNotes } = useContactNotes(contactProfile?.id, !IsActive);
const {contactNotes} = useContactNotes(contactProfile?.id,!IsActive)
const [NotesData, setNotesData] = useState(); const [NotesData, setNotesData] = useState();
const [IsSubmitting, setIsSubmitting] = useState(false); const [IsSubmitting, setIsSubmitting] = useState(false);
const [addNote, setAddNote] = useState(false); const [addNote, setAddNote] = useState(false);
@ -72,8 +70,8 @@ const NotesDirectory = ( {isLoading, contactProfile, setProfileContact} ) =>
setValue("note", ""); setValue("note", "");
setIsSubmitting(false); setIsSubmitting(false);
showToast("Note added successfully!", "success"); showToast("Note added successfully!", "success");
setAddNote( false ); setAddNote(false);
setIsActive(true) setIsActive(true);
} catch (error) { } catch (error) {
setIsSubmitting(false); setIsSubmitting(false);
const msg = const msg =
@ -93,31 +91,35 @@ const NotesDirectory = ( {isLoading, contactProfile, setProfileContact} ) =>
<div className="d-flex align-items-center justify-content-between"> <div className="d-flex align-items-center justify-content-between">
<p className="fw-semibold m-0">Notes :</p> <p className="fw-semibold m-0">Notes :</p>
<div className="m-0 d-flex aligin-items-center"> <div className="m-0 d-flex aligin-items-center">
<label className="switch switch-primary"> <label className="switch switch-primary">
<input type="checkbox" className="switch-input" onChange={() => setIsActive( !IsActive )} value={IsActive} /> <input
<span className="switch-toggle-slider"> type="checkbox"
<span className="switch-on"> className="switch-input"
{/* <i class="icon-base bx bx-check"></i> */} onChange={() => setIsActive(!IsActive)}
</span> value={IsActive}
<span className="switch-off"> />
{/* <i class="icon-base bx bx-x"></i> */} <span className="switch-toggle-slider">
</span> <span className="switch-on">
{/* <i class="icon-base bx bx-check"></i> */}
</span> </span>
<span className="switch-label small-text">Show Inactive Notes</span> <span className="switch-off">
</label> {/* <i class="icon-base bx bx-x"></i> */}
<span </span>
className={`btn btn-xs ${addNote ? "btn-danger" : "btn-primary"}`} </span>
onClick={() => setAddNote( !addNote )} <span className="switch-label small-text">Show Inactive Notes</span>
> </label>
{/* <i <span
className={`btn btn-xs ${addNote ? "btn-danger" : "btn-primary"}`}
onClick={() => setAddNote(!addNote)}
>
{/* <i
className={`icon-base bx ${ className={`icon-base bx ${
addNote ? "bx-x bx-sm" : "bx-pencil" addNote ? "bx-x bx-sm" : "bx-pencil"
} bx-xs `} } bx-xs `}
></i> */} ></i> */}
{addNote ? "close" : "Add Note"} {addNote ? "close" : "Add Note"}
</span> </span>
</div> </div>
</div> </div>
{addNote && ( {addNote && (
<form onSubmit={handleSubmit(onSubmit)}> <form onSubmit={handleSubmit(onSubmit)}>
@ -141,7 +143,7 @@ const NotesDirectory = ( {isLoading, contactProfile, setProfileContact} ) =>
</div> </div>
)} )}
{!isLoading && {!isLoading &&
[...(IsActive ? contactProfile?.notes || [] : contactNotes || [])] [...(IsActive ? contactProfile?.notes || [] : contactNotes || [])]
.reverse() .reverse()
.map((noteItem) => ( .map((noteItem) => (
<NoteCardDirectory <NoteCardDirectory
@ -151,11 +153,20 @@ const NotesDirectory = ( {isLoading, contactProfile, setProfileContact} ) =>
setProfileContact={setProfileContact} setProfileContact={setProfileContact}
key={noteItem.id} key={noteItem.id}
/> />
) )} ))}
{IsActive && ( <p>{!isLoading && contactProfile?.notes.length == 0 && !addNote && ( <p className="text-center">No Notes Found</p> )}</p> )} {IsActive && (
<p>
{!isLoading && contactProfile?.notes.length == 0 && !addNote && (
<p className="text-center">No Notes Found</p>
)}
</p>
)}
{!IsActive && ( {!IsActive && (
<p>{!isLoading && contactNotes.length == 0 && !addNote && (<p className="text-center">No Notes Found</p>) }</p> <p>
{!isLoading && contactNotes.length == 0 && !addNote && (
<p className="text-center">No Notes Found</p>
)}
</p>
)} )}
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@ export const DirectoryRepository = {
GetContactProfile: ( id ) => api.get( `/api/directory/profile/${ id }` ), GetContactProfile: ( id ) => api.get( `/api/directory/profile/${ id }` ),
CreateNote: ( data ) => api.post( '/api/directory/note', data ), CreateNote: ( data ) => api.post( '/api/directory/note', data ),
GetNote: ( id,isActive ) => api.get( `/api/directory/note/${ id }?active=${isActive}` ), GetNote: ( id,isActive ) => api.get( `/api/directory/notes/${ id }?active=${isActive}` ),
UpdateNote: ( id, data ) => api.put( `/api/directory/note/${ id }`, data ), UpdateNote: ( id, data ) => api.put( `/api/directory/note/${ id }`, data ),
DeleteNote:(id)=> api.delete(`/api/directory/note/${ id }`) DeleteNote:(id)=> api.delete(`/api/directory/note/${ id }`)
} }