From 4e88b3669ef02b6c3b78e1f157a4bea701f62631 Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Fri, 17 Feb 2023 14:57:05 +0900
Subject: [PATCH 1/7] =?UTF-8?q?Particpant=E3=82=B3=E3=83=B3=E3=83=9D?=
=?UTF-8?q?=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E4=BD=9C=E6=88=90(WIP)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
view/next.config.js | 4 +
.../ParticpantCard/ParticpantCard.module.css | 0
.../common/ParticpantCard/ParticpantCard.tsx | 75 +++++++++++++++++++
.../common/ParticpantCard/index.tsx | 1 +
.../layout/MainLayout/MainLayout.module.css | 0
.../layout/MainLayout/MainLayout.tsx | 12 +++
.../components/layout/MainLayout/index.tsx | 1 +
view/src/pages/_app.tsx | 2 +-
view/src/pages/home/index.tsx | 8 ++
view/tsconfig.json | 2 +-
10 files changed, 103 insertions(+), 2 deletions(-)
create mode 100644 view/src/components/common/ParticpantCard/ParticpantCard.module.css
create mode 100644 view/src/components/common/ParticpantCard/ParticpantCard.tsx
create mode 100644 view/src/components/common/ParticpantCard/index.tsx
create mode 100644 view/src/components/layout/MainLayout/MainLayout.module.css
create mode 100644 view/src/components/layout/MainLayout/MainLayout.tsx
create mode 100644 view/src/components/layout/MainLayout/index.tsx
create mode 100644 view/src/pages/home/index.tsx
diff --git a/view/next.config.js b/view/next.config.js
index a843cbe..2be6b2e 100644
--- a/view/next.config.js
+++ b/view/next.config.js
@@ -1,6 +1,10 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
+ env: {
+ SSR_API_URI: process.env.SSR_API_URI,
+ CSR_API_URI: process.env.CSR_API_URI,
+ }
}
module.exports = nextConfig
diff --git a/view/src/components/common/ParticpantCard/ParticpantCard.module.css b/view/src/components/common/ParticpantCard/ParticpantCard.module.css
new file mode 100644
index 0000000..e69de29
diff --git a/view/src/components/common/ParticpantCard/ParticpantCard.tsx b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
new file mode 100644
index 0000000..33e7c18
--- /dev/null
+++ b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
@@ -0,0 +1,75 @@
+import * as React from 'react';
+import { FC ,useEffect, useState } from 'react';
+import Card from '@mui/material/Card';
+import CardContent from '@mui/material/CardContent';
+import Typography from '@mui/material/Typography';
+import { get } from 'src/util/api_methods';
+
+export interface User {
+ id: number;
+ name: string;
+ number: number;
+}
+
+export interface Props {
+ users: User[];
+}
+
+// export const getServerSideProps = async () => {
+// const getUrl = process.env.SSR_API_URI + '/users';
+// const users = await get(getUrl);
+// console.log('url', getUrl)
+// console.log('json', users)
+// return {
+// props: {
+// users
+// },
+// };
+// }
+
+
+
+
+
+const ParticpantCard = () => {
+ const [users, setUsers] = useState([])
+
+ useEffect(() => {
+ fetch(process.env.CSR_API_URI + '/winners', {
+ headers: {
+ 'Content-Type': 'application/json'},
+ method: 'GET',
+ mode: 'no-cors'})
+ .then(res => res.json())
+ .then(data => {
+ setUsers(data)
+ console.log(data)
+ })
+ .catch(error => {
+ // ネットワークエラーでも !response.ok でもここで処理できる
+ console.error('エラーが発生しましたwao', error);
+ });
+ },[])
+
+ return (
+
+
+
+ 現在の技大祭参加者数:200人 外部参加者数:150人 学内参加者数:50人
+ {
+ users.map((user) =>
+ {user})
+ }
+
+
+
+ );
+}
+
+export default ParticpantCard;
diff --git a/view/src/components/common/ParticpantCard/index.tsx b/view/src/components/common/ParticpantCard/index.tsx
new file mode 100644
index 0000000..fc39468
--- /dev/null
+++ b/view/src/components/common/ParticpantCard/index.tsx
@@ -0,0 +1 @@
+export { default } from './ParticpantCard';
diff --git a/view/src/components/layout/MainLayout/MainLayout.module.css b/view/src/components/layout/MainLayout/MainLayout.module.css
new file mode 100644
index 0000000..e69de29
diff --git a/view/src/components/layout/MainLayout/MainLayout.tsx b/view/src/components/layout/MainLayout/MainLayout.tsx
new file mode 100644
index 0000000..8ac02a4
--- /dev/null
+++ b/view/src/components/layout/MainLayout/MainLayout.tsx
@@ -0,0 +1,12 @@
+import React, { FC } from 'react'
+import ParticpantCard from '@components/common/ParticpantCard/ParticpantCard'
+
+const MainLayout: FC = () => {
+ return (
+
+ )
+}
+
+export default MainLayout
diff --git a/view/src/components/layout/MainLayout/index.tsx b/view/src/components/layout/MainLayout/index.tsx
new file mode 100644
index 0000000..ed5671f
--- /dev/null
+++ b/view/src/components/layout/MainLayout/index.tsx
@@ -0,0 +1 @@
+export { default } from './MainLayout';
diff --git a/view/src/pages/_app.tsx b/view/src/pages/_app.tsx
index 021681f..a7f9cde 100644
--- a/view/src/pages/_app.tsx
+++ b/view/src/pages/_app.tsx
@@ -1,4 +1,4 @@
-import '@/styles/globals.css'
+import 'src/styles/globals.css'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
diff --git a/view/src/pages/home/index.tsx b/view/src/pages/home/index.tsx
new file mode 100644
index 0000000..b0a81b6
--- /dev/null
+++ b/view/src/pages/home/index.tsx
@@ -0,0 +1,8 @@
+import React from "react";
+import MainLayout from "@components/layout/MainLayout";
+
+const Home = () => {
+ return ;
+};
+
+export default Home;
diff --git a/view/tsconfig.json b/view/tsconfig.json
index 2159bf4..fd38a5d 100644
--- a/view/tsconfig.json
+++ b/view/tsconfig.json
@@ -16,7 +16,7 @@
"incremental": true,
"baseUrl": ".",
"paths": {
- "@/*": ["./src/*"]
+ "@components/*": ["./src/components/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
From 4ff63de50e2183344833a100698d699454e377dc Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Fri, 17 Feb 2023 14:58:45 +0900
Subject: [PATCH 2/7] =?UTF-8?q?basic=E8=AA=8D=E8=A8=BC=E3=81=AE=E4=B8=80?=
=?UTF-8?q?=E6=99=82=E9=96=89=E9=8E=96=E3=81=A8SSR,CSR=E3=81=AEurl?=
=?UTF-8?q?=E3=81=AE=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docker-compose.yml | 3 +++
go_api/main.go | 16 ++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index 323533d..d7fd6d8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -100,6 +100,9 @@ services:
volumes:
- ./view:/app/next-project
command: 'npm run dev'
+ environment:
+ SSR_API_URI: 'http://go:1323/api'
+ CSR_API_URI: 'http://localhost:1323/api'
depends_on:
- go
tty: true
diff --git a/go_api/main.go b/go_api/main.go
index 6f5d107..9e83593 100644
--- a/go_api/main.go
+++ b/go_api/main.go
@@ -2,7 +2,7 @@ package main
import (
"net/http"
- "os"
+ // "os"
_ "github.com/NUTFes/lottery/go_api/docs"
"github.com/NUTFes/lottery/go_api/infrastructure"
@@ -11,7 +11,7 @@ import (
echoSwagger "github.com/swaggo/echo-swagger"
"github.com/labstack/echo/v4"
- "github.com/labstack/echo/v4/middleware"
+ // "github.com/labstack/echo/v4/middleware"
)
type (
@@ -60,12 +60,12 @@ func main() {
// ルーティング(APIが増えると、server.goが肥大化するので、今後別にファイルに分ける)
// BasicAuth
- e.Use(middleware.BasicAuth(func(username string, password string, c echo.Context) (bool, error) {
- if username == os.Getenv("ADMIN_NAME") && password == os.Getenv("ADMIN_PASS") {
- return true, nil
- }
- return false, nil
- }))
+ // e.Use(middleware.BasicAuth(func(username string, password string, c echo.Context) (bool, error) {
+ // if username == os.Getenv("ADMIN_NAME") && password == os.Getenv("ADMIN_PASS") {
+ // return true, nil
+ // }
+ // return false, nil
+ // }))
// admins
e.GET("/admins", adminController.IndexAdmin)
From b6a46b6b28aac9b4eec2a7f3a2dc53f62a74f10b Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Sat, 18 Feb 2023 19:03:42 +0900
Subject: [PATCH 3/7] =?UTF-8?q?[mod]CSR=5FAPI=5FURI=E3=81=AE=E3=83=91?=
=?UTF-8?q?=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3(#291)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docker-compose.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index d7fd6d8..b932cf7 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -102,7 +102,7 @@ services:
command: 'npm run dev'
environment:
SSR_API_URI: 'http://go:1323/api'
- CSR_API_URI: 'http://localhost:1323/api'
+ CSR_API_URI: 'http://localhost:1323'
depends_on:
- go
tty: true
From 92d001346526741a1ee43d0878247629bebb5090 Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Sat, 18 Feb 2023 19:05:01 +0900
Subject: [PATCH 4/7] =?UTF-8?q?[add]cors=E8=A8=AD=E5=AE=9A=E3=82=92?=
=?UTF-8?q?=E8=BF=BD=E5=8A=A0(#291)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
go_api/main.go | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/go_api/main.go b/go_api/main.go
index 9e83593..e10e0e1 100644
--- a/go_api/main.go
+++ b/go_api/main.go
@@ -11,7 +11,7 @@ import (
echoSwagger "github.com/swaggo/echo-swagger"
"github.com/labstack/echo/v4"
- // "github.com/labstack/echo/v4/middleware"
+ "github.com/labstack/echo/v4/middleware"
)
type (
@@ -38,6 +38,13 @@ func main() {
// DB接続
client := infrastructure.ConnectDB()
+ // cors設定
+ arrowOrigins := []string{"http://localhost:3000"}
+ e.Use(middleware.Logger())
+ e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
+ AllowOrigins: arrowOrigins,
+ }))
+
// 依存の方向:controller -> usecase -> domain <- infrastructure
adminInfrastructure := infrastructure.NewAdminInfrastructure(client)
eventInfrastructure := infrastructure.NewEventInfrastructure(client)
From 9160d3d8a3d46fe667c55c4990ab05b23d713eb9 Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Sat, 18 Feb 2023 19:05:58 +0900
Subject: [PATCH 5/7] =?UTF-8?q?[mod]=E4=BA=BA=E6=95=B0=E3=82=AB=E3=82=A6?=
=?UTF-8?q?=E3=83=B3=E3=83=88=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D?=
=?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F(#291)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../common/ParticpantCard/ParticpantCard.tsx | 45 +++----------------
1 file changed, 5 insertions(+), 40 deletions(-)
diff --git a/view/src/components/common/ParticpantCard/ParticpantCard.tsx b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
index 33e7c18..a693fd4 100644
--- a/view/src/components/common/ParticpantCard/ParticpantCard.tsx
+++ b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
@@ -1,53 +1,22 @@
import * as React from 'react';
-import { FC ,useEffect, useState } from 'react';
+import { useEffect, useState } from 'react';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Typography from '@mui/material/Typography';
-import { get } from 'src/util/api_methods';
-
-export interface User {
- id: number;
- name: string;
- number: number;
-}
-
-export interface Props {
- users: User[];
-}
-
-// export const getServerSideProps = async () => {
-// const getUrl = process.env.SSR_API_URI + '/users';
-// const users = await get(getUrl);
-// console.log('url', getUrl)
-// console.log('json', users)
-// return {
-// props: {
-// users
-// },
-// };
-// }
-
-
-
-
const ParticpantCard = () => {
const [users, setUsers] = useState([])
useEffect(() => {
- fetch(process.env.CSR_API_URI + '/winners', {
- headers: {
- 'Content-Type': 'application/json'},
- method: 'GET',
- mode: 'no-cors'})
+ fetch(process.env.CSR_API_URI + '/users', {
+ method: 'GET',})
.then(res => res.json())
.then(data => {
setUsers(data)
console.log(data)
})
.catch(error => {
- // ネットワークエラーでも !response.ok でもここで処理できる
- console.error('エラーが発生しましたwao', error);
+ console.error('エラーが発生しました', error);
});
},[])
@@ -61,11 +30,7 @@ const ParticpantCard = () => {
fontFamily='NOTO SANS JP'
sx={{ alignSelf: 'flex-start'}}
>
- 現在の技大祭参加者数:200人 外部参加者数:150人 学内参加者数:50人
- {
- users.map((user) =>
- {user})
- }
+ 現在の技大祭参加者数:{users.length}人
From 311d1222b0d4032735ae40a2ff5b487e6a0dd540 Mon Sep 17 00:00:00 2001
From: hikahana <22.h.hanada.nutfes@gmail.com>
Date: Mon, 20 Feb 2023 18:46:43 +0900
Subject: [PATCH 6/7] =?UTF-8?q?[mod]=E3=82=B3=E3=83=B3=E3=83=9D=E3=83=BC?=
=?UTF-8?q?=E3=83=8D=E3=83=B3=E3=83=88=E3=81=AE=E3=82=B5=E3=82=A4=E3=82=BA?=
=?UTF-8?q?=E8=AA=BF=E6=95=B4(#291)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
view/src/components/common/ParticpantCard/ParticpantCard.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/view/src/components/common/ParticpantCard/ParticpantCard.tsx b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
index a693fd4..91d6ee2 100644
--- a/view/src/components/common/ParticpantCard/ParticpantCard.tsx
+++ b/view/src/components/common/ParticpantCard/ParticpantCard.tsx
@@ -21,7 +21,7 @@ const ParticpantCard = () => {
},[])
return (
-
+
Date: Sat, 4 Mar 2023 16:30:44 +0900
Subject: [PATCH 7/7] [fix] (#291)
---
docker-compose.yml | 4 ----
1 file changed, 4 deletions(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index dc5f0f9..e9e241d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -100,14 +100,10 @@ services:
- '6006:6006'
volumes:
- ./view:/app/next-project
-<<<<<<< HEAD
- command: 'npm run dev'
environment:
SSR_API_URI: 'http://go:1323/api'
CSR_API_URI: 'http://localhost:1323'
-=======
command: sh -c 'npm run dev & npm run storybook'
->>>>>>> develop
depends_on:
- go
tty: true