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: avatar profile centralized, session handling, SEO tags, refactored referrals and other minor fixes #448

Merged
merged 28 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fa61312
refactor(login-modal): close modal on backdrop click in profile view
cswni Jan 14, 2025
78ebede
refactor: rename BoxRow to FinanceBoxRow across components
cswni Jan 14, 2025
18f4748
refactor(avatar): consolidate avatar usage with `AvatarProfile`
cswni Jan 14, 2025
8ab71dc
refactor: remove dicebear utility calls for avatar fallback
cswni Jan 14, 2025
b96a088
feat(web3Auth): add session time configuration
cswni Jan 15, 2025
9b2b495
feat: add verified badge to user profiles and items
cswni Jan 15, 2025
ac99f55
feat: added metamask required, adapt earn tokens on mobile, add trans…
Jadapema Jan 17, 2025
32b5233
fix(i18n): update tooltip text to English
cswni Jan 18, 2025
1bfa5cf
feat(auth): add email field and setEmail action to auth slice
cswni Jan 18, 2025
910dbf9
feat(config): add email-related environment variables
cswni Jan 18, 2025
328f9da
feat(auth): retrieve and store user email on login
cswni Jan 18, 2025
5ce7d3c
refactor: replace supabase logic with useReferrals hook
cswni Jan 18, 2025
ae48721
feat(user-profile): add referrals section to user profile
cswni Jan 18, 2025
035e1d2
feat(table): adjust pagination container to full width
cswni Jan 18, 2025
7a557db
feat: add emailjs/browser dependency
cswni Jan 18, 2025
323cc66
feat: added verified connection
Jadapema Jan 18, 2025
6aa3000
refactor: clear unnecessary logs
Jadapema Jan 18, 2025
d3810e0
fix: auth loader HOC
Jadapema Jan 18, 2025
295ab9a
feat: added session validation, once the session is expired logout us…
Jadapema Jan 18, 2025
c01dd5e
feat: added dynamic og tags
Jadapema Jan 18, 2025
a0dc1c0
feat: email invites accept logic
Jadapema Jan 18, 2025
b8a1b81
feat: separate Supabase actions into dedicated utilities
cswni Jan 20, 2025
dc82897
fix: update payload key for self registration
cswni Jan 20, 2025
716cc8f
feat: remove resend button
Jadapema Jan 20, 2025
8775a9f
refactor: replace type assertions and improve fallback handling
cswni Jan 20, 2025
40e0055
fix: correct interface usage in finance-quick-transfer
cswni Jan 20, 2025
f7cf3e6
fix: eslint warnings
Jadapema Jan 20, 2025
434aaef
fix: sonar cloud
Jadapema Jan 20, 2025
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
50 changes: 50 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react",
"react-hooks",
"@typescript-eslint"
],
"rules": {
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-explicit-any": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-namespace": "off",
"import/no-extraneous-dependencies": "off",
"@typescript-eslint/ban-types": "off",
"react/no-unescaped-entities": "off",
"no-async-promise-executor": "off",
"react/no-children-prop": "off",
"no-extra-boolean-cast": "off",
"react/display-name": "off",
"prefer-const": "off",
"no-console": "off",
"no-debugger": "off"
},
"settings": {
"react": {
"version": "detect"
}
}
}
17 changes: 0 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@
rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght@900&display=swap" rel="stylesheet" />

<title>Watchit App</title>


<meta property="og:title" content="Watchit app" />
<meta property="og:description" content="Experience content like never before with Web3xAI" />
<meta property="og:url" content="https://app.watchit.movie" />
<meta property="og:image" content="https://pbs.twimg.com/profile_images/1814015504412987392/7FKUViWb_400x400.jpg" />
<meta property="og:type" content="website" />


<meta name="twitter:card" content="Explore and support a new era of video content on Watchit. Connect with creators, access exclusive experiences, and join a decentralized community powered by Web3 and AI." />
<meta name="twitter:title" content="Watchit app" />
<meta name="twitter:description" content="Experience content like never before with Web3xAI" />
<meta name="twitter:url" content="https://app.watchit.movie" />
<meta name="twitter:image" content="https://pbs.twimg.com/profile_images/1814015504412987392/7FKUViWb_400x400.jpg" />


