diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index e0ff6776..cbf9af95 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,8 +1,8 @@ -import { getAllAnswers } from '@/api/form'; -import { getCachedToken } from '@/api/mcToken'; -import DataTable from '@/components/dashboard'; -import DashboardMenu from '@/components/dashboardMenu'; +import DataTable from '@/components/Dashboard'; +import DashboardMenu from '@/components/DashboardMenu'; import NavBar from '@/components/NavBar'; +import { getAllAnswers } from '@/features/form/api/form'; +import { getCachedToken } from '@/features/user/api/mcToken'; import styles from '../page.module.css'; const Home = async () => { diff --git a/src/app/forms/[formId]/page.tsx b/src/app/forms/[formId]/page.tsx index aaec6f3a..f23f9291 100644 --- a/src/app/forms/[formId]/page.tsx +++ b/src/app/forms/[formId]/page.tsx @@ -1,6 +1,6 @@ -import { getForm } from '@/api/form'; -import { getCachedToken } from '@/api/mcToken'; -import AnswerForm from '@/components/AnswerForm'; +import { getForm } from '@/features/form/api/form'; +import AnswerForm from '@/features/form/components/AnswerForm'; +import { getCachedToken } from '@/features/user/api/mcToken'; const Home = async ({ params }: { params: { formId: number } }) => { const token = getCachedToken() ?? ''; diff --git a/src/app/forms/page.tsx b/src/app/forms/page.tsx index 773cbb4a..ef074e6a 100644 --- a/src/app/forms/page.tsx +++ b/src/app/forms/page.tsx @@ -1,6 +1,6 @@ -import { getForms } from '@/api/form'; -import { getCachedToken } from '@/api/mcToken'; -import FormList from '@/components/FormList'; +import { getForms } from '@/features/form/api/form'; +import FormList from '@/features/form/components/FormList'; +import { getCachedToken } from '@/features/user/api/mcToken'; const Home = async () => { const token = getCachedToken() ?? ''; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8fc0bf21..da613b50 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,10 +1,10 @@ import './globals.css'; import { Inter } from 'next/font/google'; -import { AuthenticatedTemplate } from '@/components/AuthenticatedTemplate'; -import { MsalProvider } from '@/components/MsalProvider'; import NavBar from '@/components/NavBar'; -import { NeedToSignin } from '@/components/NeedToSignin'; -import { UnauthenticatedTemplate } from '@/components/UnauthenticatedTemplate'; +import { AuthenticatedTemplate } from '@/features/user/components/AuthenticatedTemplate'; +import { MsalProvider } from '@/features/user/components/MsalProvider'; +import { NeedToSignin } from '@/features/user/components/NeedToSignin'; +import { UnauthenticatedTemplate } from '@/features/user/components/UnauthenticatedTemplate'; import styles from './page.module.css'; import type { Metadata } from 'next'; import type { ReactNode } from 'react'; diff --git a/src/components/dashboard.tsx b/src/components/Dashboard.tsx similarity index 94% rename from src/components/dashboard.tsx rename to src/components/Dashboard.tsx index d8b46f2b..0bd1472d 100644 --- a/src/components/dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -1,7 +1,7 @@ 'use client'; import { DataGrid, type GridColDef } from '@mui/x-data-grid'; import * as React from 'react'; -import type { BatchAnswer } from '@/schemas/formSchema'; +import type { BatchAnswer } from '@/features/form/types/formSchema'; const columns: GridColDef[] = [ { field: 'category', headerName: '種別', width: 200 }, diff --git a/src/components/dashboardMenu.tsx b/src/components/DashboardMenu.tsx similarity index 100% rename from src/components/dashboardMenu.tsx rename to src/components/DashboardMenu.tsx diff --git a/src/components/link.ts b/src/components/Link.ts similarity index 100% rename from src/components/link.ts rename to src/components/Link.ts diff --git a/src/components/Menu.tsx b/src/components/Menu.tsx index 2c4e319a..991c745b 100644 --- a/src/components/Menu.tsx +++ b/src/components/Menu.tsx @@ -1,7 +1,7 @@ 'use client'; import { Box, Button, styled, Stack, Typography } from '@mui/material'; -import { Link } from './link'; +import { Link } from './Link'; const Item = styled(Button)(({ theme }) => ({ backgroundColor: diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 45d00aad..6d1532d3 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,10 +1,10 @@ import MenuIcon from '@mui/icons-material/Menu'; import { Box, AppBar, Toolbar, IconButton, Typography } from '@mui/material'; -import { AuthenticatedTemplate } from './AuthenticatedTemplate'; -import { Link } from './link'; -import { SigninButton } from './SigninButton'; -import { SignoutButton } from './SignoutButton'; -import { UnauthenticatedTemplate } from './UnauthenticatedTemplate'; +import { Link } from './Link'; +import { AuthenticatedTemplate } from '../features/user/components/AuthenticatedTemplate'; +import { SigninButton } from '../features/user/components/SigninButton'; +import { SignoutButton } from '../features/user/components/SignoutButton'; +import { UnauthenticatedTemplate } from '../features/user/components/UnauthenticatedTemplate'; const NavBar = () => { return ( diff --git a/src/api/form.ts b/src/features/form/api/form.ts similarity index 94% rename from src/api/form.ts rename to src/features/form/api/form.ts index ae06c788..c8de5ee6 100644 --- a/src/api/form.ts +++ b/src/features/form/api/form.ts @@ -4,8 +4,8 @@ import { batchAnswersSchema, formSchema, formsSchema, -} from '@/schemas/formSchema'; -import type { BatchAnswer, Form } from '@/schemas/formSchema'; +} from '../types/formSchema'; +import type { BatchAnswer, Form } from '../types/formSchema'; export const getForms = async (token: string) => { const response = await fetch('http://localhost:9000/forms', { diff --git a/src/components/AnswerForm.tsx b/src/features/form/components/AnswerForm.tsx similarity index 97% rename from src/components/AnswerForm.tsx rename to src/features/form/components/AnswerForm.tsx index 54a9b516..74037e15 100644 --- a/src/components/AnswerForm.tsx +++ b/src/features/form/components/AnswerForm.tsx @@ -19,13 +19,13 @@ import { Divider, Button, Typography, + Link, } from '@mui/material'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; -import { postAnswers } from '@/api/form'; -import { getCachedToken } from '@/api/mcToken'; -import { Link } from './link'; -import type { Form, FormQuestion } from '@/schemas/formSchema'; +import { getCachedToken } from '@/features/user/api/mcToken'; +import { postAnswers } from '../api/form'; +import type { Form, FormQuestion } from '../types/formSchema'; interface Props { form: Form; diff --git a/src/components/FormList.tsx b/src/features/form/components/FormList.tsx similarity index 96% rename from src/components/FormList.tsx rename to src/features/form/components/FormList.tsx index 762a3bb2..c2012b0b 100644 --- a/src/components/FormList.tsx +++ b/src/features/form/components/FormList.tsx @@ -14,8 +14,8 @@ import { import dayjs, { extend } from 'dayjs'; import timezone from 'dayjs/plugin/timezone'; import utc from 'dayjs/plugin/utc'; -import { Link } from './link'; -import type { Form } from '@/schemas/formSchema'; +import { Link } from '@/components/Link'; +import type { Form } from '../types/formSchema'; extend(timezone); extend(utc); diff --git a/src/schemas/formSchema.ts b/src/features/form/types/formSchema.ts similarity index 100% rename from src/schemas/formSchema.ts rename to src/features/form/types/formSchema.ts diff --git a/src/api/login.ts b/src/features/user/api/login.ts similarity index 98% rename from src/api/login.ts rename to src/features/user/api/login.ts index 501dbff8..38660841 100644 --- a/src/api/login.ts +++ b/src/features/user/api/login.ts @@ -1,10 +1,10 @@ 'use server'; import { + xboxLiveServiceTokenResponseSchema, minecraftAccessTokenResponseSchema, minecraftProfileResponseSchema, - xboxLiveServiceTokenResponseSchema, -} from '@/schemas/loginSchema'; +} from '../types/loginSchema'; export const acquireXboxLiveToken = async (token: string) => { const URL = 'https://user.auth.xboxlive.com/user/authenticate'; diff --git a/src/api/mcToken.ts b/src/features/user/api/mcToken.ts similarity index 100% rename from src/api/mcToken.ts rename to src/features/user/api/mcToken.ts diff --git a/src/components/AuthenticatedTemplate.tsx b/src/features/user/components/AuthenticatedTemplate.tsx similarity index 83% rename from src/components/AuthenticatedTemplate.tsx rename to src/features/user/components/AuthenticatedTemplate.tsx index 8cf2a09d..10cec9de 100644 --- a/src/components/AuthenticatedTemplate.tsx +++ b/src/features/user/components/AuthenticatedTemplate.tsx @@ -1,4 +1,4 @@ -import { getCachedToken } from '@/api/mcToken'; +import { getCachedToken } from '../api/mcToken'; import type { ReactNode } from 'react'; type Props = { children: ReactNode }; diff --git a/src/components/MsalProvider.tsx b/src/features/user/components/MsalProvider.tsx similarity index 89% rename from src/components/MsalProvider.tsx rename to src/features/user/components/MsalProvider.tsx index a7ef9689..df45d911 100644 --- a/src/components/MsalProvider.tsx +++ b/src/features/user/components/MsalProvider.tsx @@ -2,7 +2,7 @@ import { PublicClientApplication } from '@azure/msal-browser'; import { MsalProvider as MsalLibProvider } from '@azure/msal-react'; -import { msalConfig } from '@/authConfig'; +import { msalConfig } from '../const/authConfig'; import type { ReactNode } from 'react'; const msalInstance = new PublicClientApplication(msalConfig); diff --git a/src/components/NeedToSignin.tsx b/src/features/user/components/NeedToSignin.tsx similarity index 100% rename from src/components/NeedToSignin.tsx rename to src/features/user/components/NeedToSignin.tsx diff --git a/src/components/SigninButton.tsx b/src/features/user/components/SigninButton.tsx similarity index 88% rename from src/components/SigninButton.tsx rename to src/features/user/components/SigninButton.tsx index 9ce65229..d099c76d 100644 --- a/src/components/SigninButton.tsx +++ b/src/features/user/components/SigninButton.tsx @@ -7,9 +7,9 @@ import { acquireMinecraftAccessToken, acquireXboxLiveToken, acquireXboxServiceSecurityToken, -} from '@/api/login'; -import { saveTokenToCache } from '@/api/mcToken'; -import { loginRequest } from '@/authConfig'; +} from '../api/login'; +import { saveTokenToCache } from '../api/mcToken'; +import { loginRequest } from '../const/authConfig'; export const SigninButton = () => { const { instance } = useMsal(); diff --git a/src/components/SignoutButton.tsx b/src/features/user/components/SignoutButton.tsx similarity index 90% rename from src/components/SignoutButton.tsx rename to src/features/user/components/SignoutButton.tsx index f5a2cf30..c08143ae 100644 --- a/src/components/SignoutButton.tsx +++ b/src/features/user/components/SignoutButton.tsx @@ -3,7 +3,7 @@ import { useMsal } from '@azure/msal-react'; import { Button } from '@mui/material'; import { useRouter } from 'next/navigation'; -import { clearCachedToken } from '@/api/mcToken'; +import { clearCachedToken } from '../api/mcToken'; export const SignoutButton = () => { const { instance } = useMsal(); diff --git a/src/components/UnauthenticatedTemplate.tsx b/src/features/user/components/UnauthenticatedTemplate.tsx similarity index 83% rename from src/components/UnauthenticatedTemplate.tsx rename to src/features/user/components/UnauthenticatedTemplate.tsx index 8d7fe510..3316545a 100644 --- a/src/components/UnauthenticatedTemplate.tsx +++ b/src/features/user/components/UnauthenticatedTemplate.tsx @@ -1,4 +1,4 @@ -import { getCachedToken } from '@/api/mcToken'; +import { getCachedToken } from '../api/mcToken'; import type { ReactNode } from 'react'; type Props = { children: ReactNode }; diff --git a/src/authConfig.ts b/src/features/user/const/authConfig.ts similarity index 100% rename from src/authConfig.ts rename to src/features/user/const/authConfig.ts diff --git a/src/schemas/loginSchema.ts b/src/features/user/types/loginSchema.ts similarity index 100% rename from src/schemas/loginSchema.ts rename to src/features/user/types/loginSchema.ts diff --git a/src/middleware.ts b/src/middleware.ts index f69f2ca5..3eb88316 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server'; -import { getCachedToken } from './api/mcToken'; +import { getCachedToken } from '@/features/user/api/mcToken'; import type { NextRequest } from 'next/server'; export const middleware = (request: NextRequest) => {