{"id":482495,"date":"2026-06-05T09:19:20","date_gmt":"2026-06-05T09:19:20","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=482495"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=482495","title":{"rendered":"Server Actions \u0431\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e API, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 useActionState \u0434\u043b\u044f inline CRUD \u0432 Next.js"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 Next.js \u0444\u043e\u0440\u043c\u044b \u0438 inline CRUD \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0443\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0443. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0439 API: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 route handler, fetch \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 pending, error, success, \u043f\u043b\u044e\u0441 \u0441\u0432\u043e\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f blur, Enter, Escape \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. \u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0435\u0440\u043f\u0438\u043c\u043e. \u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e inline-\u0444\u043e\u0440\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435, \u043a\u043e\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435, \u0430 \u043f\u043e \u043e\u0431\u0432\u044f\u0437\u043a\u0435.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 endpoint, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 submit, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f UI \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 Server Actions \u0432 App Router \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0444\u043e\u0440\u043c \u0438 inline-\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0443\u044e write-\u0442\u043e\u0447\u043a\u0443.<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Workbench \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0441\u0435\u043a\u0446\u0438\u0439 \u0438 \u0437\u0430\u043c\u0435\u0442\u043e\u043a. \u0423 \u0444\u043e\u0440\u043c\u044b \u0435\u0441\u0442\u044c action, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 FormData, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u0436\u0438\u0432\u0451\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430: state, formAction, isPending. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0444\u043e\u0440\u043c\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u0430 \u043d\u0435 \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.<\/p>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0440\u0443\u0447\u043d\u043e\u0433\u043e API<\/h3>\n<p>\u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0440\u0443\u0447\u043d\u043e\u0439 API \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u0432\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 \u0440\u0430\u0437\u0440\u044b\u0432\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u0442 title \u043f\u0440\u044f\u043c\u043e \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430: \u043a\u043b\u0438\u0435\u043d\u0442 \u043b\u043e\u0432\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 payload, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 fetch, \u0436\u0434\u0451\u0442 JSON, \u043f\u0430\u0440\u0441\u0438\u0442 \u043e\u0442\u0432\u0435\u0442, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438, \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 inline-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 UI. \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430. \u0413\u0434\u0435-\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 success boolean, \u0433\u0434\u0435-\u0442\u043e error string, \u0433\u0434\u0435-\u0442\u043e fieldErrors, \u0433\u0434\u0435-\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e inline CRUD \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u0440\u043e\u0433\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0436\u0438\u0432\u0451\u0442 \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Enter, blur, Escape \u0438 pending \u0431\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<h3>\u0427\u0442\u043e\u0431\u044b Server Actions \u043b\u043e\u0436\u0438\u043b\u0438\u0441\u044c \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e<\/h3>\n<p>\u0412 App Router \u0444\u043e\u0440\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u042d\u0442\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0443\u0447\u043d\u043e\u0439 fetch \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u044f\u0432\u043d\u044b\u043c. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 write-endpoint \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0435\u0441\u043b\u0438 \u0441\u0430\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u043e\u0439.<\/p>\n<p>\u0412 Workbench \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u043e\u0431\u0440\u0430\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/server\/actions\/workbenchFormActions.ts\"use server\";import { revalidatePath } from \"next\/cache\";import { readWorkbenchDb, writeWorkbenchDb } from \"@\/server\/workbenchDb\";import { titleSchema } from \"@\/lib\/schemas\";import type { RenameProjectFormState } from \"@\/lib\/formTypes\";export async function renameProjectFromForm(  _prev: RenameProjectFormState,  formData: FormData): Promise&lt;RenameProjectFormState&gt; {  const projectId = String(formData.get(\"projectId\") ?? \"\");  const titleRaw = String(formData.get(\"title\") ?? \"\");  if (!projectId) {    return { ok: false, error: \"\u041d\u0435\u0442 projectId\", fieldErrors: {} };  }  const parsed = titleSchema.safeParse(titleRaw);  if (!parsed.success) {    return {      ok: false,      error: null,      fieldErrors: {        title: parsed.error.issues[0]?.message ?? \"\u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\",      },    };  }  const db = await readWorkbenchDb();  const project = db.projects.find((x) =&gt; x.id === projectId);  if (!project) {    return { ok: false, error: \"\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\", fieldErrors: {} };  }  project.title = parsed.data;  await writeWorkbenchDb(db);  revalidatePath(\"\/\");  return { ok: true, projectId, clientId: projectId };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Action \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0438 FormData, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c write-\u0442\u043e\u0447\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c UI \u0443\u043c\u0435\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<h3>write-\u0442\u043e\u0447\u043a\u0430 \u0436\u0438\u0432\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 actions<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 actions, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u043e. UI \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d \u043b\u0438\u0431\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0443, \u043b\u0438\u0431\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043d\u043e \u0441\u0430\u043c\u0430 \u0437\u0430\u043f\u0438\u0441\u044c, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u043e\u0435 Workbench, \u0433\u0434\u0435 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0430\u0442 payload-based server actions \u0434\u043b\u044f \u043c\u0443\u0442\u0430\u0446\u0438\u0439.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/app\/_actions\/mutations.ts\"use server\";import { revalidatePath } from \"next\/cache\";import { RenameProjectPayloadSchema } from \"@\/lib\/schemas\";import { readWorkbenchDb, writeWorkbenchDb } from \"@\/server\/workbenchDb\";type Result = { ok: true } | { ok: false; error: string };export async function renameProjectAction(payload: unknown): Promise&lt;Result&gt; {  const parsed = RenameProjectPayloadSchema.safeParse(payload);  if (!parsed.success) return { ok: false, error: parsed.error.message };  const { projectId, title } = parsed.data;  const db = await readWorkbenchDb();  const project = db.projects.find((x) =&gt; x.id === projectId);  if (!project) return { ok: false, error: \"\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\" };  project.title = title;  await writeWorkbenchDb(db);  revalidatePath(\"\/\");  return { ok: true };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u043b\u044f inline-\u0444\u043e\u0440\u043c \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 form submit \u043b\u0443\u0447\u0448\u0435 \u043b\u043e\u0436\u0430\u0442\u0441\u044f actions, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 FormData \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 useActionState. \u0414\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0443\u0442\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c payload-based actions. \u041d\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0434\u0451\u0442 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0439 fetch \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e write-\u0442\u043e\u0447\u043a\u0443.<\/p>\n<h3>\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u0444\u043e\u0440\u043c\u044b \u0447\u0435\u0440\u0435\u0437 useActionState<\/h3>\n<p>\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u044d\u0442\u043e useActionState. \u041e\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0443\u0447\u043d\u043e\u0439 fetch. \u041e\u043d \u0434\u0430\u0451\u0442 \u0444\u043e\u0440\u043c\u0435 \u0442\u0440\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u044f\u0441\u043d\u043e\u0439 \u0440\u043e\u043b\u044c\u044e: state, formAction \u0438 isPending.<\/p>\n<p>\u0412 \u0434\u0435\u043c\u043e Workbench \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/app\/(demo)\/form-lab\/form-lab-client.tsx\"use client\";import { useActionState, useState } from \"react\";import { submitFormLabFromForm } from \"@\/demo\/server\/actions\/formLabActions\";import { formLabFormInitialState } from \"@\/lib\/formStates\";import type { FormLabFormState } from \"@\/lib\/formTypes\";export default function FormLabClient() {  const [title, setTitle] = useState(\"\");  const [state, formAction, isPending] = useActionState&lt;FormLabFormState, FormData&gt;(    submitFormLabFromForm,    formLabFormInitialState  );  return (    &lt;form      action={formAction}      onSubmit={() =&gt; {        setTitle(\"\");      }}    &gt;      &lt;input        name=\"title\"        value={title}        onChange={(e) =&gt; setTitle(e.target.value)}        disabled={isPending}      \/&gt;      &lt;button type=\"submit\" disabled={title.trim().length === 0 || isPending}&gt;        {isPending ? \"\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430\u2026\" : \"\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c\"}      &lt;\/button&gt;      {state.ok === false &amp;&amp; state.fieldErrors.title ? (        &lt;div&gt;{state.fieldErrors.title}&lt;\/div&gt;      ) : state.ok === false &amp;&amp; state.error ? (        &lt;div&gt;{state.error}&lt;\/div&gt;      ) : null}    &lt;\/form&gt;  );}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0424\u043e\u0440\u043c\u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e server error, pending \u0438 success \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 useState. \u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0433\u043e inline CRUD \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0444\u043b\u0430\u0433\u043e\u0432 \u0432\u043e\u043a\u0440\u0443\u0433 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0423 \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 initialState \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 UI<\/h3>\n<p>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0422\u043e\u0433\u0434\u0430 UI \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u0430\u043c \u043f\u043e \u043c\u0435\u0441\u0442\u0443, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 formStates.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/lib\/formStates.tsimport type {  CreateProjectFormState,  RenameProjectFormState,  DeleteProjectFormState,} from \"@\/lib\/formTypes\";export const createProjectFormInitialState: CreateProjectFormState = {  ok: false,  error: null,  fieldErrors: {},};export const renameProjectFormInitialState: RenameProjectFormState = {  ok: false,  error: null,  fieldErrors: {},};export const deleteProjectFormInitialState: DeleteProjectFormState = {  ok: false,  error: null,};<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0410 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0438\u0442 \u0442\u0438\u043f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/lib\/formTypes.tsexport type RenameProjectFormState =  | { ok: true; projectId: string; clientId: string }  | { ok: false; error: string | null; fieldErrors: { title?: string } };export type DeleteProjectFormState =  | { ok: true; projectId: string }  | { ok: false; error: string | null };<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b. \u0412\u0441\u0451 \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0440\u044f\u0434\u043e\u043c \u0441 action-\u0441\u043b\u043e\u0435\u043c, \u0430 useActionState \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c.<\/p>\n<h3>submit \u0438 \u0440\u0438\u0442\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 Inline CRUD<\/h3>\n<p>\u041e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0436\u0438\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c. Inline CRUD \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0438\u0442\u043c. Enter \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442, blur \u0442\u043e\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442, Escape \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442, pending \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0435\u0440\u0435\u0432\u0430, \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0443 \u043f\u043e\u043b\u044f, \u0430 \u043d\u0435 \u0433\u0434\u0435-\u0442\u043e \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0435.<\/p>\n<p>\u0412 Workbench \u044d\u0442\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0432 action-\u043a\u043b\u0438\u0435\u043d\u0442\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"javascript\">\/\/ src\/components\/forms\/RenameProjectInlineActionClient.tsx\"use client\";import { useActionState, useEffect, useRef } from \"react\";import { useRouter } from \"next\/navigation\";import { renameProjectFromForm } from \"@\/server\/actions\/workbenchFormActions\";import { renameProjectFormInitialState } from \"@\/lib\/formStates\";import { useWorkbenchStore } from \"@\/lib\/workbenchStore\";export default function RenameProjectInlineActionClient({  projectId,  initialValue,  onCancel,}: {  projectId: Id;  initialValue: string;  onCancel: () =&gt; void;}) {  const store = useWorkbenchStore();  const formRef = useRef&lt;HTMLFormElement | null&gt;(null);  const inputRef = useRef&lt;HTMLInputElement | null&gt;(null);  const [state, formAction, isPending] = useActionState(    renameProjectFromForm,    renameProjectFormInitialState  );  const router = useRouter();  useEffect(() =&gt; {    inputRef.current?.focus();    inputRef.current?.select();  }, []);  const submitAndClose = () =&gt; {    const raw = inputRef.current?.value ?? \"\";    const title = raw.trim();    if (title.length &lt; 2) return;    store.renameProjectLocal(projectId, title);    formRef.current?.requestSubmit();    router.refresh();    onCancel();  };  return (    &lt;form ref={formRef} action={formAction}&gt;      &lt;input type=\"hidden\" name=\"projectId\" value={projectId} \/&gt;      &lt;input        ref={inputRef}        name=\"title\"        defaultValue={initialValue}        disabled={isPending}        onKeyDown={(e) =&gt; {          if (e.key === \"Enter\") {            e.preventDefault();            e.stopPropagation();            submitAndClose();          }          if (e.key === \"Escape\") {            e.preventDefault();            e.stopPropagation();            onCancel();          }        }}        onBlur={() =&gt; {          submitAndClose();        }}      \/&gt;    &lt;\/form&gt;  );}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0438\u0434\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f Server Actions \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0440\u0443\u0447\u043d\u043e\u0433\u043e API. \u0424\u043e\u0440\u043c\u0430 \u043d\u0435 \u0434\u0443\u043c\u0430\u0435\u0442 \u043e fetch \u0438 response parsing. \u041e\u043d\u0430 \u0434\u0443\u043c\u0430\u0435\u0442 \u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 inline-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. Enter \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, blur \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c, Escape \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c, pending \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0435, \u043e\u0448\u0438\u0431\u043a\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u044f\u0434\u043e\u043c. \u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u0430 \u043a \u0444\u043e\u0440\u043c\u0435 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438.<\/p>\n<h3>Pending UI \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/h3>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u0442\u0438\u043f\u043e\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c UI \u0440\u0435\u0430\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 pending. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 state, \u0441\u043f\u0438\u043d\u043d\u0435\u0440 \u0436\u0438\u0432\u0451\u0442 \u0441\u0432\u043e\u0435\u0439 \u0436\u0438\u0437\u043d\u044c\u044e, \u043a\u043d\u043e\u043f\u043a\u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, input \u0432 \u0434\u0440\u0443\u0433\u043e\u043c, \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0443\u0437\u043d\u0430\u0451\u0442 \u043e pending \u0447\u0435\u0440\u0435\u0437 \u0442\u0440\u0435\u0442\u0438\u0439 \u043a\u0430\u043d\u0430\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e inline-edit \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442, pending \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043b\u0451\u0433\u043a\u0438\u043c \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u043c, \u0430 \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u043c. \u041f\u043e\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 disabled, \u0444\u043e\u0440\u043c\u0430 \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0438\u0433\u043b\u0443\u0448\u0430\u0435\u0442\u0441\u044f, \u0440\u044f\u0434\u043e\u043c \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 CreateSectionInlineActionClientconst [state, formAction, isPending] = useActionState(  createSectionFromForm,  createSectionFormInitialState);return (  &lt;form    action={formAction}    className={`space-y-1 ${isPending ? \"opacity-60\" : \"\"}`}  &gt;    &lt;input      name=\"title\"      disabled={isPending}      onBlur={() =&gt; {        formRef.current?.requestSubmit();      }}    \/&gt;    {isPending &amp;&amp; (      &lt;span        aria-label=\"\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u2026\"        className=\"absolute right-3 top-1\/2 -translate-y-1\/2 h-4 w-4 animate-spin rounded-full border-2 border-slate-300 border-t-transparent\"      \/&gt;    )}  &lt;\/form&gt;);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0430\u043a pending \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u0435\u0440\u0435\u0432\u0430 \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u0438 \u043d\u0435 \u0432\u044b\u043f\u0430\u0434\u0430\u0435\u0442 \u0438\u0437 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0438\u0442\u043c\u0430.<\/p>\n<h3>\u0421\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u0438\u00a0\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c inline CRUD \u043e\u0442 optimistic UI<\/h3>\n<p>\u0412 Workbench \u044d\u0442\u043e\u0442 \u0441\u043b\u043e\u0439 \u0441\u0432\u044f\u0437\u0430\u043d \u0435\u0449\u0451 \u0438 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c store. \u0414\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 UI \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c optimistic-\u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0438\u043b\u0438 optimistic-rename, \u0430 \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f. \u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0432 CreateProjectInlineActionClient, CreateSectionInlineActionClient, RenameSectionInlineActionClient \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u0435\u0451.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 CreateProjectInlineActionClientconst clientId = useMemo(() =&gt; crypto.randomUUID(), []);const optimisticId = `p-${clientId}`;const [state, formAction, isPending] = useActionState(  createProjectFromForm,  createProjectFormInitialState);useEffect(() =&gt; {  if (state.ok === false &amp;&amp; (state.error || state.fieldErrors?.title)) {    startTransition(() =&gt; store.removeProjectLocal(optimisticId));  }}, [state, store, optimisticId]);&lt;form  action={formAction}  onSubmit={(e) =&gt; {    const fd = new FormData(e.currentTarget);    const title = String(fd.get(\"title\") ?? \"\").trim();    if (title.length &lt; 2) return;    startTransition(() =&gt; {      store.insertProjectLocal({        id: optimisticId,        title,        structure,        createdAt: new Date().toISOString(),        isDemo: false,      });    });  }}&gt;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438. Server Actions \u0438 useActionState \u0443\u0436\u0435 \u0434\u0430\u044e\u0442 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u0446\u0438\u043a\u043b \u0444\u043e\u0440\u043c\u044b \u0434\u0430\u0436\u0435 \u0431\u0435\u0437 optimistic UI. \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 optimistic-\u0441\u043b\u043e\u0439 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433, \u0430 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0431\u0430\u0437\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 write-\u0442\u043e\u0447\u043a\u0435, \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c form state \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0444\u043e\u0440\u043c\u044b. \u0410 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c useActionState \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f inline-\u0444\u043e\u0440\u043c<\/h3>\n<p>\u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u0435\u0433\u043e \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u0442\u043e\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u044b, \u043d\u043e \u0432 inline CRUD \u043e\u043d\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u043c\u0438. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u043c\u0430\u043b\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0438 \u043c\u0430\u043b\u043e \u0442\u0435\u0440\u043f\u0438\u043c\u043e\u0441\u0442\u0438 \u043a \u043b\u0438\u0448\u043d\u0435\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0435. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e fetch, \u0440\u0443\u0447\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u0440\u0451\u0445 useState \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0434\u044c\u044e\u0441\u0435\u0440\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0434\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e blur, \u0437\u043d\u0430\u0447\u0438\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u0437\u044f\u043b\u0430 \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>useActionState \u0432 \u0442\u0430\u043a\u0438\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043d\u0443\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u0430\u043a \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u0443\u0442\u0438. \u0421\u0435\u0440\u0432\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 typed state, \u043a\u043b\u0438\u0435\u043d\u0442 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0441 \u0444\u043e\u0440\u043c\u043e\u0439, pending \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d, FormData \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0448\u0438\u0431\u043e\u043a \u0437\u0430\u0434\u0430\u043d \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e inline-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>\u0412 Workbench \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u0444\u043e\u0440\u043c\u0430\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f, \u0433\u0434\u0435 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0438\u0442\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437: \u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u043b\u044f \u0441 id, input, requestSubmit \u043d\u0430 blur, Enter \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f, Escape \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b, \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 pending-\u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440, fieldErrors \u0440\u044f\u0434\u043e\u043c \u0441 \u043f\u043e\u043b\u0435\u043c, rollback \u043f\u0440\u0438 \u043d\u0435\u0443\u0441\u043f\u0435\u0445\u0435.<\/p>\n<h3>\u0427\u0442\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0433\u043e\u043b\u043e\u0432\u0435<\/h3>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0440\u0430\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0439 API. \u0424\u043e\u0440\u043c\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0438\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0434\u043e \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0442\u044c fetch-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u041e\u043d\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u043e\u0434\u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441 \u044f\u0441\u043d\u043e\u0439 write-\u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 action \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 FormData \u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e. \u041f\u043e\u0442\u043e\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b. \u041a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 state, formAction \u0438 isPending. \u0414\u0430\u043b\u044c\u0448\u0435 inline UI \u0443\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0439, \u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0434\u0435\u043b\u043e\u043c: \u0444\u043e\u043a\u0443\u0441\u043e\u043c, Enter, blur, Escape, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c pending \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f inline CRUD \u0432 App Router Server Actions \u043e\u0449\u0443\u0449\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430.<\/p>\n<h3>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0438\u0442\u043e\u0433<\/h3>\n<p>\u0415\u0441\u043b\u0438 inline CRUD \u0432 Next.js \u043f\u043e\u043a\u0430 \u0441\u043e\u0431\u0440\u0430\u043d \u0447\u0435\u0440\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0439 API, \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u0441\u043b\u043e\u043c\u0430\u043d. \u041d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0443 \u0444\u043e\u0440\u043c\u044b \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0439 \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d Server Actions \u043f\u043b\u044e\u0441 useActionState \u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0441\u0445\u0435\u043c\u0443. Write-\u0442\u043e\u0447\u043a\u0430 \u0436\u0438\u0432\u0451\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041e\u0442\u0432\u0435\u0442 action \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d. Pending \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0445\u0443\u043a\u0430, \u0430 \u043d\u0435 \u0438\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0444\u043b\u0430\u0433\u0430. Inline-\u0444\u043e\u0440\u043c\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e: \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e Enter \u0438\u043b\u0438 blur, \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e Escape, \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043b\u0438\u0448\u043d\u044e\u044e \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0436\u0438\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/workbench-ts.onrender.com\/\" rel=\"noopener noreferrer nofollow\">Workbench<\/a>.<br \/> \u041f\u043e\u043b\u043d\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u044d\u0442\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u0430 \u0432 Stepik-\u043a\u0443\u0440\u0441\u0435 <a href=\"https:\/\/stepik.org\/a\/275811\" rel=\"noopener noreferrer nofollow\">Next.js II: TypeScript 2026<\/a>.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1043970\/\">https:\/\/habr.com\/ru\/articles\/1043970\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 Next.js \u0444\u043e\u0440\u043c\u044b \u0438 inline CRUD \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0443\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0443. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c \u0438 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0439 API: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 route handler, fetch \u0438\u0437 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 pending, error, success, \u043f\u043b\u044e\u0441 \u0441\u0432\u043e\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f blur, Enter, Escape \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. \u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0435\u0440\u043f\u0438\u043c\u043e. \u041d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e inline-\u0444\u043e\u0440\u043c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044d\u043a\u0440\u0430\u043d\u0435, \u043a\u043e\u0434 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435, \u0430 \u043f\u043e \u043e\u0431\u0432\u044f\u0437\u043a\u0435.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 endpoint, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 submit, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f UI \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0445\u0430 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 Server Actions \u0432 App Router \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0444\u043e\u0440\u043c \u0438 inline-\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u044e\u0442 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0443\u044e write-\u0442\u043e\u0447\u043a\u0443.\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Workbench \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0441\u0435\u043a\u0446\u0438\u0439 \u0438 \u0437\u0430\u043c\u0435\u0442\u043e\u043a. \u0423 \u0444\u043e\u0440\u043c\u044b \u0435\u0441\u0442\u044c action, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 FormData, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u0436\u0438\u0432\u0451\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430: state, formAction, isPending. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0444\u043e\u0440\u043c\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u0430 \u043d\u0435 \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u0440\u043e\u0437\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432.\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0440\u0443\u0447\u043d\u043e\u0433\u043e API\u041d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0440\u0443\u0447\u043d\u043e\u0439 API \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0434\u0432\u0430 \u043b\u0438\u0448\u043d\u0438\u0445 \u0440\u0430\u0437\u0440\u044b\u0432\u0430.\u041f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u0442 title \u043f\u0440\u044f\u043c\u043e \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430: \u043a\u043b\u0438\u0435\u043d\u0442 \u043b\u043e\u0432\u0438\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 payload, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 fetch, \u0436\u0434\u0451\u0442 JSON, \u043f\u0430\u0440\u0441\u0438\u0442 \u043e\u0442\u0432\u0435\u0442, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438, \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 inline-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440.\u0412\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 UI. \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430. \u0413\u0434\u0435-\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 success boolean, \u0433\u0434\u0435-\u0442\u043e error string, \u0433\u0434\u0435-\u0442\u043e fieldErrors, \u0433\u0434\u0435-\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0442\u044c.\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e inline CRUD \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u0440\u043e\u0433\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u0444\u043e\u0440\u043c\u0430 \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0436\u0438\u0432\u0451\u0442 \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Enter, blur, Escape \u0438 pending \u0431\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.\u0427\u0442\u043e\u0431\u044b Server Actions \u043b\u043e\u0436\u0438\u043b\u0438\u0441\u044c \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0412 App Router \u0444\u043e\u0440\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u042d\u0442\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0443\u0447\u043d\u043e\u0439 fetch \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u044f\u0432\u043d\u044b\u043c. \u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 write-endpoint \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0435\u0441\u043b\u0438 \u0441\u0430\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e \u0441\u043c\u044b\u0441\u043b\u0443 \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u043e\u0439.\u0412 Workbench \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u0441\u043e\u0431\u0440\u0430\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.\/\/ src\/server\/actions\/workbenchFormActions.ts&#187;use server&#187;;import { revalidatePath } from &#171;next\/cache&#187;;import { readWorkbenchDb, writeWorkbenchDb } from &#171;@\/server\/workbenchDb&#187;;import { titleSchema } from &#171;@\/lib\/schemas&#187;;import type { RenameProjectFormState } from &#171;@\/lib\/formTypes&#187;;export async function renameProjectFromForm(  _prev: RenameProjectFormState,  formData: FormData): Promise&lt;RenameProjectFormState&gt; {  const projectId = String(formData.get(&#171;projectId&#187;) ?? &#171;&#187;);  const titleRaw = String(formData.get(&#171;title&#187;) ?? &#171;&#187;);  if (!projectId) {    return { ok: false, error: &#171;\u041d\u0435\u0442 projectId&#187;, fieldErrors: {} };  }  const parsed = titleSchema.safeParse(titleRaw);  if (!parsed.success) {    return {      ok: false,      error: null,      fieldErrors: {        title: parsed.error.issues[0]?.message ?? &#171;\u041d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435&#187;,      },    };  }  const db = await readWorkbenchDb();  const project = db.projects.find((x) =&gt; x.id === projectId);  if (!project) {    return { ok: false, error: &#171;\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d&#187;, fieldErrors: {} };  }  project.title = parsed.data;  await writeWorkbenchDb(db);  revalidatePath(&#171;\/&#187;);  return { ok: true, projectId, clientId: projectId };}Action \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0438 FormData, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c write-\u0442\u043e\u0447\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0432 \u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c UI \u0443\u043c\u0435\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u044c.write-\u0442\u043e\u0447\u043a\u0430 \u0436\u0438\u0432\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 actions\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 actions, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u043e. UI \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u041e\u043d \u043b\u0438\u0431\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0443, \u043b\u0438\u0431\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043d\u043e \u0441\u0430\u043c\u0430 \u0437\u0430\u043f\u0438\u0441\u044c, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.\u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u043e\u0435 Workbench, \u0433\u0434\u0435 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0430\u0442 payload-based server actions \u0434\u043b\u044f \u043c\u0443\u0442\u0430\u0446\u0438\u0439.\/\/ src\/app\/_actions\/mutations.ts&#187;use server&#187;;import { revalidatePath } from &#171;next\/cache&#187;;import { RenameProjectPayloadSchema } from &#171;@\/lib\/schemas&#187;;import { readWorkbenchDb, writeWorkbenchDb } from &#171;@\/server\/workbenchDb&#187;;type Result = { ok: true } | { ok: false; error: string };export async function renameProjectAction(payload: unknown): Promise&lt;Result&gt; {  const parsed = RenameProjectPayloadSchema.safeParse(payload);  if (!parsed.success) return { ok: false, error: parsed.error.message };  const { projectId, title } = parsed.data;  const db = await readWorkbenchDb();  const project = db.projects.find((x) =&gt; x.id === projectId);  if (!project) return { ok: false, error: &#171;\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d&#187; };  project.title = title;  await writeWorkbenchDb(db);  revalidatePath(&#171;\/&#187;);  return { ok: true };}\u0414\u043b\u044f inline-\u0444\u043e\u0440\u043c \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 form submit \u043b\u0443\u0447\u0448\u0435 \u043b\u043e\u0436\u0430\u0442\u0441\u044f actions, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435 FormData \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 useActionState. \u0414\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0443\u0442\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c payload-based actions. \u041d\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u0434\u0451\u0442 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0439 fetch \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e write-\u0442\u043e\u0447\u043a\u0443.\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u0444\u043e\u0440\u043c\u044b \u0447\u0435\u0440\u0435\u0437 useActionState\u0426\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0432 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c\u0430\u0445 \u044d\u0442\u043e useActionState. \u041e\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0443\u0447\u043d\u043e\u0439 fetch. \u041e\u043d \u0434\u0430\u0451\u0442 \u0444\u043e\u0440\u043c\u0435 \u0442\u0440\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u044f\u0441\u043d\u043e\u0439 \u0440\u043e\u043b\u044c\u044e: state, formAction \u0438 isPending.\u0412 \u0434\u0435\u043c\u043e Workbench \u044d\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435.\/\/ src\/app\/(demo)\/form-lab\/form-lab-client.tsx&#187;use client&#187;;import { useActionState, useState } from &#171;react&#187;;import { submitFormLabFromForm } from &#171;@\/demo\/server\/actions\/formLabActions&#187;;import { formLabFormInitialState } from &#171;@\/lib\/formStates&#187;;import type { FormLabFormState } from &#171;@\/lib\/formTypes&#187;;export default function FormLabClient() {  const [title, setTitle] = useState(&#171;&#187;);  const [state, formAction, isPending] = useActionState&lt;FormLabFormState, FormData&gt;(    submitFormLabFromForm,    formLabFormInitialState  );  return (    &lt;form      action={formAction}      onSubmit={() =&gt; {        setTitle(&#171;&#187;);      }}    &gt;      &lt;input        name=&#187;title&#187;        value={title}        onChange={(e) =&gt; setTitle(e.target.value)}        disabled={isPending}      \/&gt;      &lt;button type=&#187;submit&#187; disabled={title.trim().length === 0 || isPending}&gt;        {isPending ? &#171;\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430\u2026&#187; : &#171;\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c&#187;}      &lt;\/button&gt;      {state.ok === false &amp;&amp; state.fieldErrors.title ? (        &lt;div&gt;{state.fieldErrors.title}&lt;\/div&gt;      ) : state.ok === false &amp;&amp; state.error ? (        &lt;div&gt;{state.error}&lt;\/div&gt;      ) : null}    &lt;\/form&gt;  );}\u0424\u043e\u0440\u043c\u0430 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e server error, pending \u0438 success \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 useState. \u0412\u0441\u0451 \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u0417\u0430 \u0441\u0447\u0451\u0442 \u044d\u0442\u043e\u0433\u043e inline CRUD \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0444\u043b\u0430\u0433\u043e\u0432 \u0432\u043e\u043a\u0440\u0443\u0433 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0423 \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.\u041f\u043e\u0447\u0435\u043c\u0443 initialState \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 UI\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0422\u043e\u0433\u0434\u0430 UI \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u0430\u043c \u043f\u043e \u043c\u0435\u0441\u0442\u0443, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442.\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 formStates.\/\/ src\/lib\/formStates.tsimport type {  CreateProjectFormState,  RenameProjectFormState,  DeleteProjectFormState,} from &#171;@\/lib\/formTypes&#187;;export const createProjectFormInitialState: CreateProjectFormState = {  ok: false,  error: null,  fieldErrors: {},};export const renameProjectFormInitialState: RenameProjectFormState = {  ok: false,  error: null,  fieldErrors: {},};export const deleteProjectFormInitialState: DeleteProjectFormState = {  ok: false,  error: null,};\u0410 \u0440\u044f\u0434\u043e\u043c \u043b\u0435\u0436\u0438\u0442 \u0442\u0438\u043f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.\/\/ src\/lib\/formTypes.tsexport type RenameProjectFormState =  | { ok: true; projectId: string; clientId: string }  | { ok: false; error: string | null; fieldErrors: { title?: string } };export type DeleteProjectFormState =  | { ok: true; projectId: string }  | { ok: false; error: string | null };\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0447\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0438 \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b. \u0412\u0441\u0451 \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0440\u044f\u0434\u043e\u043c \u0441 action-\u0441\u043b\u043e\u0435\u043c, \u0430 useActionState \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c.submit \u0438 \u0440\u0438\u0442\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 Inline CRUD\u041e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u043e\u0440\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0436\u0438\u0442\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c. Inline CRUD \u0442\u0430\u043a \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0438\u0442\u043c. Enter \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442, blur \u0442\u043e\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442, Escape \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u0442, pending \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u0435\u0440\u0435\u0432\u0430, \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0443 \u043f\u043e\u043b\u044f, \u0430 \u043d\u0435 \u0433\u0434\u0435-\u0442\u043e \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0435.\u0412 Workbench \u044d\u0442\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0432 action-\u043a\u043b\u0438\u0435\u043d\u0442\u0430\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.\/\/ src\/components\/forms\/RenameProjectInlineActionClient.tsx&#187;use client&#187;;import { useActionState, useEffect, useRef } from &#171;react&#187;;import { useRouter } from &#171;next\/navigation&#187;;import { renameProjectFromForm } from &#171;@\/server\/actions\/workbenchFormActions&#187;;import { renameProjectFormInitialState } from &#171;@\/lib\/formStates&#187;;import { useWorkbenchStore } from &#171;@\/lib\/workbenchStore&#187;;export default function RenameProjectInlineActionClient({  projectId,  initialValue,  onCancel,}: {  projectId: Id;  initialValue: string;  onCancel: () =&gt; void;}) {  const store = useWorkbenchStore();  const formRef = useRef&lt;HTMLFormElement | null&gt;(null);  const inputRef = useRef&lt;HTMLInputElement | null&gt;(null);  const [state, formAction, isPending] = useActionState(    renameProjectFromForm,    renameProjectFormInitialState  );  const router = useRouter();  useEffect(() =&gt; {    inputRef.current?.focus();    inputRef.current?.select();  }, []);  const submitAndClose = () =&gt; {    const raw = inputRef.current?.value ?? &#171;&#187;;    const title = raw.trim();    if (title.length &lt; 2) return;    store.renameProjectLocal(projectId, title);    formRef.current?.requestSubmit();    router.refresh();    onCancel();  };  return (    &lt;form ref={formRef} action={formAction}&gt;      &lt;input type=&#187;hidden&#187; name=&#187;projectId&#187; value={projectId} \/&gt;      &lt;input  &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-482495","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/482495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=482495"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/482495\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=482495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=482495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=482495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}