diff --git a/components/Newsfeed/Newsfeed.tsx b/components/Newsfeed/Newsfeed.tsx index 7d0644f76..bfe70361c 100644 --- a/components/Newsfeed/Newsfeed.tsx +++ b/components/Newsfeed/Newsfeed.tsx @@ -1,7 +1,7 @@ import ErrorPage from "next/error" import { Timestamp } from "firebase/firestore" import { useTranslation } from "next-i18next" -import { useEffect, useState } from "react" +import { useContext, useEffect, useState } from "react" import { useAuth } from "../auth" import { Col, Row, Spinner } from "../bootstrap" import { usePublicProfile } from "../db" @@ -15,12 +15,18 @@ import { } from "./StyledNewsfeedComponents" import { NewsfeedCard } from "components/NewsfeedCard/NewsfeedCard" +import { ProfileButtons } from "components/ProfilePage/ProfileButtons" +import { TabContext } from "components/shared/ProfileTabsContext" +import { Profile, ProfileHook, useProfile } from "../db" +import ProfileSettingsModal from "components/EditProfilePage/ProfileSettingsModal" + export default function Newsfeed() { const { t } = useTranslation("common") const { user } = useAuth() const uid = user?.uid const { result: profile, loading } = usePublicProfile(uid) + const isUser = user?.uid !== undefined const [isShowingOrgs, setIsShowingOrgs] = useState(true) const [isShowingBills, setIsShowingBills] = useState(true) @@ -61,7 +67,7 @@ export default function Newsfeed() { fetchNotifications() }, [uid]) - function Filters() { + function Filters({ profile }: { profile: Profile }) { return ( { @@ -72,27 +78,30 @@ export default function Newsfeed() { }} isShowingOrgs={isShowingOrgs} isShowingBills={isShowingBills} + profile={profile} /> ) } function FilterBoxes({ - onOrgFilterChange, - onBillFilterChange, + isShowingBills, isShowingOrgs, - isShowingBills + onBillFilterChange, + onOrgFilterChange, + profile }: { - onOrgFilterChange: any - onBillFilterChange: any - isShowingOrgs: boolean isShowingBills: boolean + isShowingOrgs: boolean + onBillFilterChange: any + onOrgFilterChange: any + profile: Profile }) { const { t } = useTranslation("common") return ( <> - + - + + ) } + function Buttons({ profile }: { profile: Profile }) { + const { + public: isPublic, + notificationFrequency: notificationFrequency + }: Profile = profile + + const [settingsModal, setSettingsModal] = useState<"show" | null>(null) + const [notifications, setNotifications] = useState< + "Weekly" | "Monthly" | "None" + >(notificationFrequency ? notificationFrequency : "Monthly") + const [isProfilePublic, setIsProfilePublic] = useState( + isPublic ? isPublic : false + ) + + const onSettingsModalOpen = () => { + setSettingsModal("show") + setNotifications( + notificationFrequency ? notificationFrequency : "Monthly" + ) + setIsProfilePublic(isPublic ? isPublic : false) + } + + const actions = useProfile() + + const { t } = useTranslation("profile") + + return ( + <> +
+ +
+ { + setSettingsModal(null) + window.location.reload() + /* when saved and reopened, modal wasn't updating * + * would like to find cleaner solution */ + }} + show={settingsModal === "show"} + /> + + ) + } + return ( <> {loading ? ( @@ -139,10 +204,10 @@ export default function Newsfeed() {
- + {t("navigation.newsfeed")} - +
{filteredResults.length > 0 ? ( <> diff --git a/components/ProfilePage/ProfileButtons.tsx b/components/ProfilePage/ProfileButtons.tsx index 20b6267c2..3ba963e7e 100644 --- a/components/ProfilePage/ProfileButtons.tsx +++ b/components/ProfilePage/ProfileButtons.tsx @@ -68,11 +68,13 @@ export const EditProfileButton = ({ } export function ProfileButtons({ - onSettingsModalOpen, - isUser + isUser, + hideTestimonyButton, + onSettingsModalOpen }: { - onSettingsModalOpen: () => void isUser: boolean + hideTestimonyButton: boolean + onSettingsModalOpen: () => void }) { const { t } = useTranslation("editProfile") @@ -89,13 +91,17 @@ export function ProfileButtons({ }} tab={"button.followedContent"} /> - { - setTabStatus("Testimonies") - }} - tab={"button.yourTestimonies"} - /> + {hideTestimonyButton ? ( + <> + ) : ( + { + setTabStatus("Testimonies") + }} + tab={"button.yourTestimonies"} + /> + )} diff --git a/pages/newsfeed.tsx b/pages/newsfeed.tsx index a17b6d488..f68c104da 100644 --- a/pages/newsfeed.tsx +++ b/pages/newsfeed.tsx @@ -15,7 +15,13 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations" export async function getStaticProps({ locale }: any) { return { props: { - ...(await serverSideTranslations(locale, ["auth", "common", "footer"])) + ...(await serverSideTranslations(locale, [ + "auth", + "common", + "editProfile", + "footer", + "profile" + ])) // Will be passed to the page component as props } }