Skip to content

Commit

Permalink
refactor: FeedType
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jun 25, 2024
1 parent 7e87b3e commit 40f595e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
77 changes: 40 additions & 37 deletions apps/web/src/components/Notification/FeedType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,57 @@ import { TabButton } from '@hey/ui';
import { NotificationTabType } from 'src/enums';

interface FeedTypeProps {
feedType: string;
feedType: NotificationTabType;
}

const FeedType: FC<FeedTypeProps> = ({ feedType }) => {
const switchTab = (type: string) => {
const switchTab = (type: NotificationTabType) => {
Leafwatch.track(NOTIFICATION.SWITCH_NOTIFICATION_TAB, {
notification_type: type.toLowerCase()
});
};

const tabs = [
{
icon: <BellIcon className="size-4" />,
name: 'All notifications',
type: NotificationTabType.All
},
{
icon: <AtSymbolIcon className="size-4" />,
name: 'Mentions',
type: NotificationTabType.Mentions
},
{
icon: <ChatBubbleLeftIcon className="size-4" />,
name: 'Comments',
type: NotificationTabType.Comments
},
{
icon: <HeartIcon className="size-4" />,
name: 'Likes',
type: NotificationTabType.Likes
},
{
icon: <RectangleStackIcon className="size-4" />,
name: 'Collects',
type: NotificationTabType.Collects
}
];

return (
<div className="flex items-center justify-between">
<div className="mt-3 flex gap-3 overflow-x-auto px-5 pb-2 sm:mt-0 sm:px-0 md:pb-0">
<TabButton
active={feedType === NotificationTabType.All}
icon={<BellIcon className="size-4" />}
name="All notifications"
onClick={() => switchTab(NotificationTabType.All)}
type={NotificationTabType.All.toLowerCase()}
/>
<TabButton
active={feedType === NotificationTabType.Mentions}
icon={<AtSymbolIcon className="size-4" />}
name="Mentions"
onClick={() => switchTab(NotificationTabType.Mentions)}
type={NotificationTabType.Mentions.toLowerCase()}
/>
<TabButton
active={feedType === NotificationTabType.Comments}
icon={<ChatBubbleLeftIcon className="size-4" />}
name="Comments"
onClick={() => switchTab(NotificationTabType.Comments)}
type={NotificationTabType.Comments.toLowerCase()}
/>
<TabButton
active={feedType === NotificationTabType.Likes}
icon={<HeartIcon className="size-4" />}
name="Likes"
onClick={() => switchTab(NotificationTabType.Likes)}
type={NotificationTabType.Likes.toLowerCase()}
/>
<TabButton
active={feedType === NotificationTabType.Collects}
icon={<RectangleStackIcon className="size-4" />}
name="Collects"
onClick={() => switchTab(NotificationTabType.Collects)}
type={NotificationTabType.Collects.toLowerCase()}
/>
{tabs.map((tab) => (
<TabButton
active={feedType === tab.type}
icon={tab.icon}
key={tab.type}
name={tab.name}
onClick={() => switchTab(tab.type)}
type={tab.type.toLowerCase()}
/>
))}
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/Notification/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { NextPage } from 'next';
import type { NotificationTabType } from 'src/enums';

import MetaTags from '@components/Common/MetaTags';
import NotLoggedIn from '@components/Shared/NotLoggedIn';
Expand Down Expand Up @@ -47,7 +48,7 @@ const Notification: NextPage = () => {
<MetaTags title={`Notifications • ${APP_NAME}`} />
<div className="w-full max-w-4xl space-y-3">
<div className="flex flex-wrap justify-between gap-3 pb-2">
<FeedType feedType={feedType} />
<FeedType feedType={feedType as NotificationTabType} />
<Settings />
</div>
<List feedType={feedType} />
Expand Down

1 comment on commit 40f595e

@vercel
Copy link

@vercel vercel bot commented on 40f595e Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-git-main-heyxyz.vercel.app
web-heyxyz.vercel.app
hey.xyz
heyxyz.vercel.app

Please sign in to comment.