Fakultas Ilmu Komputer UI

Commit 49626b4e authored by FadhilP's avatar FadhilP
Browse files

further refactoring

parent 6575fd6c
......@@ -24,7 +24,9 @@ export default function LoginForm(props) {
return (
<div className="loginFormContainer">
<h1><b>Login to discuss anything on Diskuy</b></h1>
<h1>
<b>Login to discuss anything on Diskuy</b>
</h1>
<div className="App">
<GoogleLogin
clientId={CLIENT_ID}
......
......@@ -4,7 +4,7 @@ import axios from 'axios';
import ThreadList from './thread/ThreadList';
import { API_URL } from '../config/keys';
import Pagination from './thread/Pagination';
import "../styles/Search.css"
import '../styles/Search.css';
export default function Search(props) {
const { params } = props.match;
......@@ -37,7 +37,9 @@ export default function Search(props) {
return (
<div className="searchresultContainer">
<h1><b>Search Results for "{searchParam}"</b></h1>
<h1>
<b>Search Results for "{searchParam}"</b>
</h1>
<ThreadList thread={threads} />
{totalItems != 0 && (
<div className="paginationContainer">
......
......@@ -72,9 +72,7 @@ export default function Profile(props) {
<div className="my_threads_section">
<div className="sub_header_my_threads">
<h3>
<b>
{isUser ? 'Your' : user.username}'s threads
</b>
<b>{isUser ? 'Your' : user.username}'s threads</b>
</h3>
{isUser && (
<Button text="Create Thread" color="orange" url="create/thread" />
......
/* eslint-disable eqeqeq */
import '../../styles/thread/Post.css';
import axios from 'axios';
import AuthService, { authHeader, loggedIn } from '../../helpers/services/auth.service';
import AuthService, {
authHeader,
loggedIn,
} from '../../helpers/services/auth.service';
import React, { useState, useEffect } from 'react';
import { translate } from '../../helpers/time-util';
import { API_URL } from '../../config/keys';
......@@ -86,8 +89,11 @@ export default function Post(props) {
<div id="postHeader">
<div id="headerData">
<div className="userImage">
{user.picture == 'None' && <i className="far fa-user-circle" />}
{user.picture != 'None' && <img alt="profile" src={user.picture} />}
{user.picture == 'None' ? (
<i className="far fa-user-circle" />
) : (
<img alt="profile" src={user.picture} />
)}
</div>
<div className="creator">
<p>
......@@ -104,7 +110,7 @@ export default function Post(props) {
<div className="buttonContainer">
{content.user_id == AuthService.getCurrentUserId() && (
<div>
{checkType == "threads" && (
{checkType == 'threads' && (
<Button
type="button"
text="Edit"
......@@ -130,7 +136,11 @@ export default function Post(props) {
<div className="likeSection">
{loggedIn && (
<button className="likeButton" onClick={handleLike}>
<i className={`far fa-thumbs-up ${isLiked ? 'active' : 'inactive'}`} />
<i
className={`far fa-thumbs-up ${
isLiked ? 'active' : 'inactive'
}`}
/>
</button>
)}
<div className="pointContainer">
......
......@@ -16,7 +16,8 @@ export default function PreviewThread(props) {
<div id="threadCardContent">
<p>
By{' '}
<Link to={`/profile/${content.username}/1`}>{content.username}</Link> - {time} - <i className="far fa-thumbs-up" /> {content.points}
<Link to={`/profile/${content.username}/1`}>{content.username}</Link>{' '}
- {time} - <i className="far fa-thumbs-up" /> {content.points}
</p>
</div>
</div>
......
......@@ -35,17 +35,17 @@ export default function RecentThreads(props) {
return (
<div className="recentThreads">
{totalItems == 0 ? (
<p>There is no thread yet.</p>
<p>There is no thread yet.</p>
) : (
<Fragment>
<ThreadList thread={threads} />
<div className="paginationContainer">
<Pagination
activePage={currentPage}
totalItems={totalItems}
switchPage={switchPage}
/>
</div>
<Pagination
activePage={currentPage}
totalItems={totalItems}
switchPage={switchPage}
/>
</div>
</Fragment>
)}
</div>
......
......@@ -9,7 +9,9 @@ import AuthService, { loggedIn } from '../../helpers/services/auth.service';
export default function TopicList(props) {
const [topics, setTopics] = useState([]);
const isAdmin = loggedIn ? AuthService.getCurrentUser()?.data?.role : "unregistered";
const isAdmin = loggedIn
? AuthService.getCurrentUser()?.data?.role
: 'unregistered';
useEffect(() => {
const fetch = async () => {
......@@ -23,7 +25,7 @@ export default function TopicList(props) {
<div className="topicContainer">
<div className="headerTopic">
<h1>Topic List</h1>
{loggedIn && isAdmin == "admin" && (
{loggedIn && isAdmin == 'admin' && (
<Button text="Create Topic" color="orange" url="create/topic" />
)}
</div>
......
......@@ -12,11 +12,7 @@ function Footer() {
<p>
<b>Developed under</b>
</p>
<a
target="_blank"
href="https://cs.ui.ac.id"
className="footerMenu"
>
<a target="_blank" href="https://cs.ui.ac.id" className="footerMenu">
<FasilkomLogo />
</a>
</div>
......
......@@ -66,14 +66,14 @@ const Navbar = (props) => {
</Link>
</li>
{loggedIn && (
<li className="nav-item mr-auto">
<Link
to={`/profile/${AuthService.getCurrentUsername()}/1`}
className="nav-link"
>
<b>Profile</b>
</Link>
</li>
<li className="nav-item mr-auto">
<Link
to={`/profile/${AuthService.getCurrentUsername()}/1`}
className="nav-link"
>
<b>Profile</b>
</Link>
</li>
)}
{loggedIn ? (
<li className="nav-item mr-auto" onClick={handleLogout}>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment