Skip to content

Commit

Permalink
refactor: normalize base path gathering (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruilopesm authored Nov 6, 2023
1 parent b866b15 commit a8c7feb
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 31 deletions.
14 changes: 7 additions & 7 deletions components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ type LayoutProps = {
children: ReactNode;
};

export default function Layout({
title,
description,
basePath = "attendee",
children,
}: LayoutProps) {
export default function Layout({ title, description, children }: LayoutProps) {
const { user, logout } = useAuth();
const [isNavbarOpen, setIsNavbarOpen] = useState(false);
const router = useRouter();

const currentHref = router.asPath;
const links = roleNavigations[user.type];
// FIXME: normalize user type between moonstone and safira
const links =
user.type === "company"
? roleNavigations["sponsor"]
: roleNavigations[user.type];
const basePath = user.type === "company" ? "sponsor" : user.type;

const openNavbar = () => {
setIsNavbarOpen(true);
Expand Down
2 changes: 1 addition & 1 deletion layout/Manager/Badges/Badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Badges() {
};

return (
<Layout title="Badges" description="Award a badge" basePath="manager">
<Layout title="Badges" description="Award a badge">
{showScanner ? (
<div className="mt-5">
<QRScanner
Expand Down
6 changes: 1 addition & 5 deletions layout/Manager/Identifier/Identifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ function Identifier() {
};

return (
<Layout
title="Identifier"
description="Identify an attendee"
basePath="manager"
>
<Layout title="Identifier" description="Identify an attendee">
<div className="mt-5">
<QRScanner
handleCode={handleUUID}
Expand Down
6 changes: 1 addition & 5 deletions layout/Manager/Prize/Prize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ function Prize() {
};

return (
<Layout
title="Prizes"
description="Mark a prize as redeemed"
basePath="manager"
>
<Layout title="Prizes" description="Mark a prize as redeemed">
<div className="my-5">
<button
className={`font-iregular bg-${
Expand Down
6 changes: 1 addition & 5 deletions layout/Manager/Prizes/Prizes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ function Prizes() {
};

return (
<Layout
title="Prizes"
description="Mark a prize as redeemed"
basePath="manager"
>
<Layout title="Prizes" description="Mark a prize as redeemed">
<div className="mt-5">
<QRScanner
handleCode={handleUUID}
Expand Down
1 change: 0 additions & 1 deletion layout/Sponsor/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const SponsorDashboard: React.FC = () => {
<Layout
title="Dashboard"
description="Neste local, pode dar badges ao participantes que se encontram no seu stand"
basePath="sponsor"
>
<div className="mt-10 grid grid-cols-1 lg:grid-cols-2">
<div className="mr-3 w-full">
Expand Down
1 change: 0 additions & 1 deletion layout/Sponsor/Scanner/Scanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const SponsorBadges: React.FC = () => {
<Layout
title="Scanner"
description="Recompensa os teus visitantes com o badge"
basePath="sponsor"
>
<div className="mt-5">
<QRScanner
Expand Down
6 changes: 1 addition & 5 deletions layout/Sponsor/Spotlight/Spotlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import Layout from "@components/Layout";

const Spotlight: React.FC = () => {
return (
<Layout
title="Spotlight"
description="Coloque a sua empresa em destaque"
basePath="sponsor"
>
<Layout title="Spotlight" description="Coloque a sua empresa em destaque">
<div>
<div className="mt-8 md:mt-16">
<h1 className="text-iextrabold font-ibold text-4xl text-white sm:text-5xl">
Expand Down
1 change: 0 additions & 1 deletion layout/Sponsor/Visitors/Visitors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const SponsorVisitors: React.FC = () => {
<Layout
title="Visitantes"
description="Veja quem está a visitar a sua empresa e já recebeu o seu badge"
basePath="sponsor"
>
<div className="mt-5 h-screen text-white">
{visitors.filter((v) => v.cv != null).length > 0 && (
Expand Down

0 comments on commit a8c7feb

Please sign in to comment.