AUTOFORGE PARTS
ShopFeatured
Sign inCart
Shop / Body Parts
Chevy truck bed

gku

Chevy truck bed

$1000.00$800.00
In stock (9 available)

insert into public.homepage_blocks (block_type, title, subtitle, config, is_active, sort_order) values ('faqs', 'Frequently Asked Questions', null, '{"limit": 6}', true, 13);

Vehicle fitment

Universal fit / fitment not specified.

OEM numbers: 5557, 7559, 8585, 8587

Cross-reference: 5557, 7559, 8585, 8587

Description

"use client"; import { useActionState, useState } from "react"; import Image from "next/image"; import { createClient } from "@/lib/supabase/client"; import { updatePaymentMethod, updatePaymentMethodImage, type SimpleFormState } from "@/lib/actions/payment-methods"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import type { Tables } from "@/lib/types/database.types"; const initialState: SimpleFormState = {}; export function PaymentMethodForm({ method }: { method: Tables<"payment_methods"> }) { const [state, formAction, isPending] = useActionState(updatePaymentMethod.bind(null, method.id), initialState); const [logoUrl, setLogoUrl] = useState(method.logo_url); const [isUploading, setIsUploading] = useState(false); const [uploadError, setUploadError] = useState<string | null>(null); async function handleLogoChange(e: React.ChangeEvent<HTMLInputElement>) { const file = e.target.files?.[0]; if (!file) return; setUploadError(null); setIsUploading(true); const supabase = createClient(); const ext = file.name.split(".").pop() || "bin"; const path = `payment-methods/${method.id}/logo-${Date.now()}.${ext}`; const { error } = await supabase.storage.from("media-library").upload(path, file, { upsert: true }); if (error) { setUploadError(error.message); setIsUploading(false); return; } const { data: { publicUrl }, } = supabase.storage.from("media-library").getPublicUrl(path); const result = await updatePaymentMethodImage(method.id, "logo_url", publicUrl); setIsUploading(false); if (result.error) { setUploadError(result.error); return; } setLogoUrl(publicUrl); } return ( <form action={formAction} className="max-w-2xl space-y-6"> {state.error && ( <p role="alert" className="rounded-sm bg-destructive/10 px-4 py-3 text-sm text-destructive"> {state.error} </p> )} <div className="rounded-md border border-line bg-white p-6 space-y-4"> <div> <Label>Logo</Label> <div className="mt-2 flex items-center gap-4"> {logoUrl ? ( <div className="relative h-16 w-16 overflow-hidden rounded-md border border-line bg-paper"> <Image src={logoUrl} alt="" fill className="object-contain p-2" unoptimized /> </div> ) : ( <div className="flex h-16 w-16 items-center justify-center rounded-md border border-dashed border-line text-xs text-muted"> None </div> )} <label> <input type="file" accept="image/png,image/jpeg,image/webp" className="hidden" onChange={handleLogoChange} disabled={isUploading} /> <Button asChild variant="outline" size="sm" type="button"> <span className="cursor-pointer">{isUploading ? "Uploading…" : logoUrl ? "Replace" : "Upload"}</span> </Button> </label> </div> {uploadError && <p className="mt-1 text-xs text-destructive">{uploadError}</p>} </div> <div className="flex items-center justify-between"> <Label htmlFor="is_enabled" className="text-base"> Show at checkout </Label> <Checkbox id="is_enabled" name="is_enabled" defaultChecked={method.is_enabled} /> </div> <div className="space-y-1.5"> <Label htmlFor="display_name">Display name</Label> <Input id="display_name" name="display_name" defaultValue={method.display_name} required /> </div> </div> <div className="flex justify-end"> <Button type="submit" size="lg" disabled={isPending}> {isPending ? "Saving…" : "Save changes"} </Button> </div> </form> ); }

AutoForge Parts

support@example.com

+1 (000) 000-0000

Links

Home

© 2026 AutoForge Parts. All rights reserved.