<meta name="description" content="Explore and support a new era of video content on Watchit. Connect with creators, access exclusive experiences, and join a decentralized community powered by Web3 and AI." />
<meta name="keywords" content="Watchit app, Web3, AI, streaming, innovative content, Watchit, video platform, creator support, decentralized entertainment, Web3, AI, exclusive content, video community, NFT, digital rights, smart contracts, blockchain media" />
<meta name="author" content="Watchit Team" />
Expand Down
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
]
},
"dependencies": {
"@emailjs/browser": "^4.4.1",
"@helia/unixfs": "^4.0.1",
"@hookform/resolvers": "^3.1.1",
"@iconify/react": "^4.1.1",
Expand Down
28 changes: 14 additions & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ export default function App() {
themeStretch: false,
}}
>
<AuthProvider>
<Provider store={store}>
<ThemeProvider>
<MotionLazy>
<SnackbarProvider>
<SettingsDrawer />
<ProgressBar />
<Router />
<ResponsiveOverlay />
</SnackbarProvider>
</MotionLazy>
</ThemeProvider>
</Provider>
</AuthProvider>
<Provider store={store}>
<AuthProvider>
<ThemeProvider>
<MotionLazy>
<SnackbarProvider>
<SettingsDrawer />
<ProgressBar />
<Router />
<ResponsiveOverlay />
</SnackbarProvider>
</MotionLazy>
</ThemeProvider>
</AuthProvider>
</Provider>
</SettingsProvider>
</LocalizationProvider>
</MetaMaskProvider>
Expand Down
1 change: 1 addition & 0 deletions src/auth/context/web3Auth/config/web3AuthSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export function web3AuthFactory(): Web3Auth {
});

const web3AuthOptions: Web3AuthOptions = {
sessionTime: 60 * 60 * 24 * 30, // 30 days
privateKeyProvider,
accountAbstractionProvider,
chainConfig: chain.polygonAmoy,
Expand Down
2 changes: 1 addition & 1 deletion src/components/animate/motion-lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LazyMotion, m } from 'framer-motion';

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

// eslint-disable-next-line import/extensions
// @ts-ignore
const loadFeatures = () => import('./features.js').then((res) => res.default);

type Props = {
Expand Down
23 changes: 23 additions & 0 deletions src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @mui
import Avatar from '@mui/material/Avatar';
import {FC} from "react";
import {dicebear} from "@src/utils/dicebear.ts";

interface AvatarProfileProps {
src: string;
alt?: string;
sx?: any;
[x: string]: any;
}

const AvatarProfile: FC<AvatarProfileProps> = ({ src, alt, sx, ...other }) => {

//Check if src is a valid URL starting with http or https; if not, use the dicebear API to generate a random avatar
if (!src.startsWith('http') && !src.startsWith('https')) { src = dicebear(src) }

return (
<Avatar alt={alt ?? 'Avatar profile'} src={src} sx={sx} {...other} />
)
}

export default AvatarProfile;
1 change: 1 addition & 0 deletions src/components/avatar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@src/components/avatar';
2 changes: 0 additions & 2 deletions src/components/carousel/variants/carousel-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import { varFade } from '@src/components/animate';
import Carousel, { CarouselDots, useCarousel } from '@src/components/carousel/index';
import { IconFlagFilled, IconPlayerPlay } from '@tabler/icons-react';
import Stack from '@mui/material/Stack';

// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import { type Post } from '@lens-protocol/api-bindings/dist/declarations/src/lens/graphql/generated';
import { paths } from '@src/routes/paths.ts';
import { useRouter } from '@src/routes/hooks';
Expand Down
30 changes: 25 additions & 5 deletions src/components/login-modal/modal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// REACT IMPORTS
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';

// MUI IMPORTS
import { Backdrop, Box, Fade, Modal } from '@mui/material';
Expand All @@ -13,9 +13,12 @@ import { ProfileSelectView } from '@src/components/login-modal/profile-select-vi
import { ProfileFormView } from '@src/components/login-modal/profile-form-view.tsx';
import { WatchitLoader } from '../watchit-loader';
import { useDispatch, useSelector } from 'react-redux';
import { closeLoginModal } from '@redux/auth';
import {closeLoginModal, setEmail} from '@redux/auth';
import { notifySuccess } from '@notifications/internal-notifications.ts';
import { SUCCESS } from '@notifications/success.ts';
// @ts-ignore
import {type AuthUserInfo} from "@web3auth/auth/dist/types/utils/interfaces";
import useReferrals from '@src/hooks/use-referrals.ts';

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

Expand All @@ -35,6 +38,7 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
const sessionData = useSelector((state: any) => state.auth.session);
const { execute: logoutExecute } = useLogout();
const { execute: loginExecute, error } = useLogin();
const { acceptOrCreateInvitationForUser } = useReferrals();
const dispatch = useDispatch();

useEffect(() => {
Expand All @@ -45,6 +49,9 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
method: 'eth_accounts',
});

// Obtain user info from the provider to get the email
await w3.getUserInfo().then((r:Partial<AuthUserInfo>) => dispatch(setEmail(r?.email)));

if (accounts && accounts.length > 0) {
setAddress(accounts[0]);
}
Expand All @@ -66,6 +73,12 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
await w3?.connect();
setView('profile');
setLoading(false);

// Once the user is authenticated, store the session expiration
const sessionTimeMs = 60 * 60 * 24 * 30 * 1000; // 30 days
const expirationTimestamp = Date.now() + sessionTimeMs;
localStorage.setItem("sessionExpiration", expirationTimestamp.toString());

} catch (err) {
onClose();
w3?.loginModal.closeModal();
Expand All @@ -76,10 +89,11 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
}
}, [open, view, w3.connected]);

