This commit is contained in:
@@ -9,10 +9,12 @@ export default function SettingsForm({
|
||||
defaultRestaurantName,
|
||||
defaultLocation,
|
||||
defaultLogoUrl,
|
||||
defaultGoogleReviewUrl,
|
||||
}: {
|
||||
defaultRestaurantName: string
|
||||
defaultLocation: string
|
||||
defaultLogoUrl: string
|
||||
defaultGoogleReviewUrl?: string
|
||||
}) {
|
||||
const [state, action, isPending] = useActionState(saveSettings, undefined)
|
||||
const [logoUrl, setLogoUrl] = useState(defaultLogoUrl)
|
||||
@@ -146,6 +148,21 @@ export default function SettingsForm({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Google Review Url */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
Google Yorum Linki
|
||||
</label>
|
||||
<input
|
||||
type="url"
|
||||
name="google_review_url"
|
||||
defaultValue={defaultGoogleReviewUrl}
|
||||
placeholder="https://g.page/r/..."
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-colors"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">Eğer buraya link eklerseniz site açılışında ziyaretçilere yorum yapmaları için popup gösterilir.</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isPending || uploading}
|
||||
|
||||
@@ -7,6 +7,7 @@ export async function saveSettings(_prevState: unknown, formData: FormData) {
|
||||
const restaurant_name = formData.get('restaurant_name') as string
|
||||
const location = formData.get('location') as string
|
||||
const logo_url = formData.get('logo_url') as string
|
||||
const google_review_url = formData.get('google_review_url') as string
|
||||
|
||||
try {
|
||||
await prisma.$transaction([
|
||||
@@ -25,6 +26,11 @@ export async function saveSettings(_prevState: unknown, formData: FormData) {
|
||||
update: { value: logo_url || '' },
|
||||
create: { key: 'logo_url', value: logo_url || '' },
|
||||
}),
|
||||
prisma.settings.upsert({
|
||||
where: { key: 'google_review_url' },
|
||||
update: { value: google_review_url || '' },
|
||||
create: { key: 'google_review_url', value: google_review_url || '' },
|
||||
}),
|
||||
])
|
||||
|
||||
revalidatePath('/', 'layout')
|
||||
|
||||
@@ -15,6 +15,7 @@ export default async function SettingsPage() {
|
||||
const restaurantName = settings['restaurant_name'] || 'Moy Beach'
|
||||
const location = settings['location'] || 'Akyaka · Muğla'
|
||||
const logoUrl = settings['logo_url'] || ''
|
||||
const googleReviewUrl = settings['google_review_url'] || ''
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -25,6 +26,7 @@ export default async function SettingsPage() {
|
||||
defaultRestaurantName={restaurantName}
|
||||
defaultLocation={location}
|
||||
defaultLogoUrl={logoUrl}
|
||||
defaultGoogleReviewUrl={googleReviewUrl}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user