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

Epic 2 Foundational UI -- Profile Notifications/No Organizations Views #324

Merged
merged 24 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c527f7d
Polish profile page UI layout
joshua-rdrgz Feb 2, 2024
cc26884
Modify DataTable to accept any type/interface
joshua-rdrgz Feb 4, 2024
aa0cae5
Add left/right margins to profile page container
joshua-rdrgz Feb 4, 2024
44bae5e
Add ProfileNotifications component
joshua-rdrgz Feb 4, 2024
cbbc30e
Add ProfileOrganizations component and related subcomps
joshua-rdrgz Feb 4, 2024
e8b39f9
Add "Notifications" and "Organizations" to Profile Menu
joshua-rdrgz Feb 4, 2024
b2440c8
Install form-validation/Radix-UI dependencies:
joshua-rdrgz Feb 11, 2024
34d4203
Create foundational Dialog component(s)
joshua-rdrgz Feb 11, 2024
daa7a72
Add `useId` hook for form accessibility
joshua-rdrgz Feb 11, 2024
499d0eb
Create base `label` component
joshua-rdrgz Feb 11, 2024
0d6d10e
Create base `form` component(s)
joshua-rdrgz Feb 11, 2024
ba75b6f
Create select/option(s) component(s)
joshua-rdrgz Feb 11, 2024
cdb8264
Create foundational `<input>` component
joshua-rdrgz Feb 11, 2024
d8889d3
make `PrimaryButton` receive forwarded "ref"
joshua-rdrgz Feb 11, 2024
10cb92b
Add foundational UI components to shared-components export
joshua-rdrgz Feb 11, 2024
f9406fa
Create `CreateOrganizationBtn` component w/dialog functionality
joshua-rdrgz Feb 11, 2024
623efdd
Place `CreateOrganizationBtn` in profile views
joshua-rdrgz Feb 11, 2024
c6330b2
Add confirm dialog to Join/Leave btn on notifications table
joshua-rdrgz Feb 11, 2024
f484cdb
update profile page snapshot: add 2 sections to profile nav
joshua-rdrgz Feb 11, 2024
889e3d2
Merge branch 'main' into josh/epic-two-ui
joshua-rdrgz Feb 11, 2024
3875530
get rid of unnecessary console log in `useId` hook
joshua-rdrgz Feb 11, 2024
2214ced
fix `CreateOrganizationBtn` import in `NoOrganizations` component
joshua-rdrgz Feb 11, 2024
95fe5dc
Update "org already exists" text in `CreateOrganizationForm`
joshua-rdrgz Feb 11, 2024
c4e8a5d
Downgrade "react-hook-form" to 7.25.0
joshua-rdrgz Feb 12, 2024
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
4 changes: 4 additions & 0 deletions frontend/compositions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import PasswordAid from "./password-aid/password-aid"
import EditProfileInfo from "./profile-edit"
import ProfileInfo from "./profile-info"
import ProfileNav from "./profile-nav"
import ProfileNotifications from "./profile-notifications/profile-notifications"
import ProfileOrganizations from "./profile-organizations/profile-organizations"
import SavedResults from "./profile-saved-tables/saved-results"
import SavedSearches from "./profile-saved-tables/saved-searches"
import ProfileType from "./profile-type"
Expand All @@ -29,6 +31,8 @@ export {
PasswordAid,
ProfileInfo,
ProfileNav,
ProfileNotifications,
ProfileOrganizations,
ProfileType,
RegistrationResponse,
SavedResults,
Expand Down
26 changes: 11 additions & 15 deletions frontend/compositions/profile-nav/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import * as React from "react"
import { ProfileMenu } from "../../models/profile"
import { ProfileMenu, profileMenuItems } from "../../models/profile"
import styles from "./profile-nav.module.css"

interface ProfileNavProps {
currentItem: ProfileMenu
selectNav: Function
activePage: ProfileMenu
setActivePage: React.Dispatch<React.SetStateAction<ProfileMenu>>
}

const menuItems = [
{ item: ProfileMenu.USER_INFO, text: "User Information" },
{ item: ProfileMenu.PROFILE_TYPE, text: "Profile Type" },
{ item: ProfileMenu.SAVED_RESULTS, text: "Saved Results" },
{ item: ProfileMenu.SAVED_SEARCHES, text: "Saved Searches" }
]

export default function ProfileNav({ currentItem, selectNav }: ProfileNavProps) {
const clsName = (itm: string) => (itm === currentItem ? styles.selectedItem : styles.menuItem)
export default function ProfileNav({ activePage, setActivePage }: ProfileNavProps) {
const clsName = (item: string) => (item === activePage ? styles.selectedItem : styles.menuItem)

return (
<nav className={styles.leftMenu}>
<ul>
{menuItems.map((mnu) => (
<li key={mnu.item} onClick={() => selectNav(mnu.item)} className={clsName(mnu.item)}>
{mnu.text}
{profileMenuItems.map((menu) => (
<li
key={menu.item}
onClick={() => setActivePage(menu.item)}
className={clsName(menu.item)}>
{menu.text}
</li>
))}
</ul>
Expand Down
22 changes: 9 additions & 13 deletions frontend/compositions/profile-nav/profile-nav.module.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
.leftMenu {
display: flex;

flex-direction: row;
align-items: flex-start;
font-weight: bold;
text-align: left;

padding: var(--size20) var(--size32);
border: 1px solid var(--darkBlue);
box-sizing: border-box;
box-shadow: -2px 2px 4px 2px rgba(0, 0, 0, 0.25);
border-radius: var(--size10);
align-self: flex-start;
}

margin-left: var(--size10);
margin-right: var(--size24);
margin-top: var(--size20);
width: var(--size192);
.leftMenu ul {
margin: 0;
padding: 0;

line-height: 2.5;
height: var(--size200);
display: flex;
flex-direction: column;
gap: var(--size20);
}

.leftMenu li {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.notificationsContainer {
flex: 1;
}

.headerContainer {
display: flex;
justify-content: space-between;
align-items: center;
}

.headerText {
font-size: var(--size28);
font-weight: bold;
color: var(--darkBlue);
}

.headerCTA {
/* Get rid of default margins */
margin: 0;
font-size: var(--size16) !important;
}
100 changes: 100 additions & 0 deletions frontend/compositions/profile-notifications/profile-notifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { CellProps, Column } from "react-table"
import { CreateOrganizationBtn, DataTable } from "../../shared-components"
import styles from "./profile-notifications.module.css"
import ConfirmOrgDialog from "./sub-comps/confirm-org-dialog"

enum MemberRole {
ADMIN = "Administrator",
PUBLISHER = "Publisher",
MEMBER = "Member",
SUBSCRIBER = "Subscriber"
}

interface InterimInvitation {
organization: string
role: MemberRole
dateInvited: Date
status: string
}

export default function ProfileNotifications() {
const { notificationsContainer, headerContainer, headerText, headerCTA } = styles

// TODO: get user's invitations

return (
<section className={notificationsContainer}>
<div className={headerContainer}>
<h1 className={headerText}>Notifications</h1>
<CreateOrganizationBtn btnClassName={headerCTA} />
</div>
<DataTable tableName="Notifications" data={notifications} columns={notificationsColumns} />
</section>
)
}

const notifications: InterimInvitation[] = [
{
organization: "Pearson Hardman",
role: MemberRole.ADMIN,
dateInvited: new Date("8/8/2021"),
status: "Invitation"
},
{
organization: "Pearson Hardman Litt",
role: MemberRole.ADMIN,
dateInvited: new Date("7/30/2021"),
status: "Invitation"
},
{
organization: "Zane Specter Litt",
role: MemberRole.PUBLISHER,
dateInvited: new Date("6/15/2021"),
status: "Current Member"
},
{
organization: "Porter Hedges",
role: MemberRole.MEMBER,
dateInvited: new Date("5/2/2021"),
status: "Current Member"
}
]

const notificationsColumns: Column<InterimInvitation>[] = [
{
Header: "Organization",
accessor: "organization",
id: "organization"
},
{
Header: "Role",
accessor: "role",
id: "role"
},
{
Header: "Date Invited",
Cell: (props) => (
<div>
{new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "2-digit",
day: "2-digit"
}).format(props.cell.value)}
</div>
),
accessor: "dateInvited",
id: "dateInvited"
},
{
Header: "Status",
accessor: "status",
id: "status"
},
{
Header: "Action",
Cell: ({ row }: CellProps<InterimInvitation>) => {
const organizationName = row.original.organization
return <ConfirmOrgDialog organizationName={organizationName} />
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.actionBtn {
/* Define row height */
margin: var(--size4) 0;

width: min-content;
height: var(--size32);
}

.btnContainer {
display: flex;
flex-direction: row;
margin: 0 auto;
gap: var(--size16);
}

.btn {
/* RESET MARGINS from PrimaryButton */
margin: 0;
}

.confirmBtn {
font-weight: bold;
}

.notYetBtn {
background-color: var(--red);
font-weight: bold;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import classNames from "classnames"
import { PrimaryButton, Dialog as D } from "../../../shared-components"
import styles from "./confirm-org-dialog.module.css"
import { useState } from "react"

interface ConfirmOrgDialogProps {
organizationName: string
}

export default function ConfirmOrgDialog({ organizationName }: ConfirmOrgDialogProps) {
const [open, setOpen] = useState(false)
// TODO: determine if user is joining or leaving

const handleConfirm = () => {
// TODO: Join/Leave organization
console.log("Joined or Left Organization: ", organizationName)
setOpen(false)
}

const handleNotYet = () => {
setOpen(false)
}

return (
<D.Root open={open} onOpenChange={setOpen}>
<D.Trigger asChild>
<PrimaryButton className={styles.actionBtn}>Join</PrimaryButton>
</D.Trigger>
<D.Content>
<D.Header>
<D.Title>Are you sure you want to join {organizationName}?</D.Title>
</D.Header>
<D.Footer className={styles.btnContainer}>
<PrimaryButton
className={classNames(styles.btn, styles.confirmBtn)}
onClick={handleConfirm}>
Join
</PrimaryButton>
<PrimaryButton
className={classNames(styles.btn, styles.notYetBtn)}
onClick={handleNotYet}>
Not Yet
</PrimaryButton>
</D.Footer>
</D.Content>
</D.Root>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.headerText {
font-size: var(--size24);
font-weight: bold;
color: var(--darkBlue);
margin-bottom: var(--size16);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Logo, CreateOrganizationBtn } from "../../../shared-components"
import styles from "./no-organizations.module.css"

export default function NoOrganizations() {
const { headerText } = styles

return (
<>
<Logo />
<h1 className={headerText}>You&apos;re currently Not Part of Any Organizations</h1>
<CreateOrganizationBtn />
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.organizationContainer {
flex: 1;
text-align: center;
padding: 0 var(--size192);

display: flex;
flex-direction: column;
align-items: center;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useAuth } from "../../helpers"
import NoOrganizations from "./no-organizations/no-organizations"
import styles from "./profile-organizations.module.css"

export default function ProfileOrganizations() {
const { organizationContainer, headerText, organizationBtn } = styles
const { user } = useAuth()

// TODO: Find user's organizations (if any)
// API endpoint needed: Given a user, get their partners

// TODO: Separate UI for:
// 2. Existing Organizations

return (
<section className={organizationContainer}>
<NoOrganizations />
</section>
)
}
18 changes: 18 additions & 0 deletions frontend/helpers/hooks/useId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useEffect, useState } from "react"

let idCounter = 0

const useId = () => {
const [id] = useState(() => `generated-id-${idCounter++}`)

useEffect(() => {
// Reset the counter when the component unmounts
return () => {
idCounter = 0
}
}, [])

return id
}

export default useId
Loading
Loading