Skip to content

Commit

Permalink
fix(persons): display delete button for visiting speakers from local …
Browse files Browse the repository at this point in the history
…congregation
  • Loading branch information
rhahao committed Sep 19, 2023
1 parent d997285 commit 1487c06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/features/visitingSpeakers/CongregationAdd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions src/features/visitingSpeakers/IncomingSpeaker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -238,6 +246,16 @@ const IncomingSpeaker = ({ isNew, speaker, cong_number }) => {
{!isNew && (
<Box sx={{ marginTop: '15px' }}>
<SpeakerTalk speaker={speaker} readOnly={readOnly} />

<Button
sx={{ marginTop: '15px' }}
variant="outlined"
color="error"
startIcon={<CancelIcon />}
onClick={handleDeleteSpeaker}
>
{t('delete')}
</Button>
</Box>
)}

Expand Down

0 comments on commit 1487c06

Please sign in to comment.