From 1487c065e034ab0640c08ccd9a0cf25fca2bd083 Mon Sep 17 00:00:00 2001 From: rhahao <26148770+rhahao@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:28:03 +0300 Subject: [PATCH] fix(persons): display delete button for visiting speakers from local congregation --- .../visitingSpeakers/CongregationAdd.jsx | 2 +- .../visitingSpeakers/IncomingSpeaker.jsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/features/visitingSpeakers/CongregationAdd.jsx b/src/features/visitingSpeakers/CongregationAdd.jsx index b50ac6210f..4bd71c358e 100644 --- a/src/features/visitingSpeakers/CongregationAdd.jsx +++ b/src/features/visitingSpeakers/CongregationAdd.jsx @@ -49,7 +49,7 @@ const CongregationAdd = ({ isOpen, setOpen }) => { const handleCreateCongreation = async () => { try { // check if cong exist - const tmpNumber = selectedCong.cong_number || congNumber; + const tmpNumber = selectedCong?.cong_number || congNumber; const isExist = VisitingSpeakers.getCongregation(tmpNumber); if (isExist) { diff --git a/src/features/visitingSpeakers/IncomingSpeaker.jsx b/src/features/visitingSpeakers/IncomingSpeaker.jsx index 7e8362e1cb..b5a6269dab 100644 --- a/src/features/visitingSpeakers/IncomingSpeaker.jsx +++ b/src/features/visitingSpeakers/IncomingSpeaker.jsx @@ -161,6 +161,14 @@ const IncomingSpeaker = ({ isNew, speaker, cong_number }) => { setScreenRefresh((prev) => !prev); }; + const handleDeleteSpeaker = async () => { + await VisitingSpeakers.deleteSpeaker({ + person_uid: speaker.person_uid, + cong_number: speaker.cong_number, + }); + setScreenRefresh((prev) => !prev); + }; + useEffect(() => { if (speaker) { setSpeakerName(speaker.person_name); @@ -238,6 +246,16 @@ const IncomingSpeaker = ({ isNew, speaker, cong_number }) => { {!isNew && ( + + )}