// Author: Shiv // Date: April 2026 "use client"; import { useState, useEffect } from "react"; import { useAuth } from "@/context/AuthContext"; const labelCls = "flex flex-col gap-[0.35rem] text-[0.9rem] font-semibold text-[#444]"; const inputCls = "px-[0.85rem] py-[0.6rem] border border-[#ddd] rounded-lg text-base outline-none transition-all focus:border-[#e68672] focus:shadow-[0_0_0_3px_rgba(230,134,114,0.2)]"; const submitBtnCls = "mt-2 py-3 bg-[#e68672] text-white border-none rounded-lg text-base font-bold cursor-pointer transition-all hover:bg-[#d4705e] active:scale-[0.98] disabled:opacity-60 disabled:cursor-not-allowed"; //Returns the image path for a store, guessing from the store name if no image is set function getStoreImage(store) { if (store.imageUrl) return store.imageUrl; const name = store.storeName?.toLowerCase() ?? ""; if (name.includes("downtown")) return "/stores/downtown.webp"; if (name.includes("north")) return "/stores/north.webp"; if (name.includes("west")) return "/stores/west.webp"; return "/images/pet-placeholder.png"; } //Contact page with a message form on the left and store location cards on the right export default function ContactPage() { const { token } = useAuth(); const [locations, setLocations] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [subject, setSubject] = useState(""); const [body, setBody] = useState(""); const [sending, setSending] = useState(false); const [sendError, setSendError] = useState(null); const [sendSuccess, setSendSuccess] = useState(false); //Loads all store locations when the page first opens useEffect(() => { const params = new URLSearchParams({ page: "0", size: "100", sort: "storeName,asc" }); fetch(`/api/v1/stores?${params}`) .then((res) => { if (!res.ok) throw new Error("Unable to load store, please try again later."); return res.json(); }) .then((data) => setLocations(data.content ?? [])) .catch(() => setError("Unable to load store, please try again later.")) .finally(() => setLoading(false)); }, []); //Submits the contact form to the backend async function handleSend(e) { e.preventDefault(); if (!token) { setSendError("Please log in to send a message."); return; } setSending(true); setSendError(null); try { const res = await fetch("/api/v1/contact", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, body: JSON.stringify({ subject, body }), }); if (!res.ok) throw new Error(`HTTP ${res.status}`); setSendSuccess(true); setSubject(""); setBody(""); } catch { setSendError("Failed to send message. Please try again."); } finally { setSending(false); } } return (

Contact Us

Reach the team, find a location, or send us a message.

Get in Touch

Email: hello@leonspetstore.com.au

Phone: (03) 9000 0000

Hours: Mon–Sat, 9:00 AM – 6:00 PM

Send Us a Message

{sendSuccess ? (

Your message has been sent. We'll be in touch soon.

) : (