diff --git a/ddip/src/app/feature/profile/components/info-sidebar.js b/src/app/feature/profile/components/info-sidebar.js
similarity index 100%
rename from ddip/src/app/feature/profile/components/info-sidebar.js
rename to src/app/feature/profile/components/info-sidebar.js
diff --git a/ddip/src/app/feature/profile/components/my-info-form.js b/src/app/feature/profile/components/my-info-form.js
similarity index 100%
rename from ddip/src/app/feature/profile/components/my-info-form.js
rename to src/app/feature/profile/components/my-info-form.js
diff --git a/ddip/src/app/feature/profile/components/my-sidebar.js b/src/app/feature/profile/components/my-sidebar.js
similarity index 100%
rename from ddip/src/app/feature/profile/components/my-sidebar.js
rename to src/app/feature/profile/components/my-sidebar.js
diff --git a/ddip/src/app/feature/profile/components/myproduct-managing-form.js b/src/app/feature/profile/components/myproduct-managing-form.js
similarity index 100%
rename from ddip/src/app/feature/profile/components/myproduct-managing-form.js
rename to src/app/feature/profile/components/myproduct-managing-form.js
diff --git a/ddip/src/app/feature/auth/index.js b/src/app/feature/profile/index.js
similarity index 100%
rename from ddip/src/app/feature/auth/index.js
rename to src/app/feature/profile/index.js
diff --git a/ddip/src/app/feature/auth/components/login-form.js b/src/app/feature/user/api/user-api.js
similarity index 100%
rename from ddip/src/app/feature/auth/components/login-form.js
rename to src/app/feature/user/api/user-api.js
diff --git a/ddip/src/app/feature/auth/components/sign-in.js b/src/app/feature/user/model/user.js
similarity index 100%
rename from ddip/src/app/feature/auth/components/sign-in.js
rename to src/app/feature/user/model/user.js
diff --git a/ddip/src/app/globals.css b/src/app/globals.css
similarity index 82%
rename from ddip/src/app/globals.css
rename to src/app/globals.css
index d85a1b4..4dfcf50 100644
--- a/ddip/src/app/globals.css
+++ b/src/app/globals.css
@@ -3,14 +3,15 @@
@font-face {
font-family: 'Pretendardvariable';
src: url('../../public/fonts/PretendardVariable.woff2') format('woff2');
- font-style: normal;
- font-display: swap;
+ font-style: normal;
+ font-display: swap;
}
body {
- font-family: Arial, Helvetica, sans-serif;
+ font-family: 'Pretendardvariable', Arial, Helvetica, sans-serif;
}
+
.searchslot{
@apply text-center rounded-full bg-[#FFFCED]
shadow-green-500 hover:shadow-xl
diff --git a/src/app/layout.js b/src/app/layout.js
new file mode 100644
index 0000000..040b797
--- /dev/null
+++ b/src/app/layout.js
@@ -0,0 +1,30 @@
+import { Geist, Geist_Mono } from "next/font/google";
+import "./globals.css";
+
+const geistSans = Geist({
+ variable: "--font-geist-sans",
+ subsets: ["latin"],
+});
+
+const geistMono = Geist_Mono({
+ variable: "--font-geist-mono",
+ subsets: ["latin"],
+});
+
+export const metadata = {
+ title: "Create Next App",
+ description: "Generated by create next app",
+};
+
+export default function RootLayout({ children }) {
+ return (
+
+
+ {children}
+
+
+ );
+}
+
diff --git a/src/app/page.js b/src/app/page.js
new file mode 100644
index 0000000..e3a28a6
--- /dev/null
+++ b/src/app/page.js
@@ -0,0 +1,67 @@
+'use client';
+
+import { useState } from 'react';
+import Navs from '@components/common/nav.js';
+import Main from '@home/index';
+import Category from '@home/components/category-form';
+import ItemList from '@home/components/item-list';
+import ItemExplain from '@home/components/item-explain';
+import SignUp from '@auth/index';
+
+
+
+
+export default function Home() {
+ const [mode, setMode] = useState('home');
+ const [sign, setSign] = useState(false);
+ const [selectedCategory, setSelectedCategory] = useState(null);
+ const [selectedProduct, setSelectedProduct] = useState(null);
+
+ return (
+
+
{
+ setSign(index);
+ setMode('sign');
+ }}/>
+ {mode === 'sign' &&(
+ <>
+
+ >
+ )}
+
+ {mode === 'home' && (
+ <>
+
+ {
+ setSelectedCategory(index);
+ setMode('category');
+ }} />
+ >
+ )}
+
+ {mode === 'category' && (
+ <>
+
+
+
+
+
+ {selectedCategory}
+ {
+ setSelectedProduct(index);
+ setMode('product');
+ }} />
+ >
+ )}
+
+ {mode === 'product' && (
+ <>
+
+ >
+ )}
+
+
+ );
+
+}
+
diff --git a/src/app/util/chat.js b/src/app/util/chat.js
new file mode 100644
index 0000000..db57672
--- /dev/null
+++ b/src/app/util/chat.js
@@ -0,0 +1,65 @@
+// pages/chat.js
+import { useEffect, useState } from 'react';
+import io from 'socket.io-client';
+
+let socket;
+
+const Chat = () => {
+ const [username, setUsername] = useState('');
+ const [message, setMessage] = useState('');
+ const [messages, setMessages] = useState([]);
+
+ useEffect(() => {
+ // 서버와 소켓 연결
+ socket = io({
+ path: '/api/socket_io',
+ });
+
+ socket.on('message', (data) => {
+ setMessages((prev) => [...prev, data]);
+ });
+
+ return () => {
+ socket.disconnect();
+ };
+ }, []);
+
+ const sendMessage = () => {
+ if (username && message) {
+ socket.emit('message', {
+ user: username,
+ text: message,
+ timestamp: new Date().toISOString(),
+ });
+ setMessage('');
+ }
+ };
+
+ return (
+
+
실시간 채팅
+
+ {messages.map((msg, idx) => (
+
+ {msg.user} ({new Date(msg.timestamp).toLocaleTimeString()}): {msg.text}
+
+ ))}
+
+
setUsername(e.target.value)}
+ />
+
setMessage(e.target.value)}
+ />
+
+
+ );
+};
+
+export default Chat;
diff --git a/src/app/util/database.js b/src/app/util/database.js
new file mode 100644
index 0000000..44fb58c
--- /dev/null
+++ b/src/app/util/database.js
@@ -0,0 +1,17 @@
+import { MongoClient } from "mongodb";
+
+const url = process.env.MONGODB_URI; // .env 파일에 연결 문자열을 저장해둘 거야
+const options = { useNewUrlParser: true };
+
+let connectDB;
+
+if (process.env.NODE_ENV === "development") {
+ if (!global._mongo) {
+ global._mongo = new MongoClient(url, options).connect();
+ }
+ connectDB = global._mongo;
+} else {
+ connectDB = new MongoClient(url, options).connect();
+}
+
+export { connectDB };
diff --git a/src/app/util/socket.js b/src/app/util/socket.js
new file mode 100644
index 0000000..7a1818c
--- /dev/null
+++ b/src/app/util/socket.js
@@ -0,0 +1,25 @@
+// pages/api/socket.js
+import { Server as HTTPServer } from 'http';
+import { Server as SocketIOServer } from 'socket.io';
+
+export const config = {
+ api: {
+ bodyParser: false,
+ },
+};
+
+export default function handler(req, res) {
+ if (!res.socket.server.io) {
+ const io = new SocketIOServer(res.socket.server, {
+ path: '/api/socket_io',
+ });
+ res.socket.server.io = io;
+
+ io.on('connection', (socket) => {
+ socket.on('message', (msg) => {
+ io.emit('message', msg);
+ });
+ });
+ }
+ res.end();
+}
diff --git a/ddip/src/constants/categoryDB.js b/src/constants/categoryDB.js
similarity index 100%
rename from ddip/src/constants/categoryDB.js
rename to src/constants/categoryDB.js
diff --git a/ddip/src/constants/simpleDB.js b/src/constants/simpleDB.js
similarity index 100%
rename from ddip/src/constants/simpleDB.js
rename to src/constants/simpleDB.js
diff --git a/src/lib/mongodb.js b/src/lib/mongodb.js
new file mode 100644
index 0000000..29c9988
--- /dev/null
+++ b/src/lib/mongodb.js
@@ -0,0 +1,28 @@
+import { MongoClient } from 'mongodb'
+
+const uri = process.env.MONGODB_URI
+const options = {}
+
+let client
+let clientPromise
+
+if (!uri) {
+ throw new Error('Please add your Mongo URI to .env.local')
+}
+
+if (process.env.NODE_ENV === 'development') {
+ if (!global._mongoClientPromise) {
+ console.log('🌱 Creating new MongoClient and connecting (dev mode)')
+ client = new MongoClient(uri, options)
+ global._mongoClientPromise = client.connect()
+ } else {
+ console.log('♻️ Reusing existing MongoClient promise (dev mode)')
+ }
+ clientPromise = global._mongoClientPromise
+} else {
+ console.log('🚀 Creating new MongoClient and connecting (production mode)')
+ client = new MongoClient(uri, options)
+ clientPromise = client.connect()
+}
+
+export default clientPromise