diff --git a/frontend/app/.gitignore b/frontend/app/.gitignore new file mode 100644 index 0000000..4d29575 --- /dev/null +++ b/frontend/app/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/frontend/app/package.json b/frontend/app/package.json new file mode 100644 index 0000000..9c11af8 --- /dev/null +++ b/frontend/app/package.json @@ -0,0 +1,40 @@ +{ + "name": "forum", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^5.17.0", + "@testing-library/react": "^13.4.0", + "@testing-library/user-event": "^13.5.0", + "axios": "^1.6.8", + "bulma": "^1.0.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-scripts": "5.0.1", + "web-vitals": "^2.1.4" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +} diff --git a/frontend/app/src/App.js b/frontend/app/src/App.js new file mode 100644 index 0000000..45f7602 --- /dev/null +++ b/frontend/app/src/App.js @@ -0,0 +1,41 @@ +import 'bulma/css/bulma.css' +import {useEffect, useState} from "react"; +import axios from "axios"; +import PostList from "./components/Post/PostList"; + +function App() { + const [postList, setPostsList] = useState([]); + + const fetchPosts = async () => { + await axios.get("http://localhost:8000/catalog") + .then((response) => { setPostsList(response.data)}) + } + + useEffect(() => { + fetchPosts(); + }, []); + + async function handleClickRefresh() { + await fetchPosts(); + } + + return ( + <> +
+
+
+

Singleboard Forum App

+
+
+
+
+ +
+ +
+
+ + ); +} + +export default App; \ No newline at end of file diff --git a/frontend/app/src/components/Post/PostList.js b/frontend/app/src/components/Post/PostList.js new file mode 100644 index 0000000..5105770 --- /dev/null +++ b/frontend/app/src/components/Post/PostList.js @@ -0,0 +1,19 @@ +import PostShow from "./PostShow"; + +function PostList({posts}) { + const renderedPosts = posts.map((post, key) => { + return + }) + + return ( + <> +
+
+ {renderedPosts} +
+
+ + ); +} + +export default PostList \ No newline at end of file diff --git a/frontend/app/src/components/Post/PostShow.js b/frontend/app/src/components/Post/PostShow.js new file mode 100644 index 0000000..2e983ea --- /dev/null +++ b/frontend/app/src/components/Post/PostShow.js @@ -0,0 +1,14 @@ +function PostShow({title, content, post_id}) { + return ( + <> +
+

{title}

+

{content}

+
+

0 replies

+
+ + ); +} + +export default PostShow; \ No newline at end of file diff --git a/frontend/app/src/index.js b/frontend/app/src/index.js new file mode 100644 index 0000000..23ffbde --- /dev/null +++ b/frontend/app/src/index.js @@ -0,0 +1,8 @@ +import React from "react"; +import ReactDOM from "react-dom/client" +import App from "./App"; + +const el = document.getElementById("root"); +const root = ReactDOM.createRoot(el) + +root.render() \ No newline at end of file