Skip to content

Commit

Permalink
✨ Add loading skeletons for Shopify gate not connected and address pages
Browse files Browse the repository at this point in the history
♻️ Refactor Shopify gate sections to remove Suspense and fallbacks

🐛 Remove unused imports and clean up code across Shopify features and i18n libs

💡 Improve code readability and performance by simplifying component structures
  • Loading branch information
sebpalluel committed Apr 30, 2024
1 parent 9aa543c commit cc9f6af
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { OffKeyGateNotConnectedSkeleton } from '@features/unlock/shopify';

export default function Page() {
return <OffKeyGateNotConnectedSkeleton />;
}
16 changes: 2 additions & 14 deletions apps/unlock/app/[locale]/shopify/[gateId]/(notConnected)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {
OffKeyGateNotConnectedSkeleton,
ShopifyCustomerStatus,
} from '@features/unlock/shopify';
import { ShopifyCustomerStatus } from '@features/unlock/shopify';
import { getShopifyCampaignParametersForNotConnected } from '@features/unlock/shopify-api';
import { Locale } from '@gql/shared/types';
import dynamic from 'next/dynamic';
import { notFound } from 'next/navigation';
import { Suspense } from 'react';

const OffKeyGateNotConnected = dynamic(
() =>
Expand All @@ -23,15 +19,7 @@ interface GateNotConnectedProps {
};
}

export default function GateNotConnectedSection(props: GateNotConnectedProps) {
return (
<Suspense fallback={<OffKeyGateNotConnectedSkeleton />}>
<GateNotConnected {...props} />
</Suspense>
);
}

async function GateNotConnected({
export default async function GateNotConnected({
params: { locale, gateId },
}: GateNotConnectedProps) {
const campaign = await getShopifyCampaignParametersForNotConnected({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { OffKeyGateSkeleton } from '@features/unlock/shopify';

export default function Page() {
return <OffKeyGateSkeleton />;
}
14 changes: 3 additions & 11 deletions apps/unlock/app/[locale]/shopify/[gateId]/[address]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { OffKeyGateSkeleton } from '@features/unlock/shopify';
import { getShopifyCampaignParametersForConnected } from '@features/unlock/shopify-api';
import { Locale } from '@gql/shared/types';
import { OffKeyState } from '@next/iframe';
import dynamic from 'next/dynamic';
import { notFound } from 'next/navigation';
import { Suspense } from 'react';

interface GateProps {
params: {
Expand All @@ -19,15 +17,9 @@ const OffKeyGate = dynamic(
{ ssr: false },
);

export default function GateSection(props: GateProps) {
return (
<Suspense fallback={<OffKeyGateSkeleton />}>
<Gate {...props} />
</Suspense>
);
}

async function Gate({ params: { locale, gateId, address } }: GateProps) {
export default async function Gate({
params: { locale, gateId, address },
}: GateProps) {
const campaign = await getShopifyCampaignParametersForConnected({
gateId,
locale,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { interpolateString, Locale } from '@next/i18n';
import { AutoAnimate, Text, TextSkeleton } from '@ui/components';
import { AutoAnimate, Text } from '@ui/components';
import { useShopifyCustomer } from '../hooks/useShopifyCustomer';
import { ShopifyCustomerStatus } from '../types';
import { OffKeyGateNotConnectedSkeleton } from './OffKeyGateNotConnectedSkeleton';
Expand Down
1 change: 0 additions & 1 deletion libs/next/i18n/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function interpolateString(
}
return result as string;
} catch (error) {
console.error('Error interpolating string:', error);
return str;
}
}
Expand Down

0 comments on commit cc9f6af

Please sign in to comment.