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

feat(dasboard): batch payments alpha tag #3830

Merged
merged 2 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions apps/dashboard/app/url.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
interface UrlInfo {
title: string
protected: boolean
badge?: string
}

export const URLS: Record<string, UrlInfo> = {
"/": { title: "Home", protected: true },
"/transactions": { title: "Transactions", protected: true },
"/security": { title: "Security", protected: true },
"/security/email/add": { title: "Add Email", protected: true },
"/security/email/verify": { title: "Verify Email", protected: true },
"/api-keys": { title: "API Keys", protected: true },
"/callback": { title: "Callback", protected: true },
"/security/2fa/add": { title: "Add 2FA to Account", protected: true },
"/batch-payments": { title: "Batch Payments", protected: true },
"/": { title: "Home" },
"/transactions": { title: "Transactions" },
"/security": { title: "Security" },
"/security/email/add": { title: "Add Email" },
"/security/email/verify": { title: "Verify Email" },
"/api-keys": { title: "API Keys" },
"/callback": { title: "Callback" },
"/security/2fa/add": { title: "Add 2FA to Account" },
"/batch-payments": { title: "Batch Payments", badge: "Alpha" },
}
29 changes: 22 additions & 7 deletions apps/dashboard/components/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,45 @@ import { usePathname } from "next/navigation"

import { URLS } from "@/app/url"

export function getTitle(path: string): string {
export function getTitle(path: string): {
title: string
badge?: string
} {
const urlInfo = URLS[path]
if (urlInfo) {
return urlInfo.title
return urlInfo
}
return {
title: "Path not found",
}
return "Path not found"
}

const Heading = () => {
const pathName = usePathname()
const title = getTitle(pathName)
const pageInfo = getTitle(pathName)

return (
<Box
sx={{
display: "flex",
my: 2,
gap: 1,
flexDirection: { xs: "column", sm: "row" },
alignItems: { xs: "start", sm: "center" },
alignItems: { sm: "center" },
flexWrap: "wrap",
justifyContent: "space-between",
}}
>
<Typography level="h2">{title}</Typography>
<Typography level="h2">{pageInfo.title}</Typography>
<Typography
sx={{
color: "grey",
fontSize: "1em",
marginTop: "0.8em",
}}
level="h4"
>
{pageInfo.badge}
</Typography>
</Box>
)
}
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/components/side-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const Sidebar: React.FC = () => {
label="Batch Payments"
isCurrentPath={isCurrentPath}
dataTestid="sidebar-batch-payments-link"
badge="Alpha"
/>
</List>
</Box>
Expand Down
23 changes: 21 additions & 2 deletions apps/dashboard/components/side-bar/navigation-links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react"
import Link from "next/link"
import ListItem from "@mui/joy/ListItem"
import ListItemButton from "@mui/joy/ListItemButton"
import { Typography } from "@mui/joy"
import { Badge, Typography } from "@mui/joy"

import { closeSidebar } from "./../utils"

Expand All @@ -12,6 +12,7 @@ interface NavigationLinkProps {
label: string
isCurrentPath: (href: string) => boolean
dataTestid: string
badge?: string
}

export const NavigationLink: React.FC<NavigationLinkProps> = ({
Expand All @@ -20,6 +21,7 @@ export const NavigationLink: React.FC<NavigationLinkProps> = ({
label,
isCurrentPath,
dataTestid,
badge,
}) => (
<Link data-testid={dataTestid} href={href}>
<ListItem>
Expand All @@ -44,7 +46,24 @@ export const NavigationLink: React.FC<NavigationLinkProps> = ({
}}
>
{icon}
<Typography level="title-md">{label}</Typography>
<Typography level="title-md">
{badge ? (
<Badge
sx={{
".MuiBadge-badge": {
backgroundColor: "var(--primaryColor)",
borderColor: "transparent",
transform: "translate(46.5px, -9px)",
},
}}
badgeContent={badge}
>
{label}
</Badge>
) : (
label
)}
</Typography>
</ListItemButton>
</ListItem>
</Link>
Expand Down
Loading