"use client"; import { useActionState, useEffect, useRef, useState, useTransition } from "react"; import { useRouter } from "next/navigation"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Plus, Trash2 } from "lucide-react"; import { addUser, deleteUser, sendTestEmail, type ActionResult } from "@/actions/settings"; import { updateDefaultPrice } from "@/actions/pricing"; import { toast } from "sonner"; import type { AppUser, FuelSettings } from "@/lib/types"; const initial: ActionResult = { ok: false, error: "" }; interface Props { currentUserId: string; settings: FuelSettings | null; users: AppUser[]; } export function SettingsForms({ currentUserId, settings, users }: Props) { const router = useRouter(); const [defaultPrice, setDefaultPrice] = useState(settings?.default_price_per_litre || 0); function onSaveDefault() { startTransition(async () => { const res = await updateDefaultPrice(defaultPrice); if (res.ok) { toast.success("Default price saved"); router.refresh(); } else { toast.error(res.error); } }); } const [, startTransition] = useTransition(); const [testEmail, setTestEmail] = useState(""); function onSendTest() { if (!testEmail) { toast.error("Enter a recipient email"); return; } startTransition(async () => { const res = await sendTestEmail(testEmail); if (res.ok) toast.success("Test email sent"); else toast.error(res.error); }); } return (
Fuel price, email, users, and price increase
Configured sender
rjbulk01@gmail.com
Gmail credentials are managed by the deployment environment and are not stored in PocketBase.