diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index adb343e102be9ae917ac6c37848501cab0e04144..28400d4d93df883a2a5a7bda44bef65bef9c9283 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -2,7 +2,7 @@ import React from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import "tailwindcss/tailwind.css";
import { IntoPost } from "./post/intopost";
-import { Login, Profile, RequireAuth, Signup } from "./auth";
+import { Login, Profile, RequireAuth, Signup, Admin } from "./auth";
import { Header, Body } from "./home";
import { Board } from "./board";
import Posting from "./post/posting";
@@ -38,6 +38,7 @@ export const App = () => {
}
/>
+ } />
diff --git a/frontend/src/Pages/myslide.tsx b/frontend/src/Pages/myslide.tsx
index 7c6a42f5d7b5915503615ba5e73764b232c63de5..cf9e085440229d23265508ca4b5e5eacc945a4cb 100644
--- a/frontend/src/Pages/myslide.tsx
+++ b/frontend/src/Pages/myslide.tsx
@@ -1,21 +1,17 @@
import React, { useRef, useState } from "react";
type num = {
- total: number,
- page: number,
- setPage: Function,
- style: string,
- setStyle: Function,
- // slides : any[],
+ slides: any[],
}
-export function MySlide({ total, page, setPage, style, setStyle}: num) {
-
- const numPages = Math.ceil(total / 15);
+export function MySlide({ slides}: num) {
const firstLeftClick = useRef(true);
const firstRightClick = useRef(true);
- const slide = useRef(1);
+ const [page, setPage] = useState(1);
+ const [slide,setSlide] = useState(1);
+ // const slide = useRef(1);
+ const [style, setStyle] = useState("");
const leftClick = () => {
if (firstLeftClick.current) {
@@ -24,7 +20,8 @@ export function MySlide({ total, page, setPage, style, setStyle}: num) {
} else {
setPage(page - 1)
}
- slide.current -= 1;
+ // slide.current -= 1;
+ setSlide(slide-1)
setStyle("-translate-x-full animate-slidetoright");
};
@@ -35,31 +32,34 @@ export function MySlide({ total, page, setPage, style, setStyle}: num) {
} else {
setPage(page + 1)
}
- slide.current += 1;
+ // slide.current += 1;
+ setSlide(slide+1)
setStyle("animate-slidetoleft");
};
return (
-
-
// Body Page
diff --git a/frontend/src/home/header.tsx b/frontend/src/home/header.tsx
index bc44b0ac06b34444bb79f05ff36e6b1f4ea926f3..0b44993d5e2d2e70eca88f2e970548cbc5515c30 100644
--- a/frontend/src/home/header.tsx
+++ b/frontend/src/home/header.tsx
@@ -10,13 +10,13 @@ export default function Header() {
-
+
Travel Report
@@ -45,7 +45,7 @@ export default function Header() {
) : (
로그인
@@ -56,7 +56,7 @@ export default function Header() {
게시판
diff --git a/frontend/src/home/theme.tsx b/frontend/src/home/theme.tsx
index c48bf171d0513a11f68dc53c6fd9f973a091d910..1a1c2c99fa0c0fbb4a4209ac86b6f67e1510a2b9 100644
--- a/frontend/src/home/theme.tsx
+++ b/frontend/src/home/theme.tsx
@@ -6,38 +6,38 @@ type ThemeProps = {
export default function Theme({ handleClick }: ThemeProps) {
return (
-
-
+
+
서핑
-
+
액티비티
-
+
캠핑
-
+
스키
-
+
보트
-
+
사막
-
+
골프
-
+
동굴
-
+
문화재
-
+
동물원
-
+
사이클링
diff --git a/frontend/src/pages/citylist.tsx b/frontend/src/pages/citylist.tsx
index 4e29e1b0a90ffc62fe7709beb4fbe64972633c8f..042b4ccc613d978bca908b245384126b51d4b1aa 100644
--- a/frontend/src/pages/citylist.tsx
+++ b/frontend/src/pages/citylist.tsx
@@ -6,8 +6,8 @@ type CityProps = {
export default function Citylist({ handleClick }: CityProps) {
return (
-
-
도시
+
+
도시
{
+ const req = reqExp as TypedRequestAuth<{ userId: string }>;
+
+ const { theme, city, url, title} = req.body as {
+ theme: string;
+ city: string;
+ url: string;
+ title: string;
+ };
+
+ console.log("body", req.body);
+
+ if (!isLength(url ?? "", { min: 1 })) {
+ return res.status(422).send("이미지 url을 입력해주세요");
+ }
+
+ if (!isLength(title ?? "", { min: 1 })) {
+ return res.status(422).send("이미지 제목을 입력해주세요");
+ }
+
+ const newMainimg = await mainimgDb.createMainimg({
+ theme,
+ city,
+ url,
+ title,
+ });
+
+ return res.json(newMainimg);
+});
+
+export const getMainimg = asyncWrap(async (req, res) => {
+ const mainimgs = await mainimgDb.getMainimg();
+ return res.json(mainimgs);
+ });
+
+
+
+
diff --git a/src/db/index.ts b/src/db/index.ts
index 78acdc553d8d38f4a2a8a3a2c89a3cd5ea8500eb..b714af5b043b5377b84b3ba8e213d349e63d09a8 100644
--- a/src/db/index.ts
+++ b/src/db/index.ts
@@ -1,3 +1,4 @@
export * as roleDb from "./role.db";
export * as postDb from "./post.db";
export * as userDb from "./user.db";
+export * as mainimgDb from "./mainimg.db"
\ No newline at end of file
diff --git a/src/db/mainimg.db.ts b/src/db/mainimg.db.ts
new file mode 100644
index 0000000000000000000000000000000000000000..83edb470dd8df4467ce1286d3fa6f5c97048670a
--- /dev/null
+++ b/src/db/mainimg.db.ts
@@ -0,0 +1,16 @@
+import { Mainimg, MainimgType } from "../models";
+
+export const createMainimg = async (mainimg: MainimgType) => {
+ const newMainimg = await Mainimg.create({
+ theme: mainimg.theme,
+ city: mainimg.city,
+ url: mainimg.url,
+ title: mainimg.title,
+ });
+ return newMainimg;
+};
+
+export const getMainimg = async () => {
+ const users = await Mainimg.find({});
+ return users;
+ };
diff --git a/src/models/index.ts b/src/models/index.ts
index a5735f977ae40777721d887284cda3b78c3e7400..821cab3d112ffedce2bee23e557ae809982d0be8 100644
--- a/src/models/index.ts
+++ b/src/models/index.ts
@@ -2,3 +2,4 @@ export { default as User, IUser } from "./user.model";
export { default as Post, PostType } from "./post.model";
export { default as Role } from "./role.model";
export { default as Avatar, IAvatar } from "./fileinfo.model";
+export { default as Mainimg, MainimgType } from "./mainimg.model";
diff --git a/src/models/mainimg.model.ts b/src/models/mainimg.model.ts
new file mode 100644
index 0000000000000000000000000000000000000000..70b1e4d3d05622ac76fa75d3c6c2f0f4a6dbd1eb
--- /dev/null
+++ b/src/models/mainimg.model.ts
@@ -0,0 +1,28 @@
+import {model, Schema } from "mongoose";
+
+export interface MainimgType {
+
+ theme: string;
+ city: string;
+ url: string;
+ title: string;
+}
+
+const MainimgSchema = new Schema({
+ theme: {
+ type: String,
+ },
+ city: {
+ type: String,
+ },
+ url : {
+ type: String,
+ },
+ title: {
+ type: String,
+ required: true,
+ },
+
+});
+
+export default model("Mainimg", MainimgSchema);
diff --git a/src/routes/index.ts b/src/routes/index.ts
index 986d8948073a0f7b8a282ee795424097760f129b..7102fb448f70c4a564d90718c6d9137e8ec1382f 100644
--- a/src/routes/index.ts
+++ b/src/routes/index.ts
@@ -3,6 +3,7 @@ import userRouter from "./user.route";
import authRouter from "./auth.route";
import postRouter from "./post.route";
import profileRouter from "./profile.route";
+import mainimgRouter from "./mainimg.route";
const router = express.Router();
@@ -10,6 +11,7 @@ router.use("/users", userRouter);
router.use("/auth", authRouter);
router.use("/posts", postRouter);
router.use("/profile", profileRouter);
+router.use("/mainimg", mainimgRouter);
//posting함수 -> mongodb에 posts json형식으로 저장
export default router;
diff --git a/src/routes/mainimg.route.ts b/src/routes/mainimg.route.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2016f28958a6b1c847d7ff9405ac3775493bbed2
--- /dev/null
+++ b/src/routes/mainimg.route.ts
@@ -0,0 +1,11 @@
+import express from "express";
+import { mainimgCtrl, authCtrl } from "../controllers";
+
+const router = express.Router();
+
+router
+ .route("/")
+ .get(authCtrl.requireLogin, mainimgCtrl.getMainimg)
+ .post(authCtrl.requireLogin, mainimgCtrl.createMainimg);
+
+export default router;