style(forms): ujednolicenie ekranu sukcesu i usuniecie zbednych opcji

This commit is contained in:
MichalC
2026-07-27 22:32:30 +02:00
parent e338c95da0
commit 1a11aecf01
5 changed files with 78 additions and 72 deletions
+26 -36
View File
@@ -1,10 +1,11 @@
'use client';
import { useState } from 'react';
import { AlertTriangle, Wrench, Phone, Check, Clock, Zap } from 'lucide-react';
import { Wrench, Zap, Info, Clock, Check, AlertTriangle, Phone, CheckCircle2 } from 'lucide-react';
import Link from 'next/link';
import { companyDetails } from '@/content/company';
import { submitAwariaForm } from '@/app/zgloszenie-awarii/actions';
import { getRecaptchaToken } from '@/lib/getRecaptchaToken';
// Kody błędów popularnych marek
const ERROR_CODES: Record<string, Record<string, string>> = {
@@ -125,15 +126,8 @@ export function AwariaClient() {
}
setIsSubmitting(true);
let recaptchaToken = '';
if (process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY) {
recaptchaToken = await (window as any).grecaptcha.execute(
process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,
{ action: 'submit' }
);
}
await submitAwariaForm({
const recaptchaToken = await getRecaptchaToken('submit');
const formDataObj: any = {
isUrgent,
brand,
model,
@@ -147,8 +141,10 @@ export function AwariaClient() {
city,
preferredDate: '',
preferredTime: '',
recaptchaToken,
});
};
if (recaptchaToken) formDataObj.recaptchaToken = recaptchaToken;
await submitAwariaForm(formDataObj);
setIsSubmitting(false);
setStep('success');
@@ -157,31 +153,25 @@ export function AwariaClient() {
if (step === 'success') {
return (
<main className="bg-slate-50 min-h-screen flex items-center justify-center py-16">
<div className="max-w-md mx-auto px-4 text-center">
<div className="size-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6">
<Check className="size-10 text-green-600" />
</div>
<h2 className="text-2xl font-extrabold text-primary font-heading mb-3">
Zgłoszenie przyjęte!
</h2>
<p className="text-text-muted mb-2">
{isUrgent
? 'Twoje zgłoszenie oznaczono jako PILNE — skontaktujemy się z Tobą w ciągu 2 godzin.'
: 'Skontaktujemy się z Tobą w ciągu 24 godzin, aby ustalić termin wizyty serwisanta.'}
</p>
<p className="text-sm text-text-muted mb-8">
Jeśli sprawa jest pilna — zadzwoń bezpośrednio:
</p>
<a href={`tel:${companyDetails.phoneRaw}`}>
<button className="flex items-center gap-2 px-6 py-3 bg-accent text-white rounded-xl font-bold mx-auto hover:bg-accent/90 transition-colors mb-4">
<Phone className="size-4" /> {companyDetails.phone}
<div className="max-w-md mx-auto px-4 w-full">
<div className="bg-green-50 text-green-800 p-8 rounded-2xl border border-green-200 flex flex-col items-center text-center">
<CheckCircle2 className="w-16 h-16 text-green-500 mb-4" />
<h3 className="text-2xl font-bold font-heading mb-2">Zgłoszenie przyjęte!</h3>
<p className="text-green-700 mb-2">
{isUrgent
? 'Twoje zgłoszenie oznaczono jako PILNE — skontaktujemy się z Tobą w ciągu 2 godzin.'
: 'Skontaktujemy się z Tobą w ciągu 24 godzin, aby ustalić termin wizyty serwisanta.'}
</p>
<p className="text-sm text-green-700/80 mb-6">
Jeśli sprawa jest pilna — zadzwoń bezpośrednio: {companyDetails.phone}
</p>
<button
onClick={() => setStep('form')}
className="mt-2 px-6 py-2 bg-green-600 text-white rounded-lg font-semibold hover:bg-green-700 transition-colors"
>
Wyślij kolejne zgłoszenie
</button>
</a>
<Link href="/" className="text-sm text-text-muted hover:text-accent transition-colors">
Wróć na stronę główną
</Link>
</div>
</div>
</main>
);
+3 -8
View File
@@ -6,6 +6,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { Loader2, CheckCircle2, AlertCircle, Check } from 'lucide-react';
import { submitContactForm } from '@/app/kontakt/actions';
import { getRecaptchaToken } from '@/lib/getRecaptchaToken';
const contactFormSchema = z.object({
name: z.string().min(2, "Imię musi mieć min. 2 znaki"),
@@ -49,11 +50,8 @@ export function ContactForm() {
});
formData.append("consent", consent ? 'true' : 'false');
if (process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY) {
const token = await (window as any).grecaptcha.execute(
process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,
{ action: 'submit' }
);
const token = await getRecaptchaToken('submit');
if (token) {
formData.append('recaptchaToken', token);
}
@@ -187,9 +185,6 @@ export function ContactForm() {
<option value="">Wybierz temat...</option>
<option value="klimatyzacja">Klimatyzacja</option>
<option value="pompy-ciepla">Pompy ciepła</option>
<option value="remonty">Remonty i wykończenia</option>
<option value="hydraulika">Hydraulika</option>
<option value="serwis-agd">Serwis AGD</option>
<option value="inne">Inne zapytanie</option>
</select>
{errors.subject && <p className="text-red-500 text-xs font-medium">{errors.subject.message}</p>}
+14 -14
View File
@@ -1,8 +1,9 @@
'use client';
import { useState } from 'react';
import { Check, Loader2 } from 'lucide-react';
import { Check, Loader2, CheckCircle2 } from 'lucide-react';
import { submitMultisplitForm } from '@/app/zapytanie-multisplit/actions';
import { getRecaptchaToken } from '@/lib/getRecaptchaToken';
interface Props {
productName: string;
@@ -39,13 +40,8 @@ export default function MultisplitContactForm({ productName, productSku }: Props
setLoading(true);
setError('');
try {
let recaptchaToken = '';
if (process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY) {
recaptchaToken = await (window as any).grecaptcha.execute(
process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY,
{ action: 'submit' }
);
}
const token = await getRecaptchaToken('submit');
const recaptchaToken = token || '';
const res = await submitMultisplitForm({
name: form.name,
@@ -69,12 +65,16 @@ export default function MultisplitContactForm({ productName, productSku }: Props
if (sent) {
return (
<div className="flex flex-col items-center justify-center gap-3 py-12 text-center">
<div className="size-12 bg-green-100 rounded-full flex items-center justify-center">
<Check className="size-6 text-green-600" />
</div>
<p className="font-bold text-primary">Zapytanie wysłane!</p>
<p className="text-sm text-text-muted">Oddzwonimy w ciągu 24 godzin z bezpłatną wyceną.</p>
<div className="bg-green-50 text-green-800 p-8 rounded-2xl border border-green-200 flex flex-col items-center text-center">
<CheckCircle2 className="w-16 h-16 text-green-500 mb-4" />
<h3 className="text-2xl font-bold font-heading mb-2">Zapytanie wysłane!</h3>
<p className="text-green-700">Oddzwonimy w ciągu 24 godzin z bezpłatną wyceną.</p>
<button
onClick={() => setSent(false)}
className="mt-6 px-6 py-2 bg-green-600 text-white rounded-lg font-semibold hover:bg-green-700 transition-colors"
>
Wyślij kolejne zapytanie
</button>
</div>
);
}