Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add-deduct-amount
Browse files Browse the repository at this point in the history
  • Loading branch information
oktapodia authored Sep 9, 2024
2 parents 74bd5c0 + e9813c4 commit c8aa918
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 34 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,3 @@ Register on Crowdin and you can start translating the project into your preferre
Your contributions will help make our project accessible to a wider audience around the world.

Thank you for your support!

## Code info

### NextThemeProvider

provider for the theme context, it is used to provide the theme to the whole app, must be into the layout.tsx or page.tsx.

### ThemeProviderV2

provider for the MUI theme context, mainly setting up the MUI provider, very linked to the next-theme provider
1 change: 1 addition & 0 deletions src/app/[lng]/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default async function MainLayout({

const defaultTheme = 'default';

// provider for the theme context, it is used to provide the theme to the whole app, must be into the layout.tsx or page.tsx.
return (
<NextThemeProvider
themes={[
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lng]/quests/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function PartnerThemeLayout({
enableSystem
enableColorScheme
>
<ThemeProviderV2>
<ThemeProviderV2 themes={[]}>
<Layout>{children}</Layout>
</ThemeProviderV2>
</NextThemeProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/app/[lng]/scan/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function PartnerThemeLayout({
enableSystem
enableColorScheme
>
<ThemeProviderV2>
<ThemeProviderV2 themes={[]}>
<Layout>{children}</Layout>
</ThemeProviderV2>
</NextThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const InstructionsAccordionItem = ({
<InstructionsAccordionItemContainer
sx={{
typograpy: isSuperfest ? sora.style.fontFamily : undefined,
border: isSuperfest ? '2px dotted' : undefined,
borderColor: isSuperfest ? theme.palette.black.main : undefined,
}}
>
Expand Down Expand Up @@ -148,6 +147,10 @@ export const InstructionsAccordionItem = ({
component={'span'}
mr={'8px'}
sx={{
color:
theme.palette.mode === 'light'
? '#000000'
: '#FFFFFF',
overflow: 'hidden',
textOverflow: 'ellipsis',
maxWidth: 208,
Expand All @@ -158,7 +161,14 @@ export const InstructionsAccordionItem = ({
>
{buttonTitles[i]}
</Typography>
<ArrowForwardIcon />
<ArrowForwardIcon
style={{
color:
theme.palette.mode === 'light'
? '#000000'
: '#FFFFFF',
}}
/>
</InstructionsAccordionLinkBox>
</a>
</InstructionsAccordionButtonMainBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ export const RewardsAmountBox = ({
fontWeight={700}
color={theme.palette.mode === 'dark' ? '#ffffff' : '#000000'}
>
{!account?.address || (isSuccess && rewardAmount === 0) || isConfirmed
{!account?.address ||
(isSuccess && (rewardAmount === 0 || !rewardAmount)) ||
isConfirmed
? '0'
: rewardAmount
? rewardAmount.toFixed(REWARDS_DECIMALS)
Expand Down
16 changes: 15 additions & 1 deletion src/components/ProfilePage/Rewards/RewardsCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,25 @@ export const RewardsCarousel = ({
</FlexCenterRowBox>
<ClaimButtonBox>
<Button
disabled={isPending || isConfirming || isConfirmed}
disabled={
isPending ||
isConfirming ||
isConfirmed ||
(!!rewardAmount && rewardAmount === 0) ||
(isMerklSuccess && !rewardAmount)
}
variant="primary"
aria-label="Claim rewards"
size="large"
styles={{
opacity:
isPending ||
isConfirming ||
isConfirmed ||
(!!rewardAmount && rewardAmount === 0) ||
(isMerklSuccess && !rewardAmount)
? 0.3
: undefined,
alignItems: 'center',
padding: '16px',
width: '100%',
Expand Down
7 changes: 6 additions & 1 deletion src/components/Quests/Rewards/RewardsCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export const RewardsCarousel = ({
</FlexCenterRowBox>
<ClaimButtonBox>
<Button
disabled={isPending || isConfirming || isConfirmed}
disabled={
isPending ||
isConfirming ||
isConfirmed ||
(!!rewardAmount && rewardAmount === 0)
}
variant="primary"
aria-label="Claim rewards"
size="large"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DescriptionBoxSF } from './DescriptionBoxSF/DescriptionBoxSF';
import { InformationAlertBox } from './InformationBox/InformationAlertBox';
import { StepsBox } from './StepsBox/StepsBox';
import { SuperfestPageMainBox } from './SuperfestMissionPage.style';
import { notFound } from 'next/navigation';

interface SuperfestMissionPageVar {
quest: Quest;
Expand Down Expand Up @@ -45,6 +46,10 @@ export const SuperfestMissionPage = ({
});
const { CTAsWithAPYs } = useMissionsAPY(CTAs);

if (!quest) {
return notFound();
}

return (
<SuperfestContainer className="superfest">
<SuperfestPageMainBox>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Widgets/Widget.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export interface WidgetProps extends Omit<BlogWidgetProps, 'allowChains'> {
widgetIntegrator?: string;
starterVariant: StarterVariantType;
activeThemeMode?: ThemeModesSupported;
activeTheme?: any; // TODO: Fix it
activeTheme?: string;
}
22 changes: 16 additions & 6 deletions src/providers/ThemeProviderV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import {
import { CssBaseline } from '@mui/material';
import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
import { deepmerge } from '@mui/utils';
import type { PartnerThemesData } from '@/types/strapi';
import { useTheme } from 'next-themes';
import { useEffect, useState } from 'react';
import { useCookies } from 'react-cookie';
import { darkTheme, lightTheme } from 'src/theme';

function getPartnerTheme(themes: any[], activeTheme: string) {
function getPartnerTheme(themes: PartnerThemesData[], activeTheme?: string) {
return themes?.find((d) => d.attributes.uid === activeTheme)?.attributes;
}

function getMuiTheme(themes: any[], activeTheme: string) {
if (['dark', 'system'].includes(activeTheme)) {
function getMuiTheme(themes: PartnerThemesData[], activeTheme?: string) {
if (activeTheme && ['dark', 'system'].includes(activeTheme)) {
return darkTheme;
} else if (activeTheme === 'light') {
return lightTheme;
Expand All @@ -39,17 +40,26 @@ function getMuiTheme(themes: any[], activeTheme: string) {
return deepmerge(baseTheme, formattedTheme.activeMUITheme);
}

interface ThemeProviderV2Props {
children: React.ReactNode;
activeTheme?: string;
themes: PartnerThemesData[];
}

/**
* Your app's theme provider component.
* 'use client' is essential for next-themes to work with app-dir.
* provider for the MUI theme context, mainly setting up the MUI provider, very linked to the next-theme provider
*/
export function ThemeProviderV2({ children, activeTheme, themes }: any) {
export function ThemeProviderV2({
children,
activeTheme,
themes,
}: ThemeProviderV2Props) {
const { resolvedTheme, forcedTheme, ...props2 } = useTheme();
const [cookie, setCookie] = useCookies(['theme']);
const [partnerThemes, setPartnerThemes] = useSettingsStore((state) => [
state.partnerThemes,
state.setPartnerThemes,
state.setActiveTheme,
]);
const [configTheme, setConfigTheme] = useSettingsStore((state) => [
state.configTheme,
Expand Down
5 changes: 0 additions & 5 deletions src/stores/settings/SettingsStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export const useSettingsStore = createWithEqualityFn(
...defaultSettings,

// Mode
setActiveTheme: (activeTheme: string) => {
set({
activeTheme: activeTheme,
});
},
setConfigTheme: (configTheme: PartnerThemeConfig) => {
set({
configTheme,
Expand Down
5 changes: 2 additions & 3 deletions src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export interface SettingsState extends SettingsProps {
// Mode
setThemeMode: (mode: ThemeModesSupported) => void;

setActiveTheme: (activeTheme: any) => void;
setConfigTheme: (configTheme: any) => void;
setWidgetTheme: (widgetTheme: any) => void;
setConfigTheme: (configTheme: Partial<PartnerThemeConfig>) => void;
setWidgetTheme: (widgetTheme: { config: Partial<WidgetConfig> }) => void; // maybe config

// Installed Wallets
setClientWallets: (wallet: string) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formatTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function getLogoData(theme: PartnerThemesAttributes) {
}

export function formatConfig(
theme: PartnerThemesAttributes,
theme?: PartnerThemesAttributes,
): Partial<PartnerThemeConfig> {
if (!theme) {
return {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test.describe('Jumper full e2e flow', () => {
await expect(page.getByRole('menu')).not.toBeVisible();
});

test('Should be able to navigate to profile and open Explore Fluid Mission', async ({
test.skip('Should be able to navigate to profile and open Explore Fluid Mission', async ({
page,
context,
}) => {
Expand Down

0 comments on commit c8aa918

Please sign in to comment.