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: zap page #1566

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

dennyscode
Copy link
Contributor

Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jumper-exchange ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 0:05am

Copy link

github-actions bot commented Dec 3, 2024

Playwright test results

passed  16 passed
skipped  3 skipped

Details

stats  19 tests across 3 suites
duration  3 minutes, 19 seconds
commit  3b63532

Skipped tests

chromium › e2e.spec.ts › Jumper full e2e flow › Should be able to navigate to profile and open first Mission
chromium › e2e.spec.ts › Jumper full e2e flow › Should be able to navigate to Supefest
chromium › e2e.spec.ts › Jumper full e2e flow › Should be able to open quests mission page and switch background color

Copy link

github-actions bot commented Dec 4, 2024

Test results (4/4)

passed  5 passed

Details

stats  5 tests across 2 suites
duration  1 minute, 10 seconds
commit  33fee13

Copy link

github-actions bot commented Dec 4, 2024

Test results (3/4)

failed  2 failed
passed  3 passed

Details

stats  5 tests across 2 suites
duration  8 minutes, 43 seconds
commit  33fee13

Failed tests

chromium › swapActions.spec.ts › On chain swaps › Check ETH to USDTUSDT swap pair on ETH chain
chromium › swapActions.spec.ts › On chain swaps › Check USDT to DAI swap pair on ETH chain

Copy link

github-actions bot commented Dec 4, 2024

Test results (1/4)

passed  5 passed
skipped  1 skipped

Details

stats  6 tests across 2 suites
duration  1 minute, 6 seconds
commit  33fee13

Skipped tests

chromium › e2e.spec.ts › Jumper full e2e flow › Should be able to navigate to profile and open first Mission

Copy link

github-actions bot commented Dec 4, 2024

Test results (2/4)

passed  4 passed
skipped  1 skipped

Details

stats  5 tests across 1 suite
duration  29.8 seconds
commit  33fee13

Skipped tests

