Skip to content

Commit

Permalink
Merge pull request #2 from aufacicenta/hellheadz
Browse files Browse the repository at this point in the history
feat: batch 44 - 66
  • Loading branch information
netpoe authored Sep 2, 2024
2 parents 02c512a + 86c5d50 commit 2f81ee4
Show file tree
Hide file tree
Showing 34 changed files with 1,277 additions and 93 deletions.
5 changes: 5 additions & 0 deletions app/src/context/analytics/AnalyticsContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createContext } from "react";

import { AnalyticsContextType } from "./AnalyticsContext.types";

export const AnalyticsContext = createContext<AnalyticsContextType | undefined>(undefined);
14 changes: 14 additions & 0 deletions app/src/context/analytics/AnalyticsContext.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ReactNode } from "react";

export type AnalyticsContextControllerProps = {
children: ReactNode;
};

export type AnalyticsEvent = {
name: string;
meta?: Record<string, string | number | undefined>;
};

export type AnalyticsContextType = {
onClick: (event: AnalyticsEvent) => void;
};
26 changes: 26 additions & 0 deletions app/src/context/analytics/AnalyticsContextController.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import React from "react";

import { AnalyticsContext } from "./AnalyticsContext";
import { AnalyticsContextControllerProps, AnalyticsContextType, AnalyticsEvent } from "./AnalyticsContext.types";

const onClick = (event: AnalyticsEvent) => {
(window as any)
.pirsch(event.name, {
meta: event.meta,
})
.then(() => {
console.log(`AnalyticsContextController.onClick: ${event.name}, ${JSON.stringify(event.meta)}`);
})
.catch((error: Error) => {
console.error(error);
});
};

export const AnalyticsContextController = ({ children }: AnalyticsContextControllerProps) => {
const props: AnalyticsContextType = {
onClick,
};

return <AnalyticsContext.Provider value={props}>{children}</AnalyticsContext.Provider>;
};
13 changes: 13 additions & 0 deletions app/src/context/analytics/useAnalyticsContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useContext } from "react";

import { AnalyticsContext } from "./AnalyticsContext";

