prolif löschen
This commit is contained in:
@ -4,6 +4,9 @@ import React, { useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { ModalsProvider, openConfirmModal } from '@mantine/modals';
|
||||
import './DogNavbar.css';
|
||||
import { deleteProfil } from '../services/PhpApi';
|
||||
import { notificationError, notificationSuccess } from '../services/Notifications';
|
||||
import { ResponseT } from '../context/UserContext';
|
||||
|
||||
const NaveBarIcon = ({ icon, href, text = 'tooltip 💡'}: {icon: JSX.Element, href: string, text: string}) =>
|
||||
(
|
||||
@ -20,7 +23,7 @@ const NaveBarIcon = ({ icon, href, text = 'tooltip 💡'}: {icon: JSX.Element, h
|
||||
|
||||
const Divider = () => <hr className="sidebar-hr" />;
|
||||
|
||||
const openDeleteModal = () =>
|
||||
const openDeleteModal = (qr_id: string | null) =>
|
||||
openConfirmModal({
|
||||
title: 'Account löschen!',
|
||||
centered: true,
|
||||
@ -32,10 +35,27 @@ const openDeleteModal = () =>
|
||||
),
|
||||
labels: { confirm: 'Account löschen', cancel: "Behalten, nicht löschen" },
|
||||
onCancel: () => console.log('Cancel'),
|
||||
onConfirm: () => console.log('Confirmed')
|
||||
onConfirm: () =>
|
||||
{
|
||||
console.log('Confirmed');
|
||||
if(qr_id)
|
||||
{
|
||||
const data = deleteProfil({qr_id: qr_id}) as ResponseT;
|
||||
if(data.success)
|
||||
{
|
||||
notificationSuccess('Profil gelöscht!');
|
||||
}
|
||||
else if(!data.success && data.message)
|
||||
{
|
||||
notificationError(data.message);
|
||||
}
|
||||
window.location.href = '/dog/';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function DogNavbar({hasUser, hidden, onLogout}:{hasUser: boolean, hidden: boolean, onLogout: () => void})
|
||||
function DogNavbar({hasUser, qr_id, hidden, onLogout}:
|
||||
{hasUser: boolean, qr_id: string | null, hidden: boolean, onLogout: () => void})
|
||||
{
|
||||
return (
|
||||
<>
|
||||
@ -79,7 +99,7 @@ function DogNavbar({hasUser, hidden, onLogout}:{hasUser: boolean, hidden: boolea
|
||||
<Divider/>
|
||||
<Navbar.Section className='InputForm' >
|
||||
{hasUser &&
|
||||
<div onClick={openDeleteModal}>
|
||||
<div onClick={() => openDeleteModal(qr_id)}>
|
||||
<NaveBarIcon icon={<Icons.UserMinus size={32}/>} href={''} text={'Account löschen'}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user