Skip to content

Commit e85fed9

Browse files
committed
move to dashboard folder
1 parent 3fbd9f6 commit e85fed9

File tree

11 files changed

+72
-97
lines changed

11 files changed

+72
-97
lines changed

apps/web/app/(org)/dashboard/_components/DashboardInner.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import Notifications from "@/app/dashboard/_components/Notifications";
3+
import Notifications from "@/app/(org)/dashboard/_components/Notifications";
44
import { UpgradeModal } from "@/components/UpgradeModal";
55
import { buildEnv } from "@cap/env";
66
import {
@@ -12,11 +12,7 @@ import {
1212
PopoverContent,
1313
PopoverTrigger,
1414
} from "@cap/ui";
15-
import {
16-
faBell,
17-
faMoon,
18-
faSun
19-
} from "@fortawesome/free-solid-svg-icons";
15+
import { faBell, faMoon, faSun } from "@fortawesome/free-solid-svg-icons";
2016
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2117
import { useClickAway } from "@uidotdev/usehooks";
2218
import clsx from "clsx";
@@ -26,7 +22,14 @@ import { signOut } from "next-auth/react";
2622
import Image from "next/image";
2723
import Link from "next/link";
2824
import { usePathname } from "next/navigation";
29-
import React, { cloneElement, memo, MutableRefObject, useMemo, useRef, useState } from "react";
25+
import React, {
26+
cloneElement,
27+
memo,
28+
MutableRefObject,
29+
useMemo,
30+
useRef,
31+
useState,
32+
} from "react";
3033
import { useDashboardContext, useTheme } from "../Contexts";
3134
import { MembersDialog } from "../spaces/[spaceId]/components/MembersDialog";
3235
import {
@@ -50,7 +53,8 @@ export default function DashboardInner({
5053
children: React.ReactNode;
5154
}) {
5255
const pathname = usePathname();
53-
const { activeOrganization, activeSpace, anyNewNotifications } = useDashboardContext();
56+
const { activeOrganization, activeSpace, anyNewNotifications } =
57+
useDashboardContext();
5458
const [membersDialogOpen, setMembersDialogOpen] = useState(false);
5559

5660
const titles: Record<string, string> = {
@@ -115,14 +119,16 @@ export default function DashboardInner({
115119
setToggleNotifications(!toggleNotifications);
116120
}}
117121
onKeyDown={(e) => {
118-
if (e.key === 'Enter' || e.key === ' ') {
122+
if (e.key === "Enter" || e.key === " ") {
119123
e.preventDefault();
120124
setToggleNotifications(!toggleNotifications);
121125
}
122126
}}
123127
tabIndex={0}
124128
role="button"
125-
aria-label={`Notifications${anyNewNotifications ? ' (new notifications available)' : ''}`}
129+
aria-label={`Notifications${
130+
anyNewNotifications ? " (new notifications available)" : ""
131+
}`}
126132
aria-expanded={toggleNotifications}
127133
className="hidden relative justify-center data-[state=open]:hover:bg-gray-5 items-center bg-gray-3
128134
rounded-full transition-colors cursor-pointer lg:flex
@@ -136,7 +142,8 @@ export default function DashboardInner({
136142
<div className="absolute inset-0 w-2 h-2 bg-red-400 rounded-full opacity-75 animate-ping" />
137143
<div className="relative w-2 h-2 bg-red-400 rounded-full" />
138144
</div>
139-
</div>)}
145+
</div>
146+
)}
140147
<FontAwesomeIcon className="text-gray-12 size-3.5" icon={faBell} />
141148
<AnimatePresence>
142149
{toggleNotifications && <Notifications ref={notificationsRef} />}

apps/web/app/dashboard/_components/Notifications/FilterTabs.tsx renamed to apps/web/app/(org)/dashboard/_components/Notifications/FilterTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import clsx from "clsx";
22
import { motion } from "framer-motion";
33
import { useRef, useEffect, useMemo } from "react";
44
import { NotificationType } from "@/lib/Notification";
5-
import { FilterType } from "../Filter";
5+
import { FilterType } from "./Filter";
66

77
type FilterTabsProps = {
88
activeFilter: FilterType;

apps/web/app/dashboard/_components/Notifications/NotificationItem.tsx renamed to apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Link from "next/link";
55
import moment from "moment";
66
import { NotificationType } from "@/lib/Notification";
77
import { Notification as APINotification } from "@cap/web-api-contract";
8-
import z from "zod";
98

109
type NotificationItemProps = {
1110
notification: APINotification;
@@ -17,7 +16,7 @@ const descriptionMap: Record<NotificationType, string> = {
1716
reply: `replied to your comment`,
1817
view: `viewed your video`,
1918
reaction: `reacted to your video`,
20-
mention: `mentioned you in a comment`,
19+
// mention: `mentioned you in a comment`,
2120
};
2221

2322
export const NotificationItem = ({
@@ -98,7 +97,8 @@ function getLink(notification: APINotification) {
9897
switch (notification.type) {
9998
case "comment":
10099
case "reply":
101-
// case "reaction":
100+
case "reaction":
101+
// case "mention":
102102
return `/s/${notification.videoId}/?comment=${notification.comment.id}`;
103103
default:
104104
return `/s/${notification.videoId}`;

apps/web/app/dashboard/_components/Notifications/SettingsDropdown.tsx renamed to apps/web/app/(org)/dashboard/_components/Notifications/SettingsDropdown.tsx

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import {
66
faComment,
77
faEye,
88
faReply,
9-
faThumbsUp, IconDefinition
9+
faThumbsUp,
10+
IconDefinition,
1011
} from "@fortawesome/free-solid-svg-icons";
1112
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
12-
import { Menu, Transition } from '@headlessui/react';
13+
import { Menu, Transition } from "@headlessui/react";
1314
import clsx from "clsx";
14-
import { Fragment, useState } from 'react';
15+
import { Fragment, useState } from "react";
1516
import { updatePreferences } from "@/actions/notifications/update-preferences";
1617
import { toast } from "sonner";
17-
import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";
18+
import { useDashboardContext } from "../../Contexts";
1819

1920
type NotificationOption = {
2021
icon: IconDefinition;
@@ -26,31 +27,34 @@ const notificationOptions: NotificationOption[] = [
2627
{ icon: faComment, label: "Comments", value: "pauseComments" },
2728
{ icon: faReply, label: "Replies", value: "pauseReplies" },
2829
{ icon: faEye, label: "Views", value: "pauseViews" },
29-
{ icon: faThumbsUp, label: "Reactions", value: "pauseReactions" }
30-
]
30+
{ icon: faThumbsUp, label: "Reactions", value: "pauseReactions" },
31+
];
3132

3233
export const SettingsDropdown = () => {
3334
const [showPauseSubmenu, setShowPauseSubmenu] = useState(false);
3435
const { userPreferences } = useDashboardContext();
3536

36-
3737
const updateNotificationPreferences = async (option: NotificationOption) => {
3838
try {
3939
const currentPrefs = userPreferences?.notifications ?? {
4040
pauseComments: false,
4141
pauseReplies: false,
4242
pauseViews: false,
43-
pauseReactions: false
43+
pauseReactions: false,
4444
};
4545

4646
await updatePreferences({
4747
notifications: {
4848
...currentPrefs,
49-
[option.value]: !(currentPrefs[option.value] ?? false)
50-
}
49+
[option.value]: !(currentPrefs[option.value] ?? false),
50+
},
5151
});
5252

53-
toast.success(`Notifications from ${option.label} have been ${!(currentPrefs[option.value] ?? false) ? "paused" : "unpaused"}`);
53+
toast.success(
54+
`Notifications from ${option.label} have been ${
55+
!(currentPrefs[option.value] ?? false) ? "paused" : "unpaused"
56+
}`
57+
);
5458
} catch (error) {
5559
console.error("Failed to update preferences:", error);
5660
toast.error("Failed to update notification preferences");
@@ -60,10 +64,7 @@ export const SettingsDropdown = () => {
6064
return (
6165
<Menu as="div" className="relative">
6266
<Menu.Button className="flex gap-1 items-center transition-opacity duration-200 cursor-pointer hover:opacity-70">
63-
<FontAwesomeIcon
64-
icon={faCog}
65-
className="text-gray-10 size-3"
66-
/>
67+
<FontAwesomeIcon icon={faCog} className="text-gray-10 size-3" />
6768
<p className="text-[13px] text-gray-10">Settings</p>
6869
</Menu.Button>
6970

@@ -83,16 +84,24 @@ export const SettingsDropdown = () => {
8384
<div
8485
className={clsx(
8586
"flex flex-1 items-center group justify-between px-2 py-1 min-w-fit text-[13px] text-gray-11 rounded-lg cursor-pointer outline-none",
86-
active || showPauseSubmenu ? 'bg-gray-3' : ''
87+
active || showPauseSubmenu ? "bg-gray-3" : ""
8788
)}
8889
onMouseEnter={() => setShowPauseSubmenu(true)}
8990
onMouseLeave={() => setShowPauseSubmenu(false)}
9091
>
9192
<div className="flex gap-2 items-center">
92-
<FontAwesomeIcon icon={faBellSlash} className="text-gray-10 text-[13px] size-3.5 transition-colors group-hover:text-gray-12" />
93-
<p className="text-[13px] transition-colors group-hover:text-gray-12">Pause notifications</p>
93+
<FontAwesomeIcon
94+
icon={faBellSlash}
95+
className="text-gray-10 text-[13px] size-3.5 transition-colors group-hover:text-gray-12"
96+
/>
97+
<p className="text-[13px] transition-colors group-hover:text-gray-12">
98+
Pause notifications
99+
</p>
94100
</div>
95-
<FontAwesomeIcon icon={faArrowUp} className="text-gray-10 size-2.5 rotate-90 transition-colors group-hover:text-gray-12" />
101+
<FontAwesomeIcon
102+
icon={faArrowUp}
103+
className="text-gray-10 size-2.5 rotate-90 transition-colors group-hover:text-gray-12"
104+
/>
96105
</div>
97106
)}
98107
</Menu.Item>
@@ -108,11 +117,18 @@ export const SettingsDropdown = () => {
108117
<div
109118
key={index}
110119
className="flex w-full items-center justify-between gap-2 px-2 py-1 text-[13px] text-gray-11 rounded-lg group hover:bg-gray-3 cursor-pointer outline-none"
111-
onClick={async () => await updateNotificationPreferences(option)}
120+
onClick={async () =>
121+
await updateNotificationPreferences(option)
122+
}
112123
>
113124
<div className="flex gap-1.5 items-center">
114-
<FontAwesomeIcon icon={option.icon} className="text-gray-10 size-3.5 transition-colors group-hover:text-gray-12" />
115-
<p className="text-[13px] transition-colors group-hover:text-gray-12">{option.label}</p>
125+
<FontAwesomeIcon
126+
icon={option.icon}
127+
className="text-gray-10 size-3.5 transition-colors group-hover:text-gray-12"
128+
/>
129+
<p className="text-[13px] transition-colors group-hover:text-gray-12">
130+
{option.label}
131+
</p>
116132
</div>
117133

118134
{userPreferences?.notifications[option.value] && (
@@ -133,4 +149,3 @@ export const SettingsDropdown = () => {
133149
};
134150

135151
export default SettingsDropdown;
136-

apps/web/app/dashboard/_components/Notifications/index.tsx renamed to apps/web/app/(org)/dashboard/_components/Notifications/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import clsx from "clsx";
44
import { motion, MotionProps } from "framer-motion";
55
import { forwardRef, useEffect, useRef, useMemo, useState } from "react";
6-
import { FilterTabs, FilterType, FilterLabels } from "./FilterTabs";
6+
import { FilterTabs } from "./FilterTabs";
77
import { NotificationFooter } from "./NotificationFooter";
88
import { NotificationHeader } from "./NotificationHeader";
99
import { NotificationItem } from "./NotificationItem";
@@ -14,7 +14,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1414
import { faBellSlash } from "@fortawesome/free-solid-svg-icons";
1515
import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";
1616
import { useApiClient } from "@/utils/web-api";
17-
import { matchNotificationFilter } from "../Filter";
17+
import { FilterType, matchNotificationFilter } from "./Filter";
1818

1919
type NotificationsProps = MotionProps & React.HTMLAttributes<HTMLDivElement>;
2020

apps/web/app/dashboard/_components/Notifications/mockData.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)