const handleProfileCreateSuccess = () => {
const handleProfileCreateSuccess = useCallback(() => {
acceptOrCreateInvitationForUser();
notifySuccess(SUCCESS.PROFILE_CREATED_SUCCESSFULLY);
dispatch(closeLoginModal());
};
}, []);

const handleLogin = async (profile?: Profile) => {
if (!profile || !address) return;
Expand All @@ -100,6 +114,12 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
setAddress('');
};

const handleBackdropClick = () => {
if (view === 'profile') {
onClose();
}
};

return (
<>
<Modal
Expand All @@ -109,7 +129,7 @@ export const LoginModal: React.FC<LoginModalProps> = ({ open, onClose }) => {
onClose={onClose}
closeAfterTransition
BackdropComponent={Backdrop}
BackdropProps={{ timeout: 500, onClick: () => {} }}
BackdropProps={{ timeout: 500, onClick: handleBackdropClick }}
>
<Fade in={open}>
<Box
Expand Down
18 changes: 9 additions & 9 deletions src/components/login-modal/profile-form-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useFormik } from 'formik';
import * as Yup from 'yup';

// Redux
// REDUX IMPORTS
import { useDispatch, useSelector } from 'react-redux';
import { RootState } from '@reduxjs/toolkit/query';
import {
Expand All @@ -16,9 +16,8 @@ import {

// MUI IMPORTS
import { Box, Button, Grid, Input, TextField, Typography } from '@mui/material';
import Avatar from '@mui/material/Avatar';

// Project IMPORTS
// PROJECTS IMPORTS
import Image from '../image';
import { ProfileData } from '@src/auth/context/web3Auth/types.ts';
import { uploadImageToIPFS, uploadMetadataToIPFS } from '@src/utils/ipfs.ts';
Expand All @@ -27,7 +26,7 @@ import TextMaxLine from '@src/components/text-max-line';
import NeonPaper from '@src/sections/publication/NeonPaperContainer';
import uuidv4 from '@src/utils/uuidv4';

// Lens
// LENS IMPORTS
import { Profile } from '@lens-protocol/api-bindings';
import {
LoginError,
Expand All @@ -36,10 +35,11 @@ import {
useSetProfileMetadata,
} from '@lens-protocol/react-web';

// Notifications
// NOTIFICATIONS IMPORTS
import { notifyError, notifySuccess } from '@notifications/internal-notifications';
import { SUCCESS } from '@notifications/success';
import { ERRORS } from '@notifications/errors.ts';
import AvatarProfile from "@src/components/avatar/avatar.tsx";

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

Expand Down Expand Up @@ -113,8 +113,8 @@ export const ProfileFormView: React.FC<ProfileFormProps> = ({
username: Yup.string()
.min(5, 'Username must be at least 5 characters')
.required('Username is required'),
name: Yup.string().required('Name is required'),
bio: Yup.string().required('Bio is required'),
name: Yup.string().min(3, 'Name must be at least 3 characters').required('Name is required'),
bio: Yup.string().min(10, 'Bio must be at least 10 characters').required('Bio is required'),
socialLinks: Yup.object({
twitter: Yup.string().url('Enter a valid URL'),
instagram: Yup.string().url('Enter a valid URL'),
Expand Down Expand Up @@ -378,12 +378,12 @@ export const ProfileFormView: React.FC<ProfileFormProps> = ({
}}
/>
{/* Avatar */}
<Avatar
<AvatarProfile
src={
profileImagePreview ??
(initialValues?.profileImage
? `https://ipfs.io/ipfs/${initialValues?.profileImage?.replaceAll?.('ipfs://', '')}`
: `https://api.dicebear.com/9.x/bottts-neutral/svg?seed=${mode === 'update' && sessionData?.authenticated ? sessionData?.profile?.id : 'new'}`)
: mode === 'update' && sessionData?.authenticated ? sessionData?.profile?.id : 'new')
}
alt=""
onClick={() => profileImageInputRef.current?.click()}
Expand Down
Loading
Loading