Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ interface DeleteModalProps {
handleCancelModal: () => void;
handleDeleteModal: (boardId: string) => void;
boardId: string;
boardName: string;
}

function DeleteModal(props: DeleteModalProps): React.JSX.Element {
const {handleCancelModal, handleDeleteModal, boardId} = props;
function DeleteModal({
handleCancelModal,
handleDeleteModal,
boardId,
boardName, // Destructure the new prop
}: DeleteModalProps): React.JSX.Element {
// const {handleCancelModal, handleDeleteModal, boardId} = props;

return (
<Modal visible={true} transparent={true} animationType="slide">
<View style={style.modalOverlay}>
<View style={style.modalContent}>
<Text style={style.modalTitle}>
{' '}
Are you sure you want to delete board?
Are you sure you want to delete "{boardName}"?
</Text>
</View>
<View style={style.buttonContainer}>
Expand Down
9 changes: 7 additions & 2 deletions src/screens/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ function Profile({
const [isModalVisible, setIsModalVisible] = useState(false);
const [selectedBoardId, setSelectedBoardId] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [selectedBoardName, setSelectedBoardName] = useState<string | null>(
null,
);

const handleEdit = () => {
setEditBoard(true);
};

const openDeleteModal = (boardId: string) => {
const openDeleteModal = (boardId: string, boardName: string) => {
if (!isModalVisible) {
console.log('Open delete modal for modal id:', boardId);
setSelectedBoardId(boardId);
setSelectedBoardName(boardName);
setIsModalVisible(true);
}
};
Expand Down Expand Up @@ -264,7 +268,7 @@ function Profile({
<View style={style.editIconsContainer}>
<TouchableOpacity
style={style.deleteIcon}
onPress={() => openDeleteModal(board.id)}>
onPress={() => openDeleteModal(board.id, board.name)}>
<Text style={style.iconText}>Delete</Text>
</TouchableOpacity>
<TouchableOpacity
Expand Down Expand Up @@ -297,6 +301,7 @@ function Profile({
handleDeleteModal(selectedBoardId!)
}
boardId={selectedBoardId!}
boardName={selectedBoardName || ''}
/>
)}
</Pressable>
Expand Down