From 8e4163e3f08e29f38fe87c59d8cfb91e0fa98063 Mon Sep 17 00:00:00 2001 From: kartofen Date: Mon, 29 Aug 2022 19:01:20 +0300 Subject: everything works --- src/pages/create/[board].astro | 5 ++++- src/pages/create/[board]/[tid].astro | 27 +++++++++++++++++++++++++++ src/pages/create/comment.ts | 17 +++++++++++++++++ src/pages/create/thread.ts | 5 +++-- 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/pages/create/[board]/[tid].astro create mode 100644 src/pages/create/comment.ts (limited to 'src/pages/create') diff --git a/src/pages/create/[board].astro b/src/pages/create/[board].astro index 9c2308f..152277c 100644 --- a/src/pages/create/[board].astro +++ b/src/pages/create/[board].astro @@ -1,4 +1,6 @@ --- +import '../../styles/blackbox.css'; + import Default from '../../layouts/Default.astro'; import Form from '../../components/Form.astro'; @@ -8,7 +10,7 @@ const { board } = Astro.params;

{board}

-
+
@@ -21,5 +23,6 @@ const { board } = Astro.params; diff --git a/src/pages/create/[board]/[tid].astro b/src/pages/create/[board]/[tid].astro new file mode 100644 index 0000000..ccc95ca --- /dev/null +++ b/src/pages/create/[board]/[tid].astro @@ -0,0 +1,27 @@ +--- +import '../../../styles/blackbox.css'; + +import Default from '../../../layouts/Default.astro'; +import Form from '../../../components/Form.astro'; + +const { board, tid } = Astro.params; +--- + + +

Comment

+ + + + +
+ + + +
+ + diff --git a/src/pages/create/comment.ts b/src/pages/create/comment.ts new file mode 100644 index 0000000..f8d4c82 --- /dev/null +++ b/src/pages/create/comment.ts @@ -0,0 +1,17 @@ +import { api } from '../../lib/api'; +import { processCommentOut } from '../../lib/thread'; +import Comment from '../../models/Thread'; + +export async function post({ request }) { + const form = await request.formData(); + + let c: Comment = await processCommentOut(form); + + console.log(c); + + await api('post', `comment/${form.get('board')}/${form.get('tid')}`, JSON.stringify(c)); + + return new Response('close', { + status: 200 + }); +} diff --git a/src/pages/create/thread.ts b/src/pages/create/thread.ts index 0a0b7d1..b3a02be 100644 --- a/src/pages/create/thread.ts +++ b/src/pages/create/thread.ts @@ -1,13 +1,14 @@ import { api } from '../../lib/api'; import { processThreadOut } from '../../lib/thread'; +import Thread from '../../models/Thread'; export async function post({ request }) { const form = await request.formData(); - console.log(form); - let t: Thread = await processThreadOut(form); + console.log(t); + await api('post', `thread/${form.get('board')}`, JSON.stringify(t)); return new Response(t.id, { -- cgit v1.2.3