From 2b8f837d7e852033c6a7ad474a8b96222f8a3e2d Mon Sep 17 00:00:00 2001 From: ryoaxton2000 <ryoaxton@gmail.com> Date: Fri, 8 Jan 2021 21:55:59 +0700 Subject: [PATCH] matching comment and post inside thread to JSON return from API, and implement delete thread and comment only for creator --- diskuy/.eslintcache | 2 +- diskuy/src/Threads/CommentList.js | 2 +- diskuy/src/Threads/Post.js | 15 +++++++++++---- diskuy/src/Threads/Thread.js | 19 ++++++++++--------- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/diskuy/.eslintcache b/diskuy/.eslintcache index 3b6b2e3..24d55b1 100644 --- a/diskuy/.eslintcache +++ b/diskuy/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\index.js":"1","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\reportWebVitals.js":"2","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\App.js":"3","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Topic.js":"4","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Navbar.js":"5","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Button.js":"6","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\TopicList.js":"7","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Form.js":"8","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\hooks\\input-hook.js":"9","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Thread.js":"10","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\ListThreads.js":"11","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Profile\\Profile.js":"12","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Post.js":"13","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\CommentList.js":"14","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\ThreadList.js":"15","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\PreviewThread.js":"16","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\LoginForm.js":"17","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\RegisterForm.js":"18","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth-header.js":"19","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth.service.js":"20","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\loggedInService.js":"21"},{"size":517,"mtime":1608228708909,"results":"22","hashOfConfig":"23"},{"size":375,"mtime":1608228708909,"results":"24","hashOfConfig":"23"},{"size":1059,"mtime":1610110193424,"results":"25","hashOfConfig":"23"},{"size":1429,"mtime":1610113863378,"results":"26","hashOfConfig":"23"},{"size":1492,"mtime":1610114049476,"results":"27","hashOfConfig":"23"},{"size":310,"mtime":1609674995191,"results":"28","hashOfConfig":"23"},{"size":774,"mtime":1610110193428,"results":"29","hashOfConfig":"23"},{"size":1704,"mtime":1610110193426,"results":"30","hashOfConfig":"23"},{"size":374,"mtime":1609495708947,"results":"31","hashOfConfig":"23"},{"size":3869,"mtime":1610114476088,"results":"32","hashOfConfig":"23"},{"size":703,"mtime":1609612143908,"results":"33","hashOfConfig":"23"},{"size":1864,"mtime":1609674995194,"results":"34","hashOfConfig":"23"},{"size":1325,"mtime":1609673984957,"results":"35","hashOfConfig":"23"},{"size":718,"mtime":1609663316552,"results":"36","hashOfConfig":"23"},{"size":404,"mtime":1609674083165,"results":"37","hashOfConfig":"23"},{"size":751,"mtime":1609674995195,"results":"38","hashOfConfig":"23"},{"size":2509,"mtime":1610113902295,"results":"39","hashOfConfig":"23"},{"size":3045,"mtime":1610113902297,"results":"40","hashOfConfig":"23"},{"size":209,"mtime":1610110193430,"results":"41","hashOfConfig":"23"},{"size":861,"mtime":1610110193430,"results":"42","hashOfConfig":"23"},{"size":103,"mtime":1610114385716,"results":"43","hashOfConfig":"23"},{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"1e00zfu",{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"51","messages":"52","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"55","messages":"56","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"57","usedDeprecatedRules":"46"},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"70","messages":"71","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"72","usedDeprecatedRules":"46"},{"filePath":"73","messages":"74","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"75","messages":"76","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"77","messages":"78","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"79","usedDeprecatedRules":"46"},{"filePath":"80","messages":"81","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"82","usedDeprecatedRules":"46"},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"85","messages":"86","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"89","messages":"90","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\index.js",[],["91","92"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\reportWebVitals.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\App.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Topic.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Navbar.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Button.js",["93","94"],"import React from \"react\";\r\nimport './Button.css';\r\nimport {\r\n Link\r\n } from \"react-router-dom\"\r\n\r\nfunction Button(props) {\r\n return (\r\n <Link to={`/${props.url}`}>\r\n <button className={`button ${props.color}`}>{props.text}</button>\r\n </Link>\r\n )\r\n}\r\n\r\nexport default Button;","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\TopicList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Form.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\hooks\\input-hook.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Thread.js",["95"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\ListThreads.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Profile\\Profile.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Post.js",["96"],"import './Post.css';\r\nimport './Comment.css';\r\nimport axios from 'axios';\r\n\r\nconst LINK = 'http://localhost:4000/';\r\nexport default function Post(props){\r\n\r\n const deletePost = async (event) => {\r\n try {\r\n if(event.type == \"thread\") {\r\n console.log(\"aaaa\")\r\n await axios.delete(`${LINK}api/threads/${event.id}`);\r\n props.history.push(`/${event.topic_id}`);\r\n } else {\r\n await axios.delete(`${LINK}api/post/${event.id}`);\r\n window.location.reload();\r\n }\r\n } catch (error) {}\r\n }\r\n\r\n return (\r\n <div id=\"post\">\r\n <div id=\"postHeader\">\r\n <div id=\"headerData\">\r\n <div id=\"round\"></div>\r\n <p id=\"creator\">By {props.user} - {props.time} </p>\r\n </div>\r\n <div id=\"headerButton\">\r\n <button type=\"button\" className=\"btn btn-outline-danger deleteButton\" onClick={() => deletePost(props)}>Delete</button>\r\n </div>\r\n </div>\r\n <div id=\"postContent\">\r\n <h1 id=\"judul\">{props.header}</h1>\r\n <p id=\"isi\">{props.text}</p>\r\n <p className='inline'>{props.points}</p>\r\n </div>\r\n </div>\r\n )\r\n}","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\CommentList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\ThreadList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\PreviewThread.js",["97","98"],"import React from \"react\";\r\n\r\nimport axios from \"axios\";\r\n\r\nconst LINK = 'http://localhost:4000';\r\n\r\n\r\nfunction PreviewThread (props) {\r\n\r\n // const userName = await axios.get(`${LINK}/api/threads/${props.user_id}`);\r\n // const topic_id = `${props.topic_id}`\r\n // const topicName = await axios.get(`${LINK}/api/topics/${props.topic_id}`).data.data.find(topic => topic.name === topic_id).id\r\n return (\r\n <div className=\"thread_container\">\r\n <h1>{props.title}</h1>\r\n <div className=\"label\">\r\n <h2>{props.topic_id}</h2>\r\n </div>\r\n <div className=\"info\">\r\n <h3>{props.timestamp}</h3>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default PreviewThread;","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\LoginForm.js",["99"],"import React from 'react'\r\nimport { isEmail } from 'validator'\r\nimport { useInput } from './hooks/input-hook';\r\nimport { useState } from \"react\";\r\n\r\nimport AuthService from './services/auth.service'\r\n\r\nconst required = value => {\r\n if (!value) {\r\n return (\r\n <div className='alert alert-danger' role='alert'>\r\n This field is required!\r\n </div>\r\n )\r\n }\r\n}\r\n\r\nexport default function LoginForm(props){\r\n\r\n const { value: username, bind: bindUsername, reset: resetUsername } = useInput('')\r\n const { value: password, bind: bindPassword, reset: resetPassword } = useInput('')\r\n const [loading, setLoading] = useState(false)\r\n const [message, setMessage] = useState('')\r\n\r\n const handleLogin = async event => {\r\n event.preventDefault()\r\n setLoading(true)\r\n\r\n try {\r\n await AuthService.login(username, password)\r\n props.history.push('/topics')\r\n }\r\n catch(error) {\r\n const responseMessage =\r\n (error.response && error.response.data && error.response.data.message) || error.message || error.toString()\r\n setMessage(responseMessage)\r\n resetPassword()\r\n resetUsername()\r\n }\r\n setLoading(false)\r\n }\r\n\r\n return (\r\n <div>\r\n <form onSubmit={handleLogin}>\r\n <label htmlFor='username'>Email</label>\r\n <input\r\n type='text'\r\n name='username'\r\n {...bindUsername}\r\n validations={[required]}\r\n />\r\n\r\n <label htmlFor='password'>Password</label>\r\n <input\r\n type='password'\r\n name='password'\r\n {...bindPassword}\r\n validations={[required]} \r\n />\r\n\r\n <button className='btn btn-primary' disabled={loading}>\r\n {loading && (\r\n <span className='spinner-border spinner-border-sm'></span>\r\n )}\r\n <span>Login</span>\r\n </button>\r\n\r\n {message && (\r\n <div>\r\n <div className='alert alert-danger' role='alert'>\r\n {message}\r\n </div>\r\n </div>\r\n )}\r\n </form>\r\n </div>\r\n )\r\n}\r\n","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\RegisterForm.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth-header.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth.service.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\loggedInService.js",[],{"ruleId":"100","replacedBy":"101"},{"ruleId":"102","replacedBy":"103"},{"ruleId":"104","severity":1,"message":"105","line":8,"column":18,"nodeType":"106","messageId":"107","endLine":8,"endColumn":20},{"ruleId":"104","severity":1,"message":"105","line":14,"column":23,"nodeType":"106","messageId":"107","endLine":14,"endColumn":25},{"ruleId":"104","severity":1,"message":"105","line":39,"column":105,"nodeType":"106","messageId":"107","endLine":39,"endColumn":107},{"ruleId":"104","severity":1,"message":"105","line":10,"column":27,"nodeType":"106","messageId":"107","endLine":10,"endColumn":29},{"ruleId":"108","severity":1,"message":"109","line":3,"column":8,"nodeType":"110","messageId":"111","endLine":3,"endColumn":13},{"ruleId":"108","severity":1,"message":"112","line":5,"column":7,"nodeType":"110","messageId":"111","endLine":5,"endColumn":11},{"ruleId":"108","severity":1,"message":"113","line":2,"column":10,"nodeType":"110","messageId":"111","endLine":2,"endColumn":17},"no-native-reassign",["114"],"no-negated-in-lhs",["115"],"eqeqeq","Expected '===' and instead saw '=='.","BinaryExpression","unexpected","no-unused-vars","'axios' is defined but never used.","Identifier","unusedVar","'LINK' is assigned a value but never used.","'isEmail' is defined but never used.","no-global-assign","no-unsafe-negation"] \ No newline at end of file +[{"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\index.js":"1","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\reportWebVitals.js":"2","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\App.js":"3","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Topic.js":"4","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Navbar.js":"5","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Button.js":"6","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\TopicList.js":"7","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Form.js":"8","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\hooks\\input-hook.js":"9","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Thread.js":"10","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\ListThreads.js":"11","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Profile\\Profile.js":"12","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Post.js":"13","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\CommentList.js":"14","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\ThreadList.js":"15","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\PreviewThread.js":"16","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\LoginForm.js":"17","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\RegisterForm.js":"18","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth-header.js":"19","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth.service.js":"20","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\loggedInService.js":"21"},{"size":517,"mtime":1608228708909,"results":"22","hashOfConfig":"23"},{"size":375,"mtime":1608228708909,"results":"24","hashOfConfig":"23"},{"size":1059,"mtime":1610110193424,"results":"25","hashOfConfig":"23"},{"size":1433,"mtime":1610115857293,"results":"26","hashOfConfig":"23"},{"size":1659,"mtime":1610115857292,"results":"27","hashOfConfig":"23"},{"size":310,"mtime":1609674995191,"results":"28","hashOfConfig":"23"},{"size":774,"mtime":1610110193428,"results":"29","hashOfConfig":"23"},{"size":1705,"mtime":1610117688744,"results":"30","hashOfConfig":"23"},{"size":374,"mtime":1609495708947,"results":"31","hashOfConfig":"23"},{"size":3903,"mtime":1610116889753,"results":"32","hashOfConfig":"23"},{"size":703,"mtime":1609612143908,"results":"33","hashOfConfig":"23"},{"size":1864,"mtime":1609674995194,"results":"34","hashOfConfig":"23"},{"size":1593,"mtime":1610117665047,"results":"35","hashOfConfig":"23"},{"size":708,"mtime":1610116344406,"results":"36","hashOfConfig":"23"},{"size":404,"mtime":1609674083165,"results":"37","hashOfConfig":"23"},{"size":751,"mtime":1609674995195,"results":"38","hashOfConfig":"23"},{"size":2677,"mtime":1610115857291,"results":"39","hashOfConfig":"23"},{"size":3045,"mtime":1610113902297,"results":"40","hashOfConfig":"23"},{"size":209,"mtime":1610110193430,"results":"41","hashOfConfig":"23"},{"size":861,"mtime":1610117080683,"results":"42","hashOfConfig":"23"},{"size":103,"mtime":1610114385716,"results":"43","hashOfConfig":"23"},{"filePath":"44","messages":"45","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"1e00zfu",{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"51","messages":"52","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"57","usedDeprecatedRules":"46"},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"64","messages":"65","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"66","messages":"67","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"68","messages":"69","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"70","messages":"71","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"74","messages":"75","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"76","messages":"77","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"78","usedDeprecatedRules":"46"},{"filePath":"79","messages":"80","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"81","messages":"82","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"83","messages":"84","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},{"filePath":"85","messages":"86","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"46"},"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\index.js",[],["89","90"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\reportWebVitals.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\App.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Topic.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Navbar.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Button.js",["91","92"],"import React from \"react\";\r\nimport './Button.css';\r\nimport {\r\n Link\r\n } from \"react-router-dom\"\r\n\r\nfunction Button(props) {\r\n return (\r\n <Link to={`/${props.url}`}>\r\n <button className={`button ${props.color}`}>{props.text}</button>\r\n </Link>\r\n )\r\n}\r\n\r\nexport default Button;","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\TopicList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Form.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\hooks\\input-hook.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Thread.js",["93"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\ListThreads.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Profile\\Profile.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\Post.js",["94","95"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\CommentList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\ThreadList.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\Threads\\PreviewThread.js",["96","97"],"import React from \"react\";\r\n\r\nimport axios from \"axios\";\r\n\r\nconst LINK = 'http://localhost:4000';\r\n\r\n\r\nfunction PreviewThread (props) {\r\n\r\n // const userName = await axios.get(`${LINK}/api/threads/${props.user_id}`);\r\n // const topic_id = `${props.topic_id}`\r\n // const topicName = await axios.get(`${LINK}/api/topics/${props.topic_id}`).data.data.find(topic => topic.name === topic_id).id\r\n return (\r\n <div className=\"thread_container\">\r\n <h1>{props.title}</h1>\r\n <div className=\"label\">\r\n <h2>{props.topic_id}</h2>\r\n </div>\r\n <div className=\"info\">\r\n <h3>{props.timestamp}</h3>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\nexport default PreviewThread;","C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\LoginForm.js",["98","99"],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\RegisterForm.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth-header.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\auth.service.js",[],"C:\\Users\\Ryo Axtonlie\\Documents\\..KULIAH\\SEM 5\\PemFung\\tk\\diskuy\\diskuy\\src\\services\\loggedInService.js",[],{"ruleId":"100","replacedBy":"101"},{"ruleId":"102","replacedBy":"103"},{"ruleId":"104","severity":1,"message":"105","line":8,"column":18,"nodeType":"106","messageId":"107","endLine":8,"endColumn":20},{"ruleId":"104","severity":1,"message":"105","line":14,"column":23,"nodeType":"106","messageId":"107","endLine":14,"endColumn":25},{"ruleId":"104","severity":1,"message":"105","line":41,"column":105,"nodeType":"106","messageId":"107","endLine":41,"endColumn":107},{"ruleId":"104","severity":1,"message":"105","line":12,"column":27,"nodeType":"106","messageId":"107","endLine":12,"endColumn":29},{"ruleId":"104","severity":1,"message":"105","line":33,"column":51,"nodeType":"106","messageId":"107","endLine":33,"endColumn":53},{"ruleId":"108","severity":1,"message":"109","line":3,"column":8,"nodeType":"110","messageId":"111","endLine":3,"endColumn":13},{"ruleId":"108","severity":1,"message":"112","line":5,"column":7,"nodeType":"110","messageId":"111","endLine":5,"endColumn":11},{"ruleId":"108","severity":1,"message":"113","line":2,"column":10,"nodeType":"110","messageId":"111","endLine":2,"endColumn":17},{"ruleId":"108","severity":1,"message":"114","line":6,"column":5,"nodeType":"110","messageId":"111","endLine":6,"endColumn":9},"no-native-reassign",["115"],"no-negated-in-lhs",["116"],"eqeqeq","Expected '===' and instead saw '=='.","BinaryExpression","unexpected","no-unused-vars","'axios' is defined but never used.","Identifier","unusedVar","'LINK' is assigned a value but never used.","'isEmail' is defined but never used.","'Link' is defined but never used.","no-global-assign","no-unsafe-negation"] \ No newline at end of file diff --git a/diskuy/src/Threads/CommentList.js b/diskuy/src/Threads/CommentList.js index 625bcb9..8163e47 100644 --- a/diskuy/src/Threads/CommentList.js +++ b/diskuy/src/Threads/CommentList.js @@ -8,7 +8,7 @@ export default function CommentList(props){ <Post type="comment" text={value.message} - user="Halo guys, David disini" + user={value.username} points={value.points} id={value.id} user_id={value.user_id} diff --git a/diskuy/src/Threads/Post.js b/diskuy/src/Threads/Post.js index db6eacd..ca76d9a 100644 --- a/diskuy/src/Threads/Post.js +++ b/diskuy/src/Threads/Post.js @@ -1,6 +1,8 @@ import './Post.css'; import './Comment.css'; import axios from 'axios'; +import AuthService from '../services/auth.service' +import authHeader from '../services/auth-header' const LINK = 'http://localhost:4000/'; export default function Post(props){ @@ -9,10 +11,12 @@ export default function Post(props){ try { if(event.type == "thread") { console.log("aaaa") - await axios.delete(`${LINK}api/threads/${event.id}`); - props.history.push(`/${event.topic_id}`); + await axios.delete(`${LINK}api/threads/${event.id}` + ,{headers: authHeader()}); + props.history.push(`/`); } else { - await axios.delete(`${LINK}api/post/${event.id}`); + await axios.delete(`${LINK}api/post/${event.id}` + ,{headers: authHeader()}); window.location.reload(); } } catch (error) {} @@ -25,9 +29,12 @@ export default function Post(props){ <div id="round"></div> <p id="creator">By {props.user} - {props.time} </p> </div> - <div id="headerButton"> + + { AuthService.getCurrentUser().id == props.user_id && ( + <div id="headerButton"> <button type="button" className="btn btn-outline-danger deleteButton" onClick={() => deletePost(props)}>Delete</button> </div> + )} </div> <div id="postContent"> <h1 id="judul">{props.header}</h1> diff --git a/diskuy/src/Threads/Thread.js b/diskuy/src/Threads/Thread.js index c51d932..78a7a84 100644 --- a/diskuy/src/Threads/Thread.js +++ b/diskuy/src/Threads/Thread.js @@ -5,6 +5,7 @@ import Post from './Post'; import { useInput } from '../hooks/input-hook'; import axios from 'axios'; import { loggedIn } from '../services/loggedInService' +import authHeader from '../services/auth-header' const LINK = 'http://localhost:4000/'; @@ -16,17 +17,18 @@ export default function Thread(props){ title:"", topic_id:"", user_id:"", - updated_at: "" + updated_at: "", + username:"" }); const [comment, setComment] = useState([{ + id: "", message : "", points: 0, - status: "", thread_id: "", - post_parent_id: "", user_id:"", - updated_at: "" + updated_at: "", + username:"" }]); const { value: input, bind: bindInput, reset: resetInput } = useInput(''); @@ -70,12 +72,11 @@ export default function Thread(props){ post : { message : input, points : 0, - status : 'iniapa', thread_id : threadParm, - post_parent_id: "", - user_id : 1 + user_id : localStorage.getItem('id') } - }) + }, + {headers: authHeader()}) refreshComment(); } catch (error) {} resetInput(); @@ -89,7 +90,7 @@ export default function Thread(props){ type="thread" text={thread.content} header={thread.title} - user="Hello guys David disini" + user={thread.username} points={thread.point} id={thread.id} user_id={thread.user_id} -- GitLab