chromium › e2e.spec.ts › Jumper full e2e flow › Should be able to open quests mission page and switch background color

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@oktapodia @tcheee This is a copy of the "Widget.tsx" component -> The only change is that we do not want the box-shadow within the widget-theme. First, I started out to create a partner theme to be used for the "zap" layout but ran into the problem that partner-themes do not support multiple themeModes (light + dark).

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be much better to refactorize the Widget.tsx instead of fully duplicating it :(

Copy link
Contributor Author

@dennyscode dennyscode Dec 5, 2024

Choose a reason for hiding this comment

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

Good idea running that extra mile instead of taking the shortcut I did!
I added a useWidgetConfig-hook -> We had such in the past as well, it now also takes an optional "customWidgetTheme" prop and is merged with the "source" widgetTheme using deepmerge by mui -> Wdyt?

title: 'Jumper | Berachain',
description: 'Dive into the Berachain universe!',
siteName: siteName,
url: `${getSiteUrl()}/berachain/explore/${params.slug}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure about this url? it seems to be /zap/[slug]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tcheee Can we align on the meta information?

Copy link
Contributor

Choose a reason for hiding this comment

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

should be good by now

Copy link
Contributor

@oktapodia oktapodia left a comment

Choose a reason for hiding this comment

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

Couple of comments

};
} catch (err) {
return {
title: `Jumper Learn | ${sliceStrToXChar(params.slug.replaceAll('-', ' '), 45)}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this is a learn page

Copy link
Contributor Author

@dennyscode dennyscode Dec 5, 2024

Choose a reason for hiding this comment

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

Indeed! Thanks

export default async function Page({ params }: { params: { slug: string } }) {
const { data } = await getQuestBySlug(params.slug);
const questData = (data.data[0] as ExtendedQuest) || undefined;

Copy link
Contributor

Choose a reason for hiding this comment

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

Do not forget to return notFound() if it does not exists

Copy link
Contributor Author

Choose a reason for hiding this comment

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


export default async function Page({ params }: { params: { slug: string } }) {
const { data } = await getQuestBySlug(params.slug);
const questData = (data.data[0] as ExtendedQuest) || undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to type is within getQuestBySlug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, please have another look.

marginTop: `calc( ${DEFAULT_WIDGET_TOP_OFFSET_VAR} - ${HeaderHeight.MD}px - ${DEFAULT_WIDGET_TOP_HOVER_OFFSET}px )`,

// positioning of widget on mobile-screens from 700px height
[`@media screen and (min-height: 700px)`]: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to use breakpoints value instead to avoid regresions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is magic voodoo happening. Please note, it´s applying styles to the min-height which we usually don´t have as default breakpoints. It´s needed to position the widget accordingly while the welcomeScreen is open.

src/components/Zap/BackButton/BackButton.tsx Outdated Show resolved Hide resolved
src/components/Zap/ZapAction/ZapAction.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be much better to refactorize the Widget.tsx instead of fully duplicating it :(

Copy link
Contributor

@oktapodia oktapodia left a comment

Choose a reason for hiding this comment

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

Couple of comments


export default async function Page({ params }: { params: { slug: string } }) {
const { data, url } = await getQuestBySlug(params.slug);

if (!data?.data?.[0]) {
if (!data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might not be enough, data can be returned and data.data -> [] but will still not go through

Copy link
Contributor Author

@dennyscode dennyscode Dec 10, 2024

Choose a reason for hiding this comment

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

While adding the proper types on our fetch function getQuestBySlug I have also tweaked the return statement to the following (see screen). If there is no returned data, it should actually be undefined -->

image

@@ -44,10 +44,8 @@ import { notFound } from 'next/navigation';

export default async function Page({ params }: { params: { slug: string } }) {
const { data, url } = await getQuestBySlug(params.slug);

if (!data?.data?.[0]) {
if (!data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have updated this everywhere where getQuestBySlug is being called. Check my answer above.

const questData = data;

if (questData) {
const protocolDetails = zapMarkets.filter(
Copy link
Contributor

Choose a reason for hiding this comment

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

Dangerous, if find does not find any protocolDetails, it will be null, [0] will crash the app

Copy link
Contributor Author

@dennyscode dennyscode Dec 10, 2024

Choose a reason for hiding this comment

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

Are you sure? Please take a look on my updated getQuestBySlug function. With that, we should not run into that issue, but please let´s double-check.

@@ -18,5 +33,12 @@ export async function getQuestBySlug(slug: string) {

const data = await res.json(); // Extract data from the response

return { data, url: apiBaseUrl }; // Return a plain object
if (!data || !Array.isArray(data.data) || data.data.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This part seems weird and does not seem to achieve anything, let's have a talk about it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh, yes this is the part I was so confident about - that this could catch any errors --> I have added another check and hopefully catch all possible red-flags.

  if (
    !data || // Check if data is undefined or null
    !data.data || // Check if data.data is undefined or null
    !Array.isArray(data.data) || // Check if data.data is not an array
    data.data.length === 0 || // Check if data.data is an empty array
    data.data[0] === 0 // Check if the first element is exactly zero (assuming this is an invalid value)
  ) {
    return { data: undefined, url: apiBaseUrl };
  }

Not sure if that´s the proper way of handling errors but it did fine on all my test cases:

data = null
data = undefined
data = []
data = [0]
data = { data : undefined }
data = { data: 0 }
data = { data: [] }
data = { data: [0] }
data = { data: [1] }

src/components/Quests/QuestPage/BackButton/BackButton.tsx Outdated Show resolved Hide resolved
src/components/Zap/BackButton/BackButton.tsx Outdated Show resolved Hide resolved
src/components/Zap/ZapAction/ZapAction.tsx Show resolved Hide resolved
src/components/Zap/ZapAction/Zapwidget.tsx Outdated Show resolved Hide resolved
...publicRPCList,
};
} catch (e) {
if (process.env.DEV) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Dangerous there, DEV is not a standard env variable, error will be obfuscated all time and not throwing anything (making it harder to debug), just remove this if

Copy link
Contributor Author

@dennyscode dennyscode Dec 16, 2024

Choose a reason for hiding this comment

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

@oktapodia Can you confirm and take another look if that is what you had in mind?

image

src/components/Zap/BackButton/BackButton.tsx Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants