Skip to content

Commit

Permalink
sanity powered mint config
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoo1 committed Apr 30, 2024
1 parent dc52030 commit 1e8e9e6
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import SearchProvider from './components/Search/SearchContext';
import { AnnouncementProvider } from './contexts/AnnouncementContext';
import BottomSheetModalProvider from './contexts/BottomSheetModalContext';
import ManageWalletProvider from './contexts/ManageWalletContext';
import SanityDataProvider from './contexts/SanityDataContext';
import SyncTokensProvider from './contexts/SyncTokensContext';
import ToastProvider from './contexts/ToastContext';
import { TokenStateManagerProvider } from './contexts/TokenStateManagerContext';
import { magic } from './magic';
import { useCacheIntroVideo } from './screens/Onboarding/useCacheIntroVideo';
import SanityDataProvider from './contexts/SanityDataContext';

SplashScreen.preventAutoHideAsync();

Expand Down
9 changes: 8 additions & 1 deletion apps/mobile/src/components/ClaimMintUpsellBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ export function ClaimMintUpsellBanner({ queryRef }: Props) {
}, [setIsUpsellMintBannerDismissed]);

const handleClaimPress = useCallback(() => {
showBottomSheetModal({ content: <MintCampaignBottomSheet onClose={hideBottomSheetModal} /> });
showBottomSheetModal({
content: (
<MintCampaignBottomSheet
onClose={hideBottomSheetModal}
projectInternalId="mchx-app-store-2024"
/>
),
});
}, [hideBottomSheetModal, showBottomSheetModal]);

const user = query.viewer?.user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import MintCampaignPreTransaction from './MintCampaignPreTransaction';

type Props = {
onClose?: () => void;
projectInternalId?: string;
projectInternalId: string;
};

export default function MintCampaignBottomSheet({ onClose, projectInternalId }: Props) {
Expand All @@ -21,7 +21,6 @@ export default function MintCampaignBottomSheet({ onClose, projectInternalId }:
const projectData = useMemo(() => {
return data?.mintProjects.find((document) => document.internalId === projectInternalId);
}, [data, projectInternalId]);
console.log({ projectData });

if (!projectData) {
// TODO decide best way to handle missing data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function MintCampaignPreTransaction({

const { claimMint, isClamingMint } = useHighlightClaimMint();

const [, setClaimCodeLocalStorage] = usePersistedState(`${projectInternalId}_claim_code`, '');
const [, setClaimCodeLocalStorage] = usePersistedState(`${projectInternalId}-claim-code`, '');

const handlePress = useCallback(
async (recipientWalletId: string) => {
Expand Down
9 changes: 8 additions & 1 deletion apps/mobile/src/components/MintLinkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ export function MintLinkButton({

const handlePress = useCallback(() => {
if (isRadiance) {
showBottomSheetModal({ content: <MintCampaignBottomSheet onClose={hideBottomSheetModal} /> });
showBottomSheetModal({
content: (
<MintCampaignBottomSheet
projectInternalId="mchx-app-store-2024"
onClose={hideBottomSheetModal}
/>
),
});
} else {
Linking.openURL(mintURL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export default function AnnouncementNotification() {
const { announcement, markAnnouncementAsSeen, dismissAnnouncement } = useAnnouncementContext();
const { showBottomSheetModal } = useBottomSheetModalActions();
const handlePress = useCallback(() => {
if (!announcement) return;
showBottomSheetModal({
content: <MintCampaignBottomSheet projectInternalId={announcement?.internal_id} />,
content: <MintCampaignBottomSheet projectInternalId={announcement.internal_id} />,
});
}, [announcement?.internal_id, showBottomSheetModal]);
}, [announcement, showBottomSheetModal]);
const handleDismissPress = useCallback(() => {
dismissAnnouncement();
}, [dismissAnnouncement]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ export function GalleryAnnouncement({ queryRef, notificationRef }: Props) {
const { showBottomSheetModal, hideBottomSheetModal } = useBottomSheetModalActions();
const handlePress = useCallback(() => {
if (internalId === 'apr-2024-mchx-collab') {
showBottomSheetModal({ content: <MintCampaignBottomSheet onClose={hideBottomSheetModal} /> });
showBottomSheetModal({
content: (
<MintCampaignBottomSheet
onClose={hideBottomSheetModal}
projectInternalId="mchx-app-store-2024"
/>
),
});
return;
}
if (!ctaLink) return;
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/contexts/AnnouncementContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const AnnouncementProvider = ({ children }: { children: ReactNode[] }) =>
const fetchAnnouncement = useCallback(async () => {
try {
const result = await fetchSanityContent(
`*[_type == "announcementNotification" && active == true] {
`*[_type == "announcementNotification" && active == true && (platform == "Mobile" || platform == "All")] {
internal_id,
active,
title,
Expand Down
10 changes: 7 additions & 3 deletions apps/mobile/src/contexts/SanityDataContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useMemo,
useState,
} from 'react';
import { useReportError } from 'shared/contexts/ErrorReportingContext';
import { fetchSanityContent } from 'src/utils/sanity';
import { useEffectOnAppForeground } from 'src/utils/useEffectOnAppForeground';

Expand Down Expand Up @@ -45,8 +46,8 @@ export function useSanityDataContext() {

export default function SanityDataProvider({ children }: { children: ReactNode }) {
const [data, setData] = useState<sanityDocumentTypes | null>(null);
const reportError = useReportError();
const fetchData = useCallback(async () => {
console.log('fetching');
try {
const result = await fetchSanityContent(`
*[_type == "mintProject"] {
Expand All @@ -67,9 +68,12 @@ export default function SanityDataProvider({ children }: { children: ReactNode }
setData({ mintProjects: result });
}
} catch (error) {
console.error(error);
if (error instanceof Error) {
reportError(error);
}
reportError('An error occurred while fetching sanity data');
}
}, []);
}, [reportError]);

useEffectOnAppForeground(fetchData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ export default function DebugBottomSheetModal() {
}, []);

const handleClearStorage = useCallback(() => {
AsyncStorage.multiRemove([
MARFA_2023_SUBMITTED_FORM_KEY,
MCHX_CLAIM_CODE_KEY,
`hasSeenAnnouncement-oxen-farcon-2024`,
`hasDismissedAnnouncement-oxen-farcon-2024`,
]);
AsyncStorage.multiRemove([MARFA_2023_SUBMITTED_FORM_KEY, MCHX_CLAIM_CODE_KEY]);
}, []);
return (
<View className="flex flex-column space-y-1 mx-4">
Expand Down
9 changes: 8 additions & 1 deletion apps/mobile/src/screens/SettingsScreen/SettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ export function SettingsScreen() {
}, [navigation]);

const handleDebugMintPress = useCallback(() => {
showBottomSheetModal({ content: <MintCampaignBottomSheet onClose={hideBottomSheetModal} /> });
showBottomSheetModal({
content: (
<MintCampaignBottomSheet
onClose={hideBottomSheetModal}
projectInternalId="mchx-app-store-2024"
/>
),
});
}, [hideBottomSheetModal, showBottomSheetModal]);

const [logout, isLoggingOut] = useLogout();
Expand Down

0 comments on commit 1e8e9e6

Please sign in to comment.