Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding forum comment notification #459

Merged
merged 92 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c8b297b
fix(deps): update dependency @aws-amplify/auth to v4 (#352)
renovate[bot] Mar 23, 2022
0504ac9
Feature: Added Dark theme (#365)
nichnarmada Mar 27, 2022
d789596
fix: clear search keywords when onclick related courses
YHhaoareyou Mar 27, 2022
fba8238
Merge branch 'master' into develop
YHhaoareyou Mar 27, 2022
4cc5b89
Merge branch 'master' into develop
YHhaoareyou Mar 29, 2022
bc8ecd7
Merge branch 'master' into develop
YHhaoareyou Mar 29, 2022
67b4a97
Debug: mobile dark mode debug (#373)
YHhaoareyou Apr 1, 2022
ed25abf
chore(deps): update dependency eslint-plugin-react to v7.29.4 (#361)
renovate[bot] Apr 1, 2022
86a91f5
chore(deps): update dependency ts-loader to v9.2.8 (#359)
renovate[bot] Apr 1, 2022
374a41a
feat: remove unused dependencies (#377)
YHhaoareyou Apr 13, 2022
6632a95
Feature/darktheme colors (#378)
YHhaoareyou Apr 13, 2022
2f8dd9b
Merge branch 'master' into develop
YHhaoareyou Apr 17, 2022
8492b1c
Feature: Timetable dark theme (#379)
YHhaoareyou Apr 18, 2022
66db621
feat: add the hovering effect to the member cards (#381)
xinyue296 Apr 26, 2022
ef10256
Migrate from Webpack to Vite (#382)
YHhaoareyou May 2, 2022
84b2c1d
fix: env without using dotenv explicitly (#385)
YHhaoareyou May 5, 2022
c3abb53
fix: packages version
YHhaoareyou May 5, 2022
5993df1
fix: change env var name
YHhaoareyou May 5, 2022
76976ee
fix: remove systemjs package; add peer dependencies
YHhaoareyou May 5, 2022
e52cdef
fix: feeds domain on staging/prod
YHhaoareyou May 5, 2022
59fdef5
Feature: About Us page link from Home page & split Home from Root-con…
YHhaoareyou May 6, 2022
8252657
Feature/fix card padding (#388)
xinyue296 May 10, 2022
f509547
Merge branch 'master' into develop
YHhaoareyou May 17, 2022
25973a1
fix: install missing dependency: @aws-amplify/core
YHhaoareyou May 17, 2022
8f4caf8
fix: remove course function
YHhaoareyou May 18, 2022
e8a35a6
feat: alert translation
YHhaoareyou May 18, 2022
c0585c1
fix: eslint
YHhaoareyou May 18, 2022
5d47e3c
feat: add workbox runtimeCaching config
YHhaoareyou May 19, 2022
7c6cd35
Fix service worker to enable it to replace old one (#389)
YHhaoareyou May 20, 2022
626ceca
feat: add a profile card component; add hover & click effect; add a c…
xinyue296 May 23, 2022
4bc712d
fix: syllabus minor styling issues
YHhaoareyou May 29, 2022
6245a70
Update README.md
YHhaoareyou May 29, 2022
156663d
Migrate from Webpack to Vite (#386)
YHhaoareyou May 29, 2022
6c911c8
add script-src-elem to Content Security Policy (#391)
YHhaoareyou May 29, 2022
081c41c
Hotfix (#392)
YHhaoareyou May 29, 2022
d1e063a
Hotfix (#393)
YHhaoareyou May 29, 2022
bbc1a69
Merge branch 'master' into develop
YHhaoareyou May 29, 2022
4f556ac
fix blob in csp
YHhaoareyou May 29, 2022
6fa7950
Merge branch 'master' into develop
YHhaoareyou May 30, 2022
8b825bf
fix: remove csp
YHhaoareyou May 30, 2022
893d781
Merge branch 'master' into develop
YHhaoareyou May 30, 2022
0af6214
fix: remove all webpack-related packages & setting
YHhaoareyou May 30, 2022
969da50
Allow all in CSP
YHhaoareyou May 30, 2022
a552f36
Merge branch 'master' into develop
YHhaoareyou May 30, 2022
2505b59
Fix: preload style, csp allow all, refactor index html & env var (#404)
YHhaoareyou May 31, 2022
25cdc27
Update README.md (#397)
eltociear Jun 8, 2022
0bc6cd2
chore(deps): update dependency esbuild to v0.14.43 (#384)
renovate[bot] Jun 8, 2022
c40864e
Merge branch 'master' into develop
AustinZhu Jun 8, 2022
02849a9
chore(deps): update dependencies
AustinZhu Jun 8, 2022
fc74d84
chore(deps): update dependencies
AustinZhu Jun 8, 2022
5470785
chore(deps): update dependencies
AustinZhu Jun 8, 2022
768301a
fix: preload & enable styles from other mf app
YHhaoareyou Jul 6, 2022
6c87d18
fix: packages version (fix React to v17)
YHhaoareyou Jul 6, 2022
b3484e5
Merge branch 'master' into develop
YHhaoareyou Aug 16, 2022
4606cab
Language filter for Feeds (#409)
YHhaoareyou Oct 3, 2022
5f94f13
Merge branch 'master' into develop
YHhaoareyou Oct 27, 2022
10e0f20
feat: added turbo-repo woooo (#420)
nichnarmada Jan 19, 2023
f76867f
Merge branch 'master' into develop
YHhaoareyou Mar 11, 2023
5c1a08b
feat: adding web hooks for forums
JasonNotJson Apr 16, 2023
d0d4ec3
Merge pull request #425 from wasedatime/feat/add-webhook
YHhaoareyou May 3, 2023
5837cc8
feat: updating meet our team page (#426)
JasonNotJson May 5, 2023
2d27b2c
Export Bit components to turborepo packages (#428)
YHhaoareyou May 25, 2023
d04f3c6
Feature: Remove bit from npmrc (#431)
nichnarmada Jun 22, 2023
dffbc9f
fix: fixing tailwind:build from tailwind to tailwindcss
JasonNotJson Jun 22, 2023
714dcbf
feat: reorganizing meet our teams list
JasonNotJson Sep 12, 2023
2e262e7
feat: adding alfonso lien and shiori
JasonNotJson Sep 12, 2023
87a8890
chore: ah comeon
JasonNotJson Sep 12, 2023
f8bf2dc
chore: what in the hell is a JPG and a jpg
JasonNotJson Sep 12, 2023
b70493e
chore: oh Jason focus comeon why are you doing stupid stuff mistaking…
JasonNotJson Sep 12, 2023
a8fc457
feat: adding forum into develop (#446)
JasonNotJson Sep 12, 2023
b345a28
feat: final check on develop now time to deploy
JasonNotJson Sep 12, 2023
ca4437e
feat: merge conflict resolution
JasonNotJson Sep 12, 2023
7d15560
feat: adding type safety to prevent from accessing null length
JasonNotJson Sep 12, 2023
57b72ab
feat: adding array safety
JasonNotJson Sep 12, 2023
0b88bb2
fix: adding another type safety for response array
JasonNotJson Sep 12, 2023
42d3388
feat: adding some common css to see the change
JasonNotJson Sep 12, 2023
8cbb193
feat: altering styling
JasonNotJson Sep 12, 2023
961c070
feat: adding responive ness
JasonNotJson Sep 12, 2023
04d52c8
feat: altered timeline new feature add comment logo no more title and…
JasonNotJson Sep 12, 2023
56f8541
Merge branch 'master' into develop
JasonNotJson Sep 12, 2023
0a557cf
feat: changing our mission
JasonNotJson Sep 12, 2023
a155d54
feat: enlarging the fontsize of forums. Currently it was just too sma…
JasonNotJson Sep 13, 2023
1ccc5b1
fix: fixing App layout and adding onclikc to fix links (#454)
JasonNotJson Sep 13, 2023
9e1eca3
feat: fixing finalization
JasonNotJson Sep 13, 2023
7e3680f
Merge branch 'develop' of https://github.com/wasedatime/wasedatime-we…
JasonNotJson Sep 13, 2023
0a57ff8
feat: adding max width to thread post card
JasonNotJson Sep 13, 2023
8f84951
Merge branch 'master' into develop
JasonNotJson Sep 13, 2023
a83c7d4
feat: added comment count (#456)
JasonNotJson Sep 17, 2023
5575654
fix: fix new feature image size
JasonNotJson Sep 17, 2023
2c972de
feat: resolving merge conflicts
JasonNotJson Sep 17, 2023
36f7e02
feat: adding forum comment notification functionality (#458)
JasonNotJson Sep 18, 2023
d8d4a87
Merge branch 'master' into develop
JasonNotJson Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions apps/forum/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import FilterMenu from "./FilterMenu";
import SearchTags from "./SearchTags";
import FeedBackBox from "./FeedBackBox";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";

import RefreshIcon from "@mui/icons-material/Refresh";
import { API } from "@aws-amplify/api";
import { getUserAttr, getIdToken } from "wasedatime-ui";

const App = () => {
return (
Expand All @@ -31,13 +31,36 @@ const InnerApp = () => {
const { theme, setTheme } = React.useContext(ThemeContext);
const [refresh, setRefresh] = useState(false);
const [board, setBoard] = useState("");
const [commentNotify, setCommentNotify] = useState(false);
const navigate = useNavigate();

const handleReset = () => {
navigate("/forum");
setRefresh(!refresh);
};

const fetchNotification = async () => {
let idToken = "";
if (idToken?.length <= 0) {
idToken = await getIdToken();
if (idToken?.length <= 0) return;
}
const res = await API.get("wasedatime-dev", `/forum/user`, {
headers: {
"Content-Type": "application/json",
Authorization: idToken,
},
response: true,
});

const commentFlag = res.data.data.new_comment_flag;
setCommentNotify(commentFlag);
};

useEffect(() => {
fetchNotification();
}, []);

return (
<>
<div className="flex h-[67px] shrink-0 grow-0">
Expand All @@ -52,6 +75,8 @@ const InnerApp = () => {
setTheme={setTheme}
changeLang={(lng: string | undefined) => i18n.changeLanguage(lng)}
boardSlug={board}
disabled={true}
commentNotify={commentNotify}
/>
</div>
<div className="flex flex-col h-[calc(100vh-50px)] mt-[23px]">
Expand Down
3 changes: 1 addition & 2 deletions apps/forum/src/components/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import boards from "@app/constants/boards.json";
import { currentSchoolState, currentTagsState } from "@app/recoil/atoms";
import { API } from "@aws-amplify/api";
import Thread from "@app/types/thread";
import { getUserAttr } from "wasedatime-ui";
import { getUserAttr, getIdToken } from "wasedatime-ui";
import ThreadType from "@app/types/thread";
import InfiniteScroll from "react-infinite-scroll-component";

Expand Down Expand Up @@ -78,7 +78,6 @@ const Board = ({ triggerRefresh, setBoard }: any) => {
setUserToken(userId);
}
}

const apiPath = boardId
? // if board id exists, the db query has better efficiency
`/forum?uid=${userId}&index=${index}&num=${threadCount}&school=${school}&tags=${tags}&board_id=${boardId}`
Expand Down
1 change: 0 additions & 1 deletion apps/forum/src/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const Comment = ({ comment, thread, setComments, setThread }: Props) => {
};

const deleteComment = async () => {
console.log("Triggered!");
try {
const idToken = await getIdToken();
if (!idToken || idToken.length === 0) {
Expand Down
4 changes: 0 additions & 4 deletions apps/forum/src/components/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const CommentForm: React.FC<CommentFormProps> = ({
const { boardSlug, threadUuid } = useParams();
const { t } = useTranslation();

useEffect(() => {
console.log(thread);
}, [thread]);

const handleFocusForm = async () => {
if (userToken?.length <= 0) {
const idToken = await getIdToken();
Expand Down
4 changes: 2 additions & 2 deletions apps/forum/src/components/CreateThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const CreateThread = ({ onNewThread }: CreateThreadProps) => {

return isExpanded ? (
<div className="relative">
<div className="border-2 text-start text-black dark:text-white bg-light-card1 dark:bg-dark-bgMain dark:text-dark-text1 dark:shadow-none p-2 border-light-main dark:border-dark-main rounded-lg">
<div className="border-4 text-start text-black dark:text-white bg-light-card1 dark:bg-dark-bgMain dark:text-dark-text1 dark:shadow-none p-2 border-light-main dark:border-dark-main rounded-lg">
<BoardDropdownMenu slug={boardSlug} />
{/* <textarea
placeholder={`Enter Title`}
Expand Down Expand Up @@ -320,7 +320,7 @@ const CreateThread = ({ onNewThread }: CreateThreadProps) => {
) : (
<div>
<div className="cursor-pointer" onClick={handleOpenForm}>
<h1 className="border-2 p-2 rounded-lg border-light-main">
<h1 className="border-4 p-2 rounded-lg border-light-main">
Anything interesting?
</h1>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/forum/src/components/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Thread = () => {

useEffect(() => {
fetchData();
}, []);
}, [threadUuid, boardSlug]);

const handleNewComment = (newComment: CommentType) => {
setComments((prevComments) => [newComment, ...prevComments]);
Expand Down
13 changes: 8 additions & 5 deletions apps/forum/src/components/ThreadBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const ThreadBlock = ({ isPreview, fromRoot, thread, onDelete }: Props) => {
</div> */}
<hr className="mx-2 pt-2 mt-6" />
<div className="flex flex-row justify-evenly pt-2 items-center">
<div className="flex flex-row items-center content-center">
<div className="flex flex-row items-center justify-center">
<button onClick={handleLike} className="clipboard-icon group">
<Favorite
color={userLiked ? "error" : undefined}
Expand All @@ -257,9 +257,12 @@ const ThreadBlock = ({ isPreview, fromRoot, thread, onDelete }: Props) => {
<span className="text-3xl">{totalLikes}</span>
</h3>
</div>
<h3>
<TextsmsIcon fontSize="large" />
<span>{" "}</span>
<h3 className="flex flex-row items-center justify-center gap-2">
<TextsmsIcon
fontSize="large"
color={thread.new_comment && thread.mod ? "success" : "inherit"}
/>
{/* <span>{" "}</span> */}
<span className="text-3xl">{thread.comment_count}</span>
</h3>
<button className="clipboard-icon group" onClick={handleShare}>
Expand All @@ -268,7 +271,7 @@ const ThreadBlock = ({ isPreview, fromRoot, thread, onDelete }: Props) => {
Link Copied!
</span>
</button>
<h3 className="items-center content-center justify-center">
<h3 className="flex flex-row items-center justify-center gap-2">
<Visibility fontSize="large" />{" "}
<span className="text-3xl">{thread.views}</span>
</h3>
Expand Down
21 changes: 21 additions & 0 deletions apps/forum/src/components/common/CommentNotification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import NotificationsIcon from "@mui/icons-material/Notifications";
import NotificationsActiveIcon from "@mui/icons-material/NotificationsActive";

type Props = {
commentNotify?: boolean;
};

const CommentNotification = ({ commentNotify }: Props) => {
return (
<div className="p-2 text-center flex items-center justify-center">
{commentNotify ? (
<NotificationsActiveIcon fontSize="large" color="error" />
) : (
<NotificationsIcon fontSize="large" />
)}
</div>
);
};

export default CommentNotification;
6 changes: 5 additions & 1 deletion apps/forum/src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { useNavigate } from "react-router-dom";

import colors from "wasedatime-ui/colors";
import LanguageMenu from "./LanguageMenu";
import {sizes} from "wasedatime-ui"
import { sizes } from "wasedatime-ui";
import logo from "@app/assets/logo.svg";
import { ThemeToggle } from "./ThemeToggle";
import { THEME } from "@app/types/theme";
import { SearchIcon } from "../icons/SearchIcon";
import CommentNotification from "./CommentNotification";

const headerStyle = (isBlur: boolean, theme: THEME) => {
const lightBackgroundColor = isBlur ? "#FAFAFA30" : colors.light.bgSide;
Expand Down Expand Up @@ -92,6 +93,7 @@ type HeaderProps = {
theme?: THEME;
setTheme?: (theme: THEME) => void;
onSearchBarClick?: () => void;
commentNotify: boolean;
};

const Header = ({
Expand All @@ -105,6 +107,7 @@ const Header = ({
theme = THEME.LIGHT,
setTheme,
onSearchBarClick = () => {},
commentNotify,
}: HeaderProps) => {
let navigate = useNavigate();
const [isInputExpanded, setIsInputExpanded] = useState(false);
Expand Down Expand Up @@ -181,6 +184,7 @@ const Header = ({
</MediaQuery>

<div style={headerMenuWrapperStyle}>
<CommentNotification commentNotify={commentNotify} />
<ThemeToggle theme={theme} setTheme={setTheme} />
<LanguageMenu changeLang={changeLang} />
</div>
Expand Down
26 changes: 14 additions & 12 deletions apps/forum/src/components/common/HeaderWithModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Props = {
setTheme?: (theme: THEME) => void;
onSearchBarClick?: () => void;
boardSlug: string;
commentNotify: boolean;
};

const HeaderWithModal = ({
Expand All @@ -23,26 +24,27 @@ const HeaderWithModal = ({
boardSlug,
...others
}: Props) => {
const [isModalOpen, setModalOpen] = useState(false);
const [board, setBoard] = useState(boardSlug);
// const [isModalOpen, setModalOpen] = useState(false);
// const [board, setBoard] = useState(boardSlug);

useEffect(() => {
setBoard(boardSlug);
}, [boardSlug]);
// useEffect(() => {
// setBoard(boardSlug);
// }, [boardSlug]);

const handleSearchBarClick = () => {
if (onSearchBarClick) onSearchBarClick();
setModalOpen(!isModalOpen);
};
// const handleSearchBarClick = () => {
// if (onSearchBarClick) onSearchBarClick();
// setModalOpen(!isModalOpen);
// };

return (
<>
<Header {...others} onSearchBarClick={handleSearchBarClick} />
{modal({
{/* <Header {...others} onSearchBarClick={handleSearchBarClick} /> */}
<Header {...others} />
{/* {modal({
isShow: isModalOpen,
closeModal: () => setModalOpen(false),
boardSlug: board,
})}
})} */}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/forum/src/components/icons/CloseIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import React, { useState } from "react";
import { Close } from "@mui/icons-material";
// @mui/icons-material";

export const CloseIcon = () => <Close fontSize="small" />;
export const CloseIcon = () => <Close fontSize="large" />;
2 changes: 1 addition & 1 deletion apps/forum/src/constants/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"navigation": {
"forum": "Forum"
},
"search placeholder": "Filter threads"
"search placeholder": "Under Development"
}
4 changes: 2 additions & 2 deletions apps/forum/src/constants/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"navigation": {
"forum": "掲示板"
},
"search placeholder": "スレッド絞り込み"
}
"search placeholder": "構築中"
}
2 changes: 1 addition & 1 deletion packages/ui/src/utils/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Auth from "@aws-amplify/auth"
import { Auth } from "@aws-amplify/auth"
import { CognitoHostedUIIdentityProvider } from "@aws-amplify/auth/lib/types"

export const configAuth = () => {
Expand Down
Loading