import React, { useState } from 'react'; import AdminLayout from '../../layouts/AdminLayout'; import { Box, Heading, FormControl, FormLabel, Input, Button, VStack, useToast, Text } from '@chakra-ui/react'; import api from '../../services/api'; const AdminResetPasswordPage: React.FC = () => { const [email, setEmail] = useState(''); const [isLoading, setIsLoading] = useState(false); const [sent, setSent] = useState(false); const toast = useToast(); const sendReset = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); try { await api.post('/admin/users/send-reset', { email }); setSent(true); toast({ status: 'success', title: 'Odesláno', description: 'Pokud účet existuje, byl odeslán e-mail pro reset hesla.' }); } catch (err: any) { toast({ status: 'error', title: 'Chyba', description: err.response?.data?.error || 'Nepodařilo se odeslat e-mail.' }); } finally { setIsLoading(false); } }; return ( Odeslat reset hesla Tato akce odešle uživateli e-mail s odkazem pro nastavení nového hesla. Použije se speciální SMTP konfigurace určená pouze pro reset. Email uživatele setEmail(e.target.value)} placeholder="uzivatel@example.com" /> {sent && ( Pokud adresa existuje, e-mail s odkazem byl odeslán. )} ); }; export default AdminResetPasswordPage;