export const useAnalyticsContext = () => {
const context = useContext(AnalyticsContext);

if (context === undefined) {
throw new Error("useAnalyticsContext must be used within a AnalyticsContext");
}

return context;
};
6 changes: 6 additions & 0 deletions app/src/hooks/useRoutes/useRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export const routes = {
x2y2: () => `https://x2y2.io/collection/larskristo-hellheadz/items`,
looksrare: () => `https://looksrare.org/collections/0x853bdaa30Cfd5A2Ec1E1d75935eBca7A0E52626D`,
},
socials: {
discord: `https://discord.gg/y3GWNkRh`,
},
oauth: {
discord: {
lkhh: () => `${origin}/oauth/discord/lkhh`,
Expand All @@ -20,6 +23,9 @@ export const routes = {
index: () => `/artists`,
larskristo: () => `/artists/larskristo`,
},
events: {
index: () => `/events`,
},
api: {
discord: {
verifyOwnership: () => `/api/discord/verify-ownership`,
Expand Down
32 changes: 24 additions & 8 deletions app/src/layouts/home-layout/HomeLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EvmWalletSelectorContextController } from "context/evm/wallet-selector/
import { Footer } from "ui/footer/Footer";
import { AuthorizationContextController } from "context/authorization/AuthorizationContextController";
import { DiscordContextController } from "context/discord/DiscordContextController";
import { AnalyticsContextController } from "context/analytics/AnalyticsContextController";

import { ChatLayoutProps } from "./HomeLayout.types";
import styles from "./HomeLayout.module.scss";
Expand All @@ -21,7 +22,20 @@ export const HomeLayout: React.FC<ChatLayoutProps> = ({ children }) => {
return (
<>
{process.env.NEXT_PUBLIC_VERCEL_ENV === "production" && (
<Script defer src="https://api.pirsch.io/pa.js" id="pianjs" data-code="X8onK5mQgqhkgQzuKWUBs08SnTqpig5x" />
<Script
defer
src="https://api.pirsch.io/pa.js"
id="pianjs"
data-code={process.env.NEXT_PUBLIC_PIRSCH_ANALYTICS_PID}
/>
)}
{process.env.NEXT_PUBLIC_VERCEL_ENV === "development" && (
<Script
defer
src="https://api.pirsch.io/pa.js"
id="pianjs"
data-code={process.env.NEXT_PUBLIC_PIRSCH_ANALYTICS_PID}
/>
)}
<Head>
<meta property="og:locale" content={locale} />
Expand All @@ -31,15 +45,17 @@ export const HomeLayout: React.FC<ChatLayoutProps> = ({ children }) => {
<ToastContextController>
<AuthorizationContextController>
<DiscordContextController>
<div id="modal-root" />
<div id="dropdown-portal" />
<div className={clsx(styles["home-layout"])}>
<Navbar />
<AnalyticsContextController>
<div id="modal-root" />
<div id="dropdown-portal" />
<div className={clsx(styles["home-layout"])}>
<Navbar />

<MainPanel>{children}</MainPanel>
<MainPanel>{children}</MainPanel>

<Footer />
</div>
<Footer />
</div>
</AnalyticsContextController>
</DiscordContextController>
</AuthorizationContextController>
</ToastContextController>
Expand Down
38 changes: 38 additions & 0 deletions app/src/pages/api/discord/create-forum-channel-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NextApiRequest, NextApiResponse } from "next";

import logger from "providers/logger";
import discord from "providers/discord";
import metadataBatch0_21 from "providers/svpervnder/hellheadz/metadata-batch-0-21.json";

export default async function Fn(_request: NextApiRequest, response: NextApiResponse) {
try {
logger.info(`api.discord.create-forum-channel-message`);

const discordClient = new discord.DiscordBotClient();

// const getChannel = await discordClient.getChannel({
// channelId: "1242289603906502686",
// });

// logger.info(`api.discord.create-forum-channel-message: getChannel: ${getChannel}`);

metadataBatch0_21.map(async (token) => {
const createForumThread = await discordClient.createForumThread({
channelId: "1242289603906502686",
name: `${token.name}`,
content: `Decide on the future of ${token.name}`,
applied_tags: ["1242290625106415646"],
});

logger.info(`api.discord.create-forum-channel-message: createForumThread: ${JSON.stringify(createForumThread)}`);
});

response.json({ success: true });
} catch (error) {
logger.error(error);

response.status(500).json({
error: (error as Error).message,
});
}
}
36 changes: 36 additions & 0 deletions app/src/pages/events/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { GetServerSidePropsContext, NextPage } from "next";
import { i18n, useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import Head from "next/head";

import { HomeLayout } from "layouts/home-layout/HomeLayout";
import { Events } from "ui/svpervnder/events/Events";

const Index: NextPage = () => {
const { t } = useTranslation("head");

return (
<HomeLayout>
<Head>
<title>{t("head.og.title")}</title>
<meta name="description" content={t("head.og.description")} />
<meta property="og:title" content={t("head.og.title")} />
<meta property="og:description" content={t("head.og.description")} />
</Head>

<Events />
</HomeLayout>
);
};

export const getServerSideProps = async ({ locale }: GetServerSidePropsContext) => {
await i18n?.reloadResources();

return {
props: {
...(await serverSideTranslations(locale!, ["common", "head", "chat", "prompt-wars"])),
},
};
};

export default Index;
21 changes: 21 additions & 0 deletions app/src/providers/analytics/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const EventTracking = {
click: {
events: {
discord_button: `click.events.discord_button`,
},
navbar: {
wallet_selector: `click.navbar.wallet_selector`,
},
footer: {
navigation: `click.footer.navigation`,
socials: `click.footer.socials`,
},
homepage: {
collection_item: `click.homepage.collection_item`,
collection_discord_card_button: `click.homepage.collection_discord_card_button`,
faqs_discord_button: `click.homepage.faqs_discord_button`,
faqs_accordion_trigger: `click.homepage.faqs_accordion_trigger`,
marketplaces_button: `click.homepage.marketplaces_button`,
},
},
};
5 changes: 5 additions & 0 deletions app/src/providers/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { EventTracking } from "./events";

export default {
EventTracking,
};
Loading

0 comments on commit 2f81ee4

Please sign in to comment.