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

refactor: pages and sections organization #587

Draft
wants to merge 17 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/activate-subscription-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { encodeAbiParameters } from 'viem';
// LOCAL IMPORTS
import { GLOBAL_CONSTANTS } from '@src/config-global';
import { useAuthorizePolicy } from '@src/hooks/protocol/use-authorize-policy.ts';
import NeonPaper from '@src/sections/publication/NeonPaperContainer.tsx';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import Box from '@mui/material/Box';
import LoadingButton from '@mui/lab/LoadingButton';
import { notifyError, notifySuccess } from '@notifications/internal-notifications.ts';
Expand Down
1 change: 1 addition & 0 deletions src/components/carousel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export interface CarouselSlideProps<T> {
}

export type CarouselCreatorsProps = CarouselResizable & {
profiles: Profile[];
title?: string;
};

Expand Down
20 changes: 3 additions & 17 deletions src/components/carousel/variants/CarouselCreators.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import { memo, FC } from 'react';
import {ExploreProfilesOrderByType, LimitType, PublicationType, useExploreProfiles} from "@lens-protocol/react-web"
import { PublicationType} from "@lens-protocol/react-web"
import { Profile } from '@lens-protocol/api-bindings';
import CarouselSlide from '@src/components/carousel/components/CarouselSlide';
import { UserItem } from '@src/components/user-item';
import CarouselWrapper from './CarouselWrapper';
import { CarouselCreatorsProps } from '../types';
import {filterHiddenProfiles} from "@src/utils/profile.ts"

