From 0a1e9b194ca89defafa49f0029e3cfdf2e0251c8 Mon Sep 17 00:00:00 2001 From: "k_95.21" Date: Sun, 19 Nov 2023 16:52:57 +0900 Subject: [PATCH 1/4] add pure layout because contact page into contact layout is not goog --- src/app/contact/page.tsx | 5 +-- .../templates/SubPagePureLayout.tsx | 34 +++++++++++++++++++ .../styles/SubPagePureLayout.module.scss | 0 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/components/templates/SubPagePureLayout.tsx create mode 100644 src/components/templates/styles/SubPagePureLayout.module.scss diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index be395df..9166c4a 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -5,6 +5,7 @@ import React from 'react' import styles from './Contact.module.scss' import SubPageHero from '@/components/templates/SubPageHero' import MainLayout from '@/components/templates/MainLayout' +import SubPagePureLayout from '@/components/templates/SubPagePureLayout' // components import @@ -15,7 +16,7 @@ const Contact = () => { return(
{/* TODO: pureLayoutとかのコンポーネントを作る contactの中にcontactは変 */} - { >

this space is contact children space

-
+
) } diff --git a/src/components/templates/SubPagePureLayout.tsx b/src/components/templates/SubPagePureLayout.tsx new file mode 100644 index 0000000..916b9ff --- /dev/null +++ b/src/components/templates/SubPagePureLayout.tsx @@ -0,0 +1,34 @@ +import React from 'react' + + +// scss import +import styles from './styles/SubPagePureLayout.module.scss' + + +// components import +import Header from '../organisms/Header' +import Footer from '../organisms/Footer' + +// type +export type MainLayoutProps = { + id: number + children: React.ReactNode +} + + +const SubPagePureLayout = ({ + id, + children +}: MainLayoutProps) => { + return ( +
+
+
+ {children} +
+
+
+ ) +} + +export default SubPagePureLayout \ No newline at end of file diff --git a/src/components/templates/styles/SubPagePureLayout.module.scss b/src/components/templates/styles/SubPagePureLayout.module.scss new file mode 100644 index 0000000..e69de29 From 25e397dd682ca5bc6b37f7dddc21195a9263431b Mon Sep 17 00:00:00 2001 From: "k_95.21" Date: Sun, 19 Nov 2023 17:23:44 +0900 Subject: [PATCH 2/4] add contact form company or personal change logic --- src/app/contact/Contact.module.scss | 34 +++++++++++ src/app/contact/page.tsx | 61 ++++++++++++++++--- .../styles/SubPageContent.module.scss | 2 + 3 files changed, 89 insertions(+), 8 deletions(-) diff --git a/src/app/contact/Contact.module.scss b/src/app/contact/Contact.module.scss index e69de29..a974888 100644 --- a/src/app/contact/Contact.module.scss +++ b/src/app/contact/Contact.module.scss @@ -0,0 +1,34 @@ +.formBox { + width: 100%; + margin-top: 100px; + height: 500px; + border: 1px solid gray; + .flexButton { + display: flex; + align-items: center; + .personalButton { + background-color: rgb(255, 255, 255); + color: red; + padding: 10px 20px; + cursor: pointer; + transition: background-color 0.3s, color 0.3s; + &.active { + // active時のスタイル + background-color: red; + color: white; + } + } + .companyButton { + background-color: rgb(255, 255, 255); + color: red; + padding: 10px 20px; + cursor: pointer; + transition: background-color 0.3s, color 0.3s; + &.active { + // active時のスタイル + background-color: red; + color: white; + } + } + } +} \ No newline at end of file diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index 9166c4a..ec6ae9d 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -1,18 +1,24 @@ -import React from 'react' - +'use client' +import React, { useState } from 'react' // scss import import styles from './Contact.module.scss' + +// components import import SubPageHero from '@/components/templates/SubPageHero' -import MainLayout from '@/components/templates/MainLayout' import SubPagePureLayout from '@/components/templates/SubPagePureLayout' +import SubPageContent from '@/components/templates/SubPageContent' +import SubPageSecTitle from '@/components/atoms/SubPageSecTitle' +import SubPageTitleBox from '@/components/molecules/SubPageTitleBox' +import SubPageMainText from '@/components/atoms/SubPageMainText' -// components import +const Contact = () => { + // formの切り替え + const [form, setForm] = useState<'personal' | 'company'>('personal'); -const Contact = () => { return(
{/* TODO: pureLayoutとかのコンポーネントを作る contactの中にcontactは変 */} @@ -25,9 +31,48 @@ const Contact = () => { title='お問い合わせ' subTitle='このサービスについてお問い合わせいただけます。' pageName='CONTACT' - > -

this space is contact children space

- + /> + + + + +
+
+ + +
+
+ {form === 'personal' ? ( +
+

Person Form

+ {/* ここに実際の個人の方向けのフォームを配置 */} +
+ ) : ( +
+

Company Form

+ {/* ここに実際の法人の方向けのフォームを配置 */} +
+ )} +
+
+
) diff --git a/src/components/templates/styles/SubPageContent.module.scss b/src/components/templates/styles/SubPageContent.module.scss index 043e639..49818cc 100644 --- a/src/components/templates/styles/SubPageContent.module.scss +++ b/src/components/templates/styles/SubPageContent.module.scss @@ -1,6 +1,8 @@ .content { width: 60%; max-width: 1900px; + padding: 20px 0 100px 0; + box-sizing: border-box; margin: 0 auto; } From cee418abf69d3f3822943f1c05687d7a04194f12 Mon Sep 17 00:00:00 2001 From: "k_95.21" Date: Sun, 19 Nov 2023 17:45:16 +0900 Subject: [PATCH 3/4] add zod and react-hook-form contact pc layout complte --- src/app/contact/Contact.module.scss | 213 ++++++++++++++++++++++++++-- src/app/contact/page.tsx | 207 ++++++++++++++++++++++++--- 2 files changed, 392 insertions(+), 28 deletions(-) diff --git a/src/app/contact/Contact.module.scss b/src/app/contact/Contact.module.scss index a974888..f3e4d91 100644 --- a/src/app/contact/Contact.module.scss +++ b/src/app/contact/Contact.module.scss @@ -1,34 +1,227 @@ .formBox { width: 100%; - margin-top: 100px; - height: 500px; - border: 1px solid gray; + margin-top: 70px; .flexButton { display: flex; align-items: center; .personalButton { background-color: rgb(255, 255, 255); color: red; - padding: 10px 20px; + padding: 20px 30px; + border-radius: 5px; cursor: pointer; transition: background-color 0.3s, color 0.3s; &.active { // active時のスタイル - background-color: red; - color: white; + background-color: var(--main-red-color); + color: var(--main-white-color); } } .companyButton { background-color: rgb(255, 255, 255); color: red; - padding: 10px 20px; + padding: 20px 30px; + border-radius: 5px; cursor: pointer; transition: background-color 0.3s, color 0.3s; &.active { // active時のスタイル - background-color: red; - color: white; + background-color: var(--main-red-color); + color: var(--main-white-color); } } } -} \ No newline at end of file + .formBox { + padding: 30px 0 40px 0; + box-sizing: border-box; + // form styling + .form { + width: 100%; + .label { + display: block; + margin-top: 20px; + .labelTitle { + font-size: 20px; + font-weight: bold; + color: rgb(27, 27, 27); + } + .textInput { + width: 100%; + min-width: 800px; + margin-top: 10px; + margin-bottom: 10px; + padding: 20px 30px; + border-radius: 10px; + border: 1px solid gray; + } + .errorMessage { + color: red; + margin-bottom: 20px; + } + // textarea + .textarea { + width: 100%; + min-width: 800px; + min-height: 200px; + margin-top: 10px; + margin-bottom: 20px; + padding: 20px 30px; + box-sizing: border-box; + border-radius: 10px; + border: 1px solid gray; + } + .checkbox { + width: 20px; + height: 20px; + cursor: pointer; + border-radius: 4px; + border: 1px solid gray; + pointer-events: auto; + } + .checkbox:checked { + background-color: black; + } + } + .checkLabel { + .textBox { + width: 100%; + height: 200px; + border-radius: 5px; + border: 0.2px solid gray; + margin: 20px 0 30px 0; + overflow: scroll; + } + .checkboxContainer { + display: flex; + align-items: center; + margin-bottom: 10px; + gap: 20px; + } + + .checkbox { + width: 20px; + height: 20px; + cursor: pointer; + border-radius: 4px; + border: 1px solid gray; + margin-right: 10px; + } + + .errorMessage { + color: red; + margin-bottom: 20px; + } + + .checkbox:checked { + background-color: black; + } + } + } + .button { + padding: 15px 50px; + border-radius: 20px; + border: 1px solid gray; + } + .button:hover { + background-color: black; + color: white; + } + + } +} + + +// responsive + +@media screen and (max-width: 768px) { + // form styling + .form { + width: 100%; + .label { + display: block; + margin-top: 20px; + .labelTitle { + font-size: 20px; + font-weight: bold; + color: rgb(27, 27, 27); + } + .textInput { + width: 100%; + margin-top: 10px; + margin-bottom: 10px; + padding: 20px 30px; + border-radius: 10px; + border: 1px solid gray; + } + .errorMessage { + color: red; + margin-bottom: 20px; + } + // textarea + .textarea { + width: 100%; + min-height: 200px; + margin-top: 10px; + margin-bottom: 20px; + padding: 20px 30px; + box-sizing: border-box; + border-radius: 10px; + border: 1px solid gray; + } + .checkbox { + width: 20px; + height: 20px; + cursor: pointer; + border-radius: 4px; + border: 1px solid gray; + pointer-events: auto; + } + .checkbox:checked { + background-color: black; + } + } + .checkLabel { + .textBox { + width: 100%; + height: 200px; + border-radius: 5px; + border: 0.2px solid gray; + margin: 20px 0 30px 0; + overflow: scroll; + } + .checkboxContainer { + display: flex; + align-items: center; + margin-bottom: 10px; + gap: 20px; + } + + .checkbox { + width: 20px; + height: 20px; + cursor: pointer; + border-radius: 4px; + border: 1px solid gray; + margin-right: 10px; + } + + .errorMessage { + color: red; + margin-bottom: 20px; + } + + .checkbox:checked { + background-color: black; + } + } + } + .button { + padding: 15px 50px; + border-radius: 20px; + border: 1px solid gray; + } + .button:hover { + background-color: black; + color: white; + } + } \ No newline at end of file diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx index ec6ae9d..e8aba21 100644 --- a/src/app/contact/page.tsx +++ b/src/app/contact/page.tsx @@ -12,12 +12,33 @@ import SubPageSecTitle from '@/components/atoms/SubPageSecTitle' import SubPageTitleBox from '@/components/molecules/SubPageTitleBox' import SubPageMainText from '@/components/atoms/SubPageMainText' +// zod +import { ContactIndividualSchema, ContactIndividualType } from '@/schema/individual' +// import { ContactCorporationSchema, ContactCorporationType } from '@/schema/corporation' +import { zodResolver } from '@hookform/resolvers/zod' +import { SubmitHandler, useForm } from 'react-hook-form' + +interface ContactFormProps {} + const Contact = () => { // formの切り替え const [form, setForm] = useState<'personal' | 'company'>('personal'); + const handleOnSubmit: SubmitHandler = (data) => { + console.log(data) + } + + const { + register, + handleSubmit, + formState: { errors: formatError, isValid, isSubmitting }, + } = useForm({ + mode: 'onBlur', + resolver: zodResolver(ContactIndividualSchema), + }) + return(
@@ -45,29 +66,179 @@ const Contact = () => { />
- - + +
{form === 'personal' ? ( -
-

Person Form

- {/* ここに実際の個人の方向けのフォームを配置 */} +
+

個人のお客様用お問い合わせフォーム

+
{ + void handleSubmit(handleOnSubmit)(event) + }} + > + {/* email */} + + + {/* name */} + + + {/* kana */} + + + {/* tel */} + + + {/* title */} + + + {/* message */} +