From 8a94d4358e109c81847b5a41ced74d998d7cbead Mon Sep 17 00:00:00 2001 From: Clement Date: Mon, 20 May 2024 18:09:13 +0200 Subject: [PATCH] make user use template --- front/src/components/ui/Form.astro | 4 +-- front/src/components/widgets/Contact.astro | 6 ++++ front/src/pages/account/login.astro | 32 ++++++++++++++++++---- front/src/pages/account/register.astro | 2 ++ front/src/types.d.ts | 7 ++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/front/src/components/ui/Form.astro b/front/src/components/ui/Form.astro index 6ab6b41..7b63ed9 100644 --- a/front/src/components/ui/Form.astro +++ b/front/src/components/ui/Form.astro @@ -2,10 +2,10 @@ import type { Form as Props } from 'types'; import Button from 'components/ui/Button.astro'; -const { inputs, textarea, disclaimer, button = 'Contact us', description = '' } = Astro.props; +const { inputs, textarea, disclaimer, button = 'Contact us', description = '', id, method, enctype } = Astro.props; --- -
+ { inputs && inputs.map( diff --git a/front/src/components/widgets/Contact.astro b/front/src/components/widgets/Contact.astro index 3698361..4222cc4 100644 --- a/front/src/components/widgets/Contact.astro +++ b/front/src/components/widgets/Contact.astro @@ -13,6 +13,9 @@ const { disclaimer, button, description, + formid, + method, + enctype, id, isDark = false, @@ -33,6 +36,9 @@ const { disclaimer={disclaimer} button={button} description={description} + id={formid} + method={method} + enctype={enctype} /> ) diff --git a/front/src/pages/account/login.astro b/front/src/pages/account/login.astro index da1a22a..7ef7cca 100644 --- a/front/src/pages/account/login.astro +++ b/front/src/pages/account/login.astro @@ -3,6 +3,8 @@ import Layout from 'layouts/PageLayout.astro'; //import Layout from 'layouts/Layout.astro'; import AstroUtils from "libs/AstroUtils"; import PocketBase from 'pocketbase' +import ContactUs from 'components/widgets/Contact.astro'; +import FormContainer from 'components/ui/Form.astro'; const pb = Astro.locals.pb @@ -11,7 +13,10 @@ if(pb.authStore.isValid){ return Astro.redirect("/account") } -const res = await AstroUtils.wrap(async () => { +console.log(Astro.request.method); + + +await AstroUtils.wrap(async () => { if (Astro.request.method !== 'POST') { return } @@ -38,9 +43,24 @@ const metadata = { --- - - - - - +
diff --git a/front/src/pages/account/register.astro b/front/src/pages/account/register.astro index f780d8d..39552b4 100644 --- a/front/src/pages/account/register.astro +++ b/front/src/pages/account/register.astro @@ -3,6 +3,8 @@ import Layout from 'layouts/PageLayout.astro'; //import Layout from 'layouts/Layout.astro'; import AstroUtils from 'libs/AstroUtils'; import { getEnv } from 'libs/Env'; +import ContactUs from 'components/widgets/Contact.astro'; +import Form from 'components/ui/Form.astro'; const pb = Astro.locals.pb diff --git a/front/src/types.d.ts b/front/src/types.d.ts index df8ca6e..ee2a0c5 100644 --- a/front/src/types.d.ts +++ b/front/src/types.d.ts @@ -210,6 +210,9 @@ export interface Form { disclaimer?: Disclaimer button?: string description?: string + id?: string + method?: string + enctype?: string } // WIDGETS @@ -285,4 +288,6 @@ export interface Content extends Omit, Widget { callToAction?: CallToAction } -export interface Contact extends Omit, Form, Widget {} +export interface Contact extends Omit, Form, Widget { + formid?: string +}