const CarouselCreators: FC<CarouselCreatorsProps> = (params) => {
const { title, minItemWidth, maxItemWidth } = params;

const { data: latestCreatedProfiles } = useExploreProfiles({
orderBy: ExploreProfilesOrderByType.LatestCreated,
limit: LimitType.Fifty,
});

// FilteredCompletedProfiles is an array of objects, each object has a metadata property and inside exists a displayName en bio property; filter the profiles that not have a displayName and bio property
const filtered = latestCreatedProfiles?.filter(
(profile: any) => profile.metadata?.displayName && profile.metadata?.bio
);

// Clear ###HIDDEN### profiles
const filteredProfiles = filterHiddenProfiles(filtered);
const { profiles, title, minItemWidth, maxItemWidth } = params;

const carouselSettings = {
infinite: false,
Expand Down Expand Up @@ -49,7 +35,7 @@ import {filterHiddenProfiles} from "@src/utils/profile.ts"
);

const carouselParams = {
data: filteredProfiles || [],
data: profiles || [],
title,
minItemWidth,
maxItemWidth,
Expand Down
2 changes: 1 addition & 1 deletion src/components/follow-unfollow-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { removeFollowing, addFollowing } from '@redux/followers';
// LOCAL IMPORTS
import { useNotifications } from '@src/hooks/use-notifications.ts';
import { useNotificationPayload } from '@src/hooks/use-notification-payload.ts';
import NeonPaper from '@src/sections/publication/NeonPaperContainer.tsx';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import Box from '@mui/material/Box';

// Notifications
Expand Down
2 changes: 1 addition & 1 deletion src/components/login-modal/profile-form-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ProfileData } from '@src/auth/context/web3Auth/types.ts';
import { uploadImageToIPFS, uploadMetadataToIPFS } from '@src/utils/ipfs.ts';
import { buildProfileMetadata } from '@src/utils/profile.ts';
import TextMaxLine from '@src/components/text-max-line';
import NeonPaper from '@src/sections/publication/NeonPaperContainer';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import uuidv4 from '@src/utils/uuidv4';

// LENS IMPORTS
Expand Down
2 changes: 1 addition & 1 deletion src/components/poster/variants/poster-creators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Paper from '@mui/material/Paper';
import Image from '@src/components/image';
import { useRouter } from '@src/routes/hooks';
import { paths } from '@src/routes/paths.ts';
import { TrendingTopicsType } from '@src/sections/explore/view.tsx';
import { TrendingTopicsType } from '@src/sections/explore/types.ts';
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import ListItemText from '@mui/material/ListItemText';
Expand Down
2 changes: 1 addition & 1 deletion src/components/poster/variants/poster-latest-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { styled } from '@mui/system';
import Image from '@src/components/image';
import { useRouter } from '@src/routes/hooks';
import { paths } from '@src/routes/paths.ts';
import { TrendingTopicsType } from '@src/sections/explore/view.tsx';
import { TrendingTopicsType } from '@src/sections/explore/types.ts';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import TextMaxLine from '@src/components/text-max-line';
Expand Down
2 changes: 1 addition & 1 deletion src/components/poster/variants/poster-trending-topic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Stack from '@mui/material/Stack';
import Image from '@src/components/image';
import { useRouter } from '@src/routes/hooks';
import { paths } from '@src/routes/paths.ts';
import { TrendingTopicsType } from '@src/sections/explore/view.tsx';
import { TrendingTopicsType } from '@src/sections/explore/types.ts';
import Box from '@mui/material/Box';

// ----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/components/publication-detail-main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import { paths } from '@src/routes/paths.ts';
import { useRouter } from '@src/routes/hooks';
import { varFade } from '@src/components/animate';
import { LeaveTipCard } from '@src/components/leave-tip-card.tsx';
import PostCommentList from '@src/sections/publication/publication-comments-list.tsx';
import PublicationCommentForm from '@src/sections/publication/publication-details-comment-form.tsx';
import PostCommentList from '@src/sections/publication/components/publication-comments-list.tsx';
import PublicationCommentForm from '@src/sections/publication/components/publication-details-comment-form.tsx';
import { SubscribeToUnlockCard } from '@src/components/subscribe-to-unlock-card/subscribe-to-unlock-card.tsx';
import { ReportPublicationModal } from '@src/components/report-publication-modal.tsx';
import Popover from '@mui/material/Popover';
Expand Down
2 changes: 1 addition & 1 deletion src/components/publication-detail-main/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface PublicationDetailProps {
handleSubscribe: () => void;
handleRefetchAccess: () => void;
loadingSubscribe: boolean;
subscribeDisabled: boolean;
subscribeDisabled?: boolean;
hasAccess: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { styled } from '@mui/material/styles';
import { Icon } from '@iconify/react';

// LOCAL IMPORTS
import NeonPaper from '@src/sections/publication/NeonPaperContainer.tsx';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import { useSponsoredAccessAgreement } from '@src/hooks/protocol/use-sponsored-access-agreement.ts';
import { useAccountSession } from '@src/hooks/use-account-session.ts';
import { ExtendedSponsoredAccessProps } from '@src/components/sponsored-access-button/types.ts';
Expand Down
2 changes: 1 addition & 1 deletion src/components/subscribe-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { useGetBalance } from '@src/hooks/protocol/use-get-balance.ts';
import { useNotifications } from '@src/hooks/use-notifications.ts';
import { useNotificationPayload } from '@src/hooks/use-notification-payload.ts';
import NeonPaper from '@src/sections/publication/NeonPaperContainer.tsx';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import Box from '@mui/material/Box';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { notifyError, notifySuccess } from '@notifications/internal-notifications.ts';
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/protocol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,8 @@ export interface UseGetSubtitlesReturn {
export interface UseHasAccessHook {
hasAccess?: boolean;
loading: boolean;
fetching: boolean;
error?: HasAccessError | null;
refetch: () => void;
fetch: () => void;
}

// ----------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/protocol/use-get-campaign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ export const useGetCampaign = (): UseGetCampaignHook => {
}
setLoading(true);
try {
const active: any = await publicClient.readContract({
const campaignAddress: any = await publicClient.readContract({
address: GLOBAL_CONSTANTS.CAMPAIGN_REGISTRY_ADDRESS,
abi: CampaignRegistryAbi.abi,
functionName: 'getCampaign',
args: [account, policy],
});
setCampaign(active);
return active;
setCampaign(campaignAddress);
//
return campaignAddress;
} catch (err: any) {
console.error('Error fetching is active:', err);
console.error('Error fetching campaign address:', err);
setCampaign(null);
} finally {
setLoading(false);
Expand Down
33 changes: 14 additions & 19 deletions src/hooks/protocol/use-has-access.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { Address } from 'viem';
import { publicClient } from '@src/clients/viem/publicClient.ts';
import AccessAggAbi from '@src/config/abi/AccessAgg.json';
Expand All @@ -20,17 +20,20 @@ export const useHasAccess = (ownerAddress?: Address): UseHasAccessHook => {
const { isAuthenticated } = useAccountSession();
const [hasAccess, setHasAccess] = useState<boolean | undefined>(undefined);
const [loading, setLoading] = useState(true);
const [fetching, setFetching] = useState(true);
const defaultResponse = {
hasAccess: false,
loading: false,
error: null,
fetch: () => {},
}

const fetchAccess = async () => {
const fetchAccess = useCallback(async () => {
if (!userAddress || !ownerAddress) {
setLoading(false);
setFetching(false);

throw new Error('User address or owner address is missing while verifying user access.');
return defaultResponse;
}

setFetching(true);
setLoading(true);
try {
const accessData: any = await publicClient.readContract({
address: GLOBAL_CONSTANTS.ACCESS_AGG_ADDRESS,
Expand All @@ -47,28 +50,20 @@ export const useHasAccess = (ownerAddress?: Address): UseHasAccessHook => {
notifyError(ERRORS.VERIFY_ACCESS_ERROR);
} finally {
setLoading(false);
setFetching(false);
}
};
}, [userAddress, ownerAddress]);

useEffect(() => {
fetchAccess();
}, [userAddress, ownerAddress]);
}, [fetchAccess]);

if (!isAuthenticated()) {
return {
hasAccess: false,
loading: false,
fetching: false,
error: null,
refetch: () => {},
};
return defaultResponse;
}

return {
hasAccess,
loading,
fetching,
refetch: fetchAccess,
fetch: fetchAccess,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { m } from 'framer-motion';
// LOCAL IMPORTS
import { varHover } from '@src/components/animate';
import AvatarProfile from '@src/components/avatar/avatar';
import NeonPaper from '@src/sections/publication/NeonPaperContainer';
import NeonPaper from '@src/sections/publication/components/neon-paper-container.tsx';
import { UsePopoverReturnType } from '@src/components/custom-popover/use-popover.ts';

// ----------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/pages/403.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Helmet } from 'react-helmet-async';
// sections
import { View403 } from '@src/sections/error';
import { Error403View } from '@src/sections/error';

// ----------------------------------------------------------------------

Expand All @@ -11,7 +11,7 @@ export default function Page403() {
<title> 403 Forbidden</title>
</Helmet>

<View403 />
<Error403View />
</>
);
}
4 changes: 2 additions & 2 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Helmet } from 'react-helmet-async';
// sections
import { NotFoundView } from '@src/sections/error';
import { Error404View } from '@src/sections/error';

// ----------------------------------------------------------------------

Expand All @@ -11,7 +11,7 @@ export default function NotFoundPage() {
<title> 404 Page Not Found!</title>
</Helmet>

<NotFoundView />
<Error404View />
</>
);
}
4 changes: 2 additions & 2 deletions src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Helmet } from 'react-helmet-async';
// sections
import { View500 } from '@src/sections/error';
import { Error500View } from '@src/sections/error';

// ----------------------------------------------------------------------

Expand All @@ -11,7 +11,7 @@ export default function Page500() {
<title> 500 Internal Server Error</title>
</Helmet>

<View500 />
<Error500View />
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// sections
import BlankView from '@src/sections/blank/view';
import ComingSoonView from '../../sections/coming-soon/view';
import BlankView from '@src/sections/blank/views/blank-view.tsx';
import { ComingSoonView } from '../sections/coming-soon';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

Expand Down
4 changes: 2 additions & 2 deletions src/pages/dashboard/analytics.tsx → src/pages/analytics.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BlankView from '../../sections/blank/view';
import ComingSoonView from '../../sections/coming-soon/view';
import BlankView from '../sections/blank/views/blank-view.tsx';
import { ComingSoonView } from '../sections/coming-soon';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

Expand Down
4 changes: 2 additions & 2 deletions src/pages/dashboard/community.tsx → src/pages/community.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BlankView from '../../sections/blank/view';
import ComingSoonView from '../../sections/coming-soon/view';
import BlankView from '../sections/blank/views/blank-view.tsx';
import { ComingSoonView } from '../sections/coming-soon';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

Expand Down
18 changes: 0 additions & 18 deletions src/pages/dashboard/publication/new.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/pages/dashboard/publication/play.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/pages/dashboard/events.tsx → src/pages/events.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// sections
import ComingSoonView from '@src/sections/coming-soon/view.tsx';
import BlankView from '@src/sections/blank/view.tsx';
import { ComingSoonView } from '@src/sections/coming-soon';
import BlankView from '@src/sections/blank/views/blank-view.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pages/dashboard/finance.tsx → src/pages/finance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import OverviewBankingView from '@src/sections/finance';
import { FinanceView } from '@src/sections/finance';
import Header from '@src/layouts/dashboard/header.tsx';
import HeaderContent from '@src/layouts/dashboard/header-content.tsx';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
Expand All @@ -15,7 +15,7 @@ const OverviewBankingPage = () => {
<Header>
<HeaderContent title="Finance" />
</Header>
<WithAuth component={OverviewBankingView} description={'Login to access your balance.'} icon={'iconoir:stats-report'} header={'Finance Dashboard'} />
<WithAuth component={FinanceView} description={'Login to access your balance.'} icon={'iconoir:stats-report'} header={'Finance Dashboard'} />
</OgMetaTags>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// sections
import { GovernanceDetailsView } from '../../../sections/governance/view';
import { GovernanceDetailsView } from '../../sections/governance';
import { GLOBAL_CONSTANTS } from '@src/config-global.ts';
import { OgMetaTags } from '@src/components/og-meta-tags.tsx';

Expand Down
Loading