Skip to content

Commit

Permalink
Merge pull request #4 from VortexExpansion/auth
Browse files Browse the repository at this point in the history
Auth
HisashiHasebe authored Feb 7, 2024
2 parents 639e443 + 043e26d commit e06987b
Showing 29 changed files with 1,813 additions and 372 deletions.
15 changes: 10 additions & 5 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
@@ -12,18 +16,19 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"forceConsistentCasingInFileNames": true,
"baseUrl": "./", // Added baseUrl for path mapping
"paths": {
"@/*": ["./src/*"]
}
"@/*": [
"./src/*"
]
},
"forceConsistentCasingInFileNames": true
},
"include": [
"next-env.d.ts",
"**/*.js", // Change to include JavaScript files
"**/*.jsx", // Include JSX files
".next/types/**/*.ts",
"src/**/*.jsx"
],
"exclude": ["node_modules"]
}
584 changes: 383 additions & 201 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
},
"dependencies": {
"next": "14.0.4",
"next-auth": "^4.24.5",
"react": "latest",
"react-dom": "latest",
"textlint": "^13.4.1"
4 changes: 2 additions & 2 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -931,8 +931,8 @@ table {
display: flex;
position: relative;
-webkit-box-align: start;
-ms-flex-align: start;
align-items: start;
-ms-flex-align: flex-start;
align-items: flex-start;
z-index: 1; }
.c-memberArticle__coupon__title {
margin-right: 10px;
2 changes: 1 addition & 1 deletion public/mock/member/delete/index.html
Original file line number Diff line number Diff line change
@@ -288,4 +288,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2>
</footer>

</body>
</html>
</html>
2 changes: 1 addition & 1 deletion public/mock/member/edit/index.html
Original file line number Diff line number Diff line change
@@ -294,4 +294,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2>
</footer>

</body>
</html>
</html>
2 changes: 1 addition & 1 deletion public/mock/member/mypage/index.html
Original file line number Diff line number Diff line change
@@ -405,4 +405,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2>
</footer>

</body>
</html>
</html>
18 changes: 0 additions & 18 deletions src/app/(pages)/(SigleColumn)/layout.jsx

This file was deleted.

97 changes: 92 additions & 5 deletions src/app/(pages)/(SigleColumn)/login/page.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,94 @@
export default function Login () {
"use client";

import { useUser } from "@/components/common/userContext";
import { login } from "@/components/common/fetchData";
import { useRef } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import Breadcrumb from "@/components/common/Breadcrumb";
import PageTitle from "@/components/common/PageTitle";
import { getLabels } from "@/components/common/fetchData";
import AlertError from "@/components/ui/AlertError";
import { useState } from "react";


export default function Login() {
const email = useRef("");
const password = useRef("");
const { user, loading, storeUser } = useUser();
const router = useRouter();
const contentDirectory = getLabels();
const content = contentDirectory.login;
const [alert, setAlert] = useState(false);

const handleChange = () => {
setAlert(false);
};

const handleLogin = async (event) => {
event.preventDefault();
const user = await login(email.current.value, password.current.value);

if (user) {
setAlert(false);
storeUser(user);
router.push("member/mypage");
}
else{
setAlert(true);
}
};

return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
login page
</main>
)
<div className="l-container">
<Breadcrumb paths={[{ label: content.text }]} />
<PageTitle content={content} />
<div className="l-container--small l-container--contents">
<div className="flex min-h-screen flex-col items-center justify-between p-24">
{loading ? (
<div>Loading...</div>
) : user ? (
<div>You have already logged in.</div>
) : (
<form className="c-form" onSubmit={handleLogin} onChange={handleChange}>
<div className="c-form-group">
<label htmlFor="email" className="c-form-label">
メールアドレス
</label>
<input name="email" type="email" id="email" ref={email} />
</div>
<div className="c-form-group">
<label htmlFor="password" className="c-form-label">
パスワード
</label>
<input
name="password"
type="password"
id="password"
ref={password}
/>
</div>
<div className="c-form-group">
<button type="submit" className="c-button--primary u-width-100">
ログイン
</button>
</div>
<div className="u-text-align-center u-mt-25">
<Link href="/register" className="">
会員登録
</Link>
または
<Link href="/reminder" className="">
パスワードをお忘れの方
</Link>
</div>
</form>
)}

</div>
{alert && <AlertError message="メールアドレスまたはパスワードが間違っています。" />}
</div>

</div>
);
}
116 changes: 116 additions & 0 deletions src/app/(pages)/(SigleColumn)/register/page.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
"use client";

import Breadcrumb from "@/components/common/Breadcrumb";
import PageTitle from "@/components/common/PageTitle";
import { getLabels } from "@/components/common/fetchData";
import Link from "next/link";
import { useRef, useState } from "react";
import { register } from "@/components/common/fetchData";
import { useUser } from "@/components/common/userContext";
import { useRouter } from "next/navigation";
import AlertError from "@/components/ui/AlertError";

export default function Register() {
const contentDirectory = getLabels();
const content = contentDirectory.register;
const { user, loading, storeUser } = useUser();
const router = useRouter();
const [alert, setAlert] = useState(false);

const name1 = useRef("");
const name2 = useRef("");
const email = useRef("");
const login_pwd = useRef("");

const handleChange = () => {
setAlert(false);
};

const handleRegister = async (event) => {
event.preventDefault();

const user = await register(
name1.current.value,
name2.current.value,
email.current.value,
login_pwd.current.value
);

if (user) {
setAlert(false);
storeUser(user);
router.push("member/mypage");
} else {
setAlert(true);
}
};

return (
<div className="l-container">
<Breadcrumb paths={[{ label: content.text }]} />
<PageTitle content={content} />
<div className="l-container--small l-container--contents">
<div className="c-form-group u-text-align-center">
<p className="c-text--small">
<span className="c-form-label__required">*</span>は必須項目です。
</p>
</div>
<form className="c-form" onSubmit={handleRegister} onChange={handleChange}>
<div className="c-form-group">
<label htmlFor="name1" className="c-form-label">
名前(姓)
</label>
<span className="c-form-label__required">*</span>
<input name="name1" type="text" id="name1" ref={name1} />
</div>
<div className="c-form-group">
<label htmlFor="name2" className="c-form-label">
名前(名)
</label>
<input name="name2" type="text" id="name2" ref={name2} />
</div>
<div className="c-form-group">
<label htmlFor="email" className="c-form-label">
メールアドレス
</label>
<input name="email" type="email" ref={email} />
</div>
<div className="c-form-group">
<div className="u-display-flex">
<div className="u-display-flex-grow-1">
<label htmlFor="login_pwd" className="c-form-label">
パスワード
</label>
<span className="c-form-label__required u-ml-5">*</span>
</div>
<p className="u-ma-0 c-text--small">半角英数8文字以上</p>
</div>
<input
name="login_pwd"
type="password"
id="login_pwd"
ref={login_pwd}
/>
</div>
<div className="c-form-group">
<button type="submit" className="c-button--primary u-width-100">
登録
</button>
</div>
<div className="c-form-group u-text-align-center">
すでに会員の方は
<Link href="/login" className="nuxt-link-active">
ログイン
</Link>
</div>
<p className="c-text--small u-mt-25">
続行することで<Link href="#">利用規約</Link>及び
<Link href="/privacy">プライバシーポリシー</Link>
に同意したこととなります。
</p>
</form>
{alert && <AlertError message="エントリー内容を再度ご確認ください。" />}
</div>
</div>
);
}
Loading

0 comments on commit e06987b

Please sign in to comment.