This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use server" | |
| import { createClient } from '@supabase/supabase-js' | |
| // Make sure to set these environment variables | |
| const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!) | |
| export async function submitForm(data: { name: string, email: string }) { | |
| const { data: result, error } = await supabase | |
| .from('your_table_name') // Replace with your actual table name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "use client" | |
| import { useForm } from "@tanstack/react-form" | |
| import { zodValidator } from "@tanstack/zod-form-adapter" | |
| import { z } from "zod" | |
| import { submitForm } from "./actions" // Make sure to create this file with the server action | |
| import { useState } from "react" | |
| const formSchema = z.object({ | |
| name: z.string().min(2, "Name must be at least 2 characters"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //{schema.fields.map((field) => ( | |
| "use client"; | |
| import { zodValidator } from "@tanstack/zod-form-adapter"; | |
| import { z } from "zod"; | |
| import type { FieldApi } from "@tanstack/react-form"; | |
| import { useForm, formOptions } from "@tanstack/react-form"; | |
| function FieldInfo({ field }: { field: FieldApi<any, any, any, any> }) { | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { useForm } from 'react-hook-form'; | |
| import { zodResolver } from '@hookform/resolvers/zod'; | |
| import { z } from 'zod'; | |
| // Example JSON schema for form fields | |
| const jsonSchema = { | |
| fields: [ | |
| { | |
| name: 'name', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Formik, Form, Field, ErrorMessage } from 'formik'; | |
| import { z } from 'zod'; | |
| // Example JSON schema for form fields | |
| const jsonSchema = { | |
| fields: [ | |
| { | |
| name: 'name', | |
| type: 'text', |