From 51d7117579edcc5f745408dd4c93912ab89f8a81 Mon Sep 17 00:00:00 2001 From: qun <68707557+L-Qun@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:53:43 +0000 Subject: [PATCH] chore: prettier --- README.MD | 4 +- examples/react19/official-exp/app/actions.ts | 50 +++++++++---------- .../react19/official-exp/app/add-form.tsx | 20 ++++---- .../react19/official-exp/app/delete-form.tsx | 20 ++++---- examples/react19/official-exp/app/layout.tsx | 12 ++--- examples/react19/official-exp/app/page.tsx | 14 +++--- .../react19/server-actions/tailwind.config.js | 14 +++--- 7 files changed, 66 insertions(+), 68 deletions(-) diff --git a/README.MD b/README.MD index a844123..9c5c548 100644 --- a/README.MD +++ b/README.MD @@ -3,9 +3,7 @@ State Management Collection

- - State Management Collection - + State Management Collection diff --git a/examples/react19/official-exp/app/actions.ts b/examples/react19/official-exp/app/actions.ts index dee0d8c..f204900 100644 --- a/examples/react19/official-exp/app/actions.ts +++ b/examples/react19/official-exp/app/actions.ts @@ -1,12 +1,12 @@ -"use server"; +'use server' -import { revalidatePath } from "next/cache"; -import postgres from "postgres"; -import { z } from "zod"; +import { revalidatePath } from 'next/cache' +import postgres from 'postgres' +import { z } from 'zod' let sql = postgres(process.env.DATABASE_URL || process.env.POSTGRES_URL!, { - ssl: "allow", -}); + ssl: 'allow', +}) // CREATE TABLE todos ( // id SERIAL PRIMARY KEY, @@ -15,60 +15,60 @@ let sql = postgres(process.env.DATABASE_URL || process.env.POSTGRES_URL!, { export async function createTodo( prevState: { - message: string; + message: string }, formData: FormData, ) { const schema = z.object({ todo: z.string().min(1), - }); + }) const parse = schema.safeParse({ - todo: formData.get("todo"), - }); + todo: formData.get('todo'), + }) if (!parse.success) { - return { message: "Failed to create todo" }; + return { message: 'Failed to create todo' } } - const data = parse.data; + const data = parse.data try { await sql` INSERT INTO todos (text) VALUES (${data.todo}) - `; + ` - revalidatePath("/"); - return { message: `Added todo ${data.todo}` }; + revalidatePath('/') + return { message: `Added todo ${data.todo}` } } catch (e) { - return { message: "Failed to create todo" }; + return { message: 'Failed to create todo' } } } export async function deleteTodo( prevState: { - message: string; + message: string }, formData: FormData, ) { const schema = z.object({ id: z.string().min(1), todo: z.string().min(1), - }); + }) const data = schema.parse({ - id: formData.get("id"), - todo: formData.get("todo"), - }); + id: formData.get('id'), + todo: formData.get('todo'), + }) try { await sql` DELETE FROM todos WHERE id = ${data.id}; - `; + ` - revalidatePath("/"); - return { message: `Deleted todo ${data.todo}` }; + revalidatePath('/') + return { message: `Deleted todo ${data.todo}` } } catch (e) { - return { message: "Failed to delete todo" }; + return { message: 'Failed to delete todo' } } } diff --git a/examples/react19/official-exp/app/add-form.tsx b/examples/react19/official-exp/app/add-form.tsx index 4f5bb96..40b6e7e 100644 --- a/examples/react19/official-exp/app/add-form.tsx +++ b/examples/react19/official-exp/app/add-form.tsx @@ -1,25 +1,25 @@ -"use client"; +'use client' -import { useActionState } from "react"; -import { useFormStatus } from "react-dom"; -import { createTodo } from "@/app/actions"; +import { useActionState } from 'react' +import { useFormStatus } from 'react-dom' +import { createTodo } from '@/app/actions' const initialState = { - message: "", -}; + message: '', +} function SubmitButton() { - const { pending } = useFormStatus(); + const { pending } = useFormStatus() return ( - ); + ) } export function AddForm() { - const [state, formAction] = useActionState(createTodo, initialState); + const [state, formAction] = useActionState(createTodo, initialState) return (
@@ -30,5 +30,5 @@ export function AddForm() { {state?.message}

- ); + ) } diff --git a/examples/react19/official-exp/app/delete-form.tsx b/examples/react19/official-exp/app/delete-form.tsx index b15eb19..e6754bd 100644 --- a/examples/react19/official-exp/app/delete-form.tsx +++ b/examples/react19/official-exp/app/delete-form.tsx @@ -1,25 +1,25 @@ -"use client"; +'use client' -import { useActionState } from "react"; -import { useFormStatus } from "react-dom"; -import { deleteTodo } from "@/app/actions"; +import { useActionState } from 'react' +import { useFormStatus } from 'react-dom' +import { deleteTodo } from '@/app/actions' const initialState = { - message: "", -}; + message: '', +} function DeleteButton() { - const { pending } = useFormStatus(); + const { pending } = useFormStatus() return ( - ); + ) } export function DeleteForm({ id, todo }: { id: number; todo: string }) { - const [state, formAction] = useActionState(deleteTodo, initialState); + const [state, formAction] = useActionState(deleteTodo, initialState) return (
@@ -30,5 +30,5 @@ export function DeleteForm({ id, todo }: { id: number; todo: string }) { {state?.message}

- ); + ) } diff --git a/examples/react19/official-exp/app/layout.tsx b/examples/react19/official-exp/app/layout.tsx index 5921f43..193d648 100644 --- a/examples/react19/official-exp/app/layout.tsx +++ b/examples/react19/official-exp/app/layout.tsx @@ -1,18 +1,18 @@ -import "./global.css"; +import './global.css' export const metadata = { - title: "Next.js Forms Example", - description: "Example application with forms and Postgres.", -}; + title: 'Next.js Forms Example', + description: 'Example application with forms and Postgres.', +} export default function RootLayout({ children, }: { - children: React.ReactNode; + children: React.ReactNode }) { return ( {children} - ); + ) } diff --git a/examples/react19/official-exp/app/page.tsx b/examples/react19/official-exp/app/page.tsx index e2ab769..63c054b 100644 --- a/examples/react19/official-exp/app/page.tsx +++ b/examples/react19/official-exp/app/page.tsx @@ -1,14 +1,14 @@ -import postgres from "postgres"; +import postgres from 'postgres' -import { AddForm } from "@/app/add-form"; -import { DeleteForm } from "@/app/delete-form"; +import { AddForm } from '@/app/add-form' +import { DeleteForm } from '@/app/delete-form' let sql = postgres(process.env.DATABASE_URL || process.env.POSTGRES_URL!, { - ssl: "allow", -}); + ssl: 'allow', +}) export default async function Home() { - let todos = await sql`SELECT * FROM todos`; + let todos = await sql`SELECT * FROM todos` return (
@@ -23,5 +23,5 @@ export default async function Home() { ))}
- ); + ) } diff --git a/examples/react19/server-actions/tailwind.config.js b/examples/react19/server-actions/tailwind.config.js index 78ebc4e..8c4d1b2 100644 --- a/examples/react19/server-actions/tailwind.config.js +++ b/examples/react19/server-actions/tailwind.config.js @@ -1,18 +1,18 @@ /** @type {import('tailwindcss').Config} */ module.exports = { content: [ - "./pages/**/*.{js,ts,jsx,tsx,mdx}", - "./components/**/*.{js,ts,jsx,tsx,mdx}", - "./app/**/*.{js,ts,jsx,tsx,mdx}", + './pages/**/*.{js,ts,jsx,tsx,mdx}', + './components/**/*.{js,ts,jsx,tsx,mdx}', + './app/**/*.{js,ts,jsx,tsx,mdx}', ], theme: { extend: { backgroundImage: { - "gradient-radial": "radial-gradient(var(--tw-gradient-stops))", - "gradient-conic": - "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))", + 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', + 'gradient-conic': + 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', }, }, }, plugins: [], -}; +}