Skip to content

Commit

Permalink
Merge pull request #1 from mertbagt/following-tab
Browse files Browse the repository at this point in the history
Following tab
  • Loading branch information
mertbagt authored Jan 13, 2023
2 parents 6d4a738 + 7c282cc commit 3dd063a
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 161 deletions.
38 changes: 5 additions & 33 deletions components/ProfilePage/AboutMeEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type UpdateProfileData = {
aboutYou: string
twitter: string
linkedIn: string
public: boolean
organization: boolean
profileImage: any
}
Expand All @@ -33,15 +32,9 @@ async function updateProfile(
{ profile, actions, uid }: Props,
data: UpdateProfileData
) {
const {
updateIsPublic,
updateSocial,
updateAbout,
updateDisplayName,
updateFullName
} = actions
const { updateSocial, updateAbout, updateDisplayName, updateFullName } =
actions

await updateIsPublic(data.public)
await updateSocial("linkedIn", data.linkedIn)
await updateSocial("twitter", data.twitter)
await updateAbout(data.aboutYou)
Expand All @@ -62,14 +55,8 @@ export function AboutMeEditForm({
handleSubmit
} = useForm<UpdateProfileData>()

const {
displayName,
about,
organization,
public: isPublic,
social,
profileImage
}: Profile = profile
const { displayName, about, organization, social, profileImage }: Profile =
profile

const { updateIsOrganization } = actions

Expand Down Expand Up @@ -97,22 +84,7 @@ export function AboutMeEditForm({
return (
<TitledSectionCard className={className}>
<Form onSubmit={onSubmit}>
<Header
title={"About You"}
bug={
<Row className={`justify-content-center align-items-center`}>
<Form.Check
{...register("public")}
className={`col-auto about-me-checkbox`}
type="checkbox"
defaultChecked={isPublic}
/>
<Form.Label htmlFor="public" className={`col my-1`}>
Allow others to see your profile
</Form.Label>
</Row>
}
></Header>
<Header title={"About You"}></Header>
<div className={`mx-4 mt-3 d-flex flex-column gap-3`}>
{/* <Form.FloatingLabel label="User Type" className="mb-3">
<Form.Select
Expand Down
51 changes: 45 additions & 6 deletions components/ProfilePage/EditProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { Internal } from "../links"
import ViewTestimony from "../UserTestimonies/ViewTestimony"
import { AboutMeEditForm } from "./AboutMeEditForm"
import { FollowingTab } from "./FollowingTab"
import NotificationSettingsModal from "./NotificationSettingsModal"
import {
Header,
Expand Down Expand Up @@ -43,9 +44,28 @@ export function EditProfileForm({
actions: ProfileHook
uid: string
}) {
const {
public: isPublic,
notificationFrequency: notificationFrequency
}: Profile = profile

const [key, setKey] = useState("AboutYou")
const [formUpdated, setFormUpdated] = useState(false)
const [settingsModal, setSettingsModal] = useState<"show" | null>(null)
const [notifications, setNotifications] = useState<
"Daily" | "Weekly" | "Monthly" | "None"
>(notificationFrequency ? notificationFrequency : "Monthly")
const [isProfilePublic, setIsProfilePublic] = useState<false | true>(
isPublic ? isPublic : false
)

const onSettingsModalOpen = () => {
setSettingsModal("show")
setNotifications(notificationFrequency ? notificationFrequency : "Monthly")
setIsProfilePublic(isPublic ? isPublic : false)
}

const close = () => setSettingsModal(null)

const testimony = usePublishedTestimonyListing({
uid: uid
Expand Down Expand Up @@ -82,11 +102,22 @@ export function EditProfileForm({
className="mt-3 mb-4"
/>
)
},
{
title: "Following",
eventKey: "Following",
content: (
<FollowingTab
profile={profile}
actions={actions}
uid={uid}
setFormUpdated={setFormUpdated}
className="mt-3 mb-4"
/>
)
}
]

const close = () => setSettingsModal(null)

return (
<Container>
<Header>
Expand All @@ -99,12 +130,15 @@ export function EditProfileForm({
*/
className={`btn btn-lg btn-outline-secondary me-4 invisible`}
disabled={!!formUpdated}
onClick={() => setSettingsModal("show")}
onClick={() => onSettingsModalOpen()}
>
{"Settings"}
</GearButton>
</Internal>
<Internal className={`ml-2`} href={`/profile?id=${uid}`}>
<Internal
className={`ml-2`}
href={!!formUpdated ? `javascript:void(0)` : `/profile?id=${uid}`}
>
<Button className={`btn btn-lg`} disabled={!!formUpdated}>
{!profile.organization
? "View your profile"
Expand Down Expand Up @@ -135,9 +169,14 @@ export function EditProfileForm({
</StyledTabContent>
</TabContainer>
<NotificationSettingsModal
show={settingsModal === "show"}
actions={actions}
isProfilePublic={isProfilePublic}
setIsProfilePublic={setIsProfilePublic}
notifications={notifications}
setNotifications={setNotifications}
onHide={close}
onClickCloseModal={() => setSettingsModal(null)}
onSettingsModalClose={() => setSettingsModal(null)}
show={settingsModal === "show"}
/>
</Container>
)
Expand Down
37 changes: 37 additions & 0 deletions components/ProfilePage/FollowingTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import clsx from "clsx"
import { ChangeEvent, useEffect, useState } from "react"
import { FormCheck, FormControlProps } from "react-bootstrap"
import { useForm } from "react-hook-form"
import { Button, Form, Image, Row, Col } from "../bootstrap"
import { Profile, ProfileHook } from "../db"
import Input from "../forms/Input"
import { TitledSectionCard } from "../shared"
import { Header } from "../shared/TitledSectionCard"
import { ImageInput } from "./ImageInput"
import { YourLegislators } from "./YourLegislators"
import { Internal } from "../links"

type Props = {
profile: Profile
actions: ProfileHook
uid?: string
setFormUpdated?: any
className?: string
}

export function FollowingTab({
profile,
actions,
uid,
className,
setFormUpdated
}: Props) {
return (
<TitledSectionCard className={className}>
<Header title={"Following"} />
<div className={`mx-4 mt-3 d-flex flex-column gap-3`}>
{"Bills You Follow"}
</div>
</TitledSectionCard>
)
}
Loading

0 comments on commit 3dd063a

Please sign in to comment.