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
-
-
-
+
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 (