diff --git a/lang/ca.json b/lang/ca.json index b373d57ae4..fa5b4f6e37 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -308,10 +308,10 @@ "label.deposit_confirmed": "Dipòsit confirmat", "label.deposit_or_stream_balance": "Diposita Tokens o utilitza el Saldo de Transmissió", "label.deposit_token_use_balance": "Diposita Tokens o utilitza el Saldo de Transmissió", - "label.devouch.attest_on_devouch": "Certifica a DeVouch", - "label.devouch.if_you_are_eligible": "Si ets un verificador elegible de Giveth, pots avalar la legitimitat d'aquest projecte, potencialment augmentant els beneficis que rep a Giveth.", + "label.devouch.go_to_devouch": "Anar a DeVouch", + "label.devouch.description.vouch_this_project": "Amb DeVouch, pots assenyalar el teu suport a aquest projecte testificant la seva legitimitat, cosa que potencialment augmentarà els beneficis que rep a Giveth.", "label.devouch.learn_more_about_devouch": "Més informació sobre DeVouch i la verificació descentralitzada", - "label.devouch.view_this_project": "Veure aquest projecte a DeVouch", + "label.devouch.title.vouch_this_project": "Avalar aquest Projecte", "label.didnt_get_the_givdrop": "No has rebut el GIVdrop?", "label.did_the_donation_but_not_confirmed": "He fet la donació però no està confirmada.", "label.discover_our_roadmap": "descobreix la nostra planificació estratègica", @@ -1662,10 +1662,9 @@ "project.givback_toast.description.non_verified_owner_submitted": "Notícies emocionants! La teva sol·licitud ha estat enviada i està a la cua per ser revisada pel nostre equip de revisió d'elegibilitat per a GIVbacks. Et respondrem en un termini d'1-2 setmanes.", "project.givback_toast.description.non_verified_public": "Actualment, els GIVbacks només s'atorguen per donacions fetes a projectes elegibles per a GIVbacks a Ethereum. La teva contribució segueix sent important, fins i tot si no genera GIVbacks!", "project.givback_toast.description.verified_owner": "Potencia el teu projecte per augmentar el seu percentatge de GIVbacks i ajudar-lo a aparèixer més amunt a la pàgina de projectes!", - "project.givback_toast.description.verified_owner_not_eligible": "El teu projecte ha estat avalat pels Verificadors de Giveth i ara pot beneficiar-se de GIVpower. Fes stake i bloqueja els teus tokens GIV per impulsar aquest projecte i fer-lo més visible a la pàgina de projectes. No obstant això, donar a aquest projecte no generarà GIVbacks per als donants.", - "project.givback_toast.description.verified_public": "Les donacions de ${value} o més són elegibles per a GIVbacks. Impulsa aquest projecte per augmentar el seu percentatge de recompenses i visibilitat a la pàgina de projectes!", - "project.givback_toast.description.verified_public_not_eligible": "{stakeLock} els teus tokens GIV per obtenir GIVpower. Impulsa aquest projecte per fer-lo més visible a la pàgina de projectes. Nota: Tot i que aquest projecte és elegible per ser impulsat amb GIVpower, no generarà GIVbacks per als seus donants.", + "project.givback_toast.description.verified_public": "Les donacions a Ethereum a projectes elegibles per a GIVbacks són recompensades amb GIV. Impulsa aquest projecte per augmentar el seu percentatge de recompenses i fer-lo més visible a la pàgina de projectes!", "project.givback_toast.title.non_verified_owner": "El teu projecte està creant o donant suport a béns públics?", + "project.givback_toast.description.verified_owner_not_eligible": "El teu projecte ha estat avalat pels Verificadors de Giveth i ara pot beneficiar-se de GIVpower. Fes stake i bloqueja els teus tokens GIV per impulsar aquest projecte i fer-lo més visible a la pàgina de projectes. No obstant això, donar a aquest projecte no generarà GIVbacks per als donants.", "project.givback_toast.title.non_verified_owner_cancelled": "Estat Cancel·lat", "project.givback_toast.title.non_verified_owner_deactive": "Mode Desactivat", "project.givback_toast.title.non_verified_owner_draft": "Publica el teu projecte avui!", diff --git a/lang/en.json b/lang/en.json index 41efee8dcd..c81997f83b 100644 --- a/lang/en.json +++ b/lang/en.json @@ -308,10 +308,10 @@ "label.deposit_confirmed": "Deposit confirmed", "label.deposit_or_stream_balance": "Deposit Tokens or use Stream Balance", "label.deposit_token_use_balance": "Deposit Tokens or use Stream Balance", - "label.devouch.attest_on_devouch": "Attest on Devouch", - "label.devouch.if_you_are_eligible": "If you are an eligible Giveth Verifier you can vouch for this project's legitimacy, potentially increasing the benefits it receives on Giveth.", + "label.devouch.go_to_devouch": "Go to DeVouch", + "label.devouch.title.vouch_this_project": "Vouch for this Project", + "label.devouch.description.vouch_this_project": "With DeVouch, you can signal your support for this project by attesting to its legitimacy, potentially increasing the benefits it receives on Giveth.", "label.devouch.learn_more_about_devouch": "Learn more about DeVouch & Decentralized Verification", - "label.devouch.view_this_project": "View this Project on DeVouch", "label.didnt_get_the_givdrop": "Didn’t get the GIVdrop?", "label.did_the_donation_but_not_confirmed": "I did the donation but it's not confirmed.", "label.discover_our_roadmap": "discover our roadmap", diff --git a/lang/es.json b/lang/es.json index 0fdb935136..757a50adb2 100644 --- a/lang/es.json +++ b/lang/es.json @@ -308,10 +308,10 @@ "label.deposit_confirmed": "Depósito confirmado", "label.deposit_or_stream_balance": "Deposita Tokens o usa el Saldo de Transmisión", "label.deposit_token_use_balance": "Deposita Tokens o usa el Saldo de Transmisión", - "label.devouch.attest_on_devouch": "Certificar en DeVouch", - "label.devouch.if_you_are_eligible": "Si eres un verificador elegible de Giveth, puedes avalar la legitimidad de este proyecto, potencialmente aumentando los beneficios que recibe en Giveth.", + "label.devouch.go_to_devouch": "Ir a DeVouch", + "label.devouch.description.vouch_this_project": "Con DeVouch, puedes señalar tu apoyo a este proyecto atestiguando su legitimidad, lo que potencialmente aumentará los beneficios que recibe en Giveth.", "label.devouch.learn_more_about_devouch": "Más información sobre DeVouch y la verificación descentralizada", - "label.devouch.view_this_project": "Ver este proyecto en DeVouch", + "label.devouch.title.vouch_this_project": "Avalar este Proyecto", "label.didnt_get_the_givdrop": "¿No has recibido el GIVdrop?", "label.did_the_donation_but_not_confirmed": "Hice la donación pero no está confirmada.", "label.discover_our_roadmap": "descubre nuestra hoja de ruta", @@ -1661,10 +1661,10 @@ "project.givback_toast.description.non_verified_owner_rejected_2": " o al soporte de Discord para más instrucciones.", "project.givback_toast.description.non_verified_owner_submitted": "¡Noticias emocionantes! Tu solicitud ha sido enviada y está en la cola para ser revisada por nuestro equipo de revisión de elegibilidad para GIVbacks. Te responderemos en un plazo de 1-2 semanas.", "project.givback_toast.description.non_verified_public": "Actualmente, los GIVbacks solo se otorgan por donaciones hechas a proyectos elegibles para GIVbacks en Ethereum. ¡Tu contribución sigue siendo importante, incluso si no genera GIVbacks!", - "project.givback_toast.description.verified_owner": "Impulsa tu proyecto para aumentar su porcentaje de GIVbacks y ayudarlo a aparecer más alto en la página de proyectos.", + "project.givback_toast.description.verified_owner": "Impulsa tu proyecto para aumentar la cantidad de GIVbacks que reciben tus donantes en Ethereum y aumentar su visibilidad entre otros proyectos.", "project.givback_toast.description.verified_owner_not_eligible": "Tu proyecto ha sido avalado por los Verificadores de Giveth y ahora puede beneficiarse de GIVpower. Haz stake y bloquea tus tokens GIV para impulsar este proyecto y hacerlo más visible en la página de proyectos. Sin embargo, donar a este proyecto no generará GIVbacks para los donantes.", "project.givback_toast.description.verified_public": "Las donaciones de ${value} o más son elegibles para recibir GIVbacks. ¡Impulsa este proyecto para aumentar su porcentaje de recompensas y su visibilidad en la página de proyectos!", - "project.givback_toast.description.verified_public_not_eligible": "{stakeLock} tus tokens GIV para obtener GIVpower. Impulsa este proyecto para hacerlo más visible en la página de proyectos. Nota: Aunque este proyecto es elegible para ser impulsado con GIVpower, no generará GIVbacks para sus donantes.", + "project.givback_toast.description.verified_public_not_eligible": "{stakeLock} tus GIV tokens para obtener GIVpower. ¡Impulsa este proyecto para hacerlo más visible en la página de proyectos! Ten en cuenta que aunque este proyecto es elegible para ser impulsado con GIVpower, no generará GIVbacks para sus donantes.", "project.givback_toast.title.non_verified_owner": "¿Tu proyecto está creando o apoyando bienes públicos?", "project.givback_toast.title.non_verified_owner_cancelled": "Estado Cancelado", "project.givback_toast.title.non_verified_owner_deactive": "Modo Desactivado", diff --git a/lang/t_ca.json b/lang/t_ca.json index d2a5d33f70..028a0d1c3f 100644 --- a/lang/t_ca.json +++ b/lang/t_ca.json @@ -151,7 +151,6 @@ "page.project.preview_hint": "Aquesta és una previsualització del teu projecte.", "project.givback_toast.description.non_verified_owner": "Pots demostrar que el teu projecte està proporcionant un bé públic? La verificació et dóna accés a una gran quantitat de beneficis com recompenses per a donants, major visibilitat i formes addicionals d'obtenir fons!", "project.givback_toast.description.non_verified_public": "Actualment, els GIVbacks només es concedeixen per donacions fetes a projectes verificats. La teva contribució encara és important, encara que no generi GIVbacks!", - "project.givback_toast.description.verified_owner": "Impulsa el teu projecte per augmentar el seu percentatge de recompenses i fer-lo més visible a la pàgina de projectes!", "project.givback_toast.description.verified_public": "Els donants de projectes verificats són recompensats amb GIV. Impulsa aquest projecte per augmentar el seu percentatge de recompenses i fer-lo més visible a la pàgina de projectes!", "project.givback_toast.title.non_verified_owner": "Porta el teu projecte al següent nivell amb la Verificació!", "project.givback_toast.title.non_verified_public": "Per què no hi ha GIVbacks?", diff --git a/lang/t_es.json b/lang/t_es.json index 458545900a..183125dbfc 100644 --- a/lang/t_es.json +++ b/lang/t_es.json @@ -117,7 +117,6 @@ "page.project.preview_hint": "Esta es una vista previa de tu proyecto.", "project.givback_toast.description.non_verified_owner": "¿Puedes demostrar que tu proyecto está proporcionando un bien público? ¡La verificación te da acceso a una gran cantidad de beneficios como recompensas para los donantes, mayor visibilidad y formas adicionales de recaudar fondos!", "project.givback_toast.description.non_verified_public": "Los GIVbacks se otorgan actualmente solo por donaciones realizadas a proyectos verificados. ¡Tu contribución sigue siendo importante, incluso si no genera GIVbacks!", - "project.givback_toast.description.verified_owner": "¡Impulsa tu proyecto para aumentar su porcentaje de recompensas y hacerlo más visible en la página de proyectos!", "project.givback_toast.description.verified_public": "Los donantes a proyectos verificados son recompensados con GIV. ¡Impulsa este proyecto para aumentar su porcentaje de recompensas y hacerlo más visible en la página de proyectos!", "project.givback_toast.title.non_verified_owner": "¡Lleva tu proyecto al siguiente nivel con la Verificación!", "project.givback_toast.title.non_verified_public": "¿Por qué no hay GIVbacks?", diff --git a/package.json b/package.json index f8b3083f33..9e5c6b1b85 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "devDependencies": { "@babel/preset-typescript": "^7.23.3", "@next/bundle-analyzer": "^14.1.0", + "@tanstack/react-query-devtools": "^5.58.0", "@testing-library/cypress": "^10.0.1", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", diff --git a/src/apollo/apolloClient.ts b/src/apollo/apolloClient.ts index 6bf978265c..4cedd8970d 100644 --- a/src/apollo/apolloClient.ts +++ b/src/apollo/apolloClient.ts @@ -1,5 +1,10 @@ import { useMemo } from 'react'; -import { ApolloClient, InMemoryCache, ApolloLink } from '@apollo/client'; +import { + ApolloClient, + InMemoryCache, + ApolloLink, + NormalizedCacheObject, +} from '@apollo/client'; import { RetryLink } from '@apollo/client/link/retry'; import { setContext } from '@apollo/client/link/context'; import { onError } from '@apollo/client/link/error'; @@ -14,20 +19,21 @@ import { signOut } from '@/features/user/user.thunks'; import config from '@/configuration'; import { setShowSignWithWallet } from '@/features/modal/modal.slice'; -let apolloClient: any; +let apolloClient: ApolloClient | undefined; const ssrMode = isSSRMode; export const APOLLO_STATE_PROP_NAME = '__APOLLO_STATE__'; -const parseHeaders = (rawHeaders: any) => { +// Parses headers into the Headers object +const parseHeaders = (rawHeaders: string) => { const headers = new Headers(); // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space // https://tools.ietf.org/html/rfc7230#section-3.2 const preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); - preProcessedHeaders.split(/\r?\n/).forEach((line: any) => { + preProcessedHeaders.split(/\r?\n/).forEach((line: string) => { const parts = line.split(':'); - const key = parts.shift().trim(); + const key = parts.shift()?.trim(); if (key) { const value = parts.join(':').trim(); headers.append(key, value); @@ -36,6 +42,7 @@ const parseHeaders = (rawHeaders: any) => { return headers; }; +// Custom fetch logic with file upload handling const uploadFetch = (url: string, options: any) => new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); @@ -49,8 +56,11 @@ const uploadFetch = (url: string, options: any) => 'responseURL' in xhr ? xhr.responseURL : opts.headers.get('X-Request-URL'); + // TypeScript fix: Explicitly cast `xhr` to `XMLHttpRequest` to access responseText const body = - 'response' in xhr ? xhr.response : (xhr as any).responseText; + 'response' in xhr + ? xhr.response + : (xhr as XMLHttpRequest).responseText; resolve(new Response(body, opts)); }; xhr.onerror = () => { @@ -76,14 +86,16 @@ const uploadFetch = (url: string, options: any) => xhr.send(options.body); }); -const customFetch = (uri: any, options: any) => { +// Custom fetch function to determine when to use upload fetch or standard fetch +const customFetch = (uri: string, options: any) => { if (options.useUpload) { return uploadFetch(uri, options); } return fetch(uri, options); }; -function createApolloClient() { +// Creates the Apollo Client with the custom link setup +function createApolloClient(): ApolloClient { let userWalletAddress: string | null; if (!ssrMode) { userWalletAddress = localStorage.getItem(StorageLabel.USER); @@ -91,11 +103,13 @@ function createApolloClient() { const retryLink = new RetryLink(); + // Custom link for handling file uploads const httpLink = createUploadLink({ uri: config.BACKEND_LINK, fetch: customFetch as any, }); + // Auth link to add Authorization and locale headers const authLink = setContext((_, { headers }) => { let locale: string | null = !ssrMode ? localStorage.getItem(StorageLabel.LOCALE) @@ -117,12 +131,13 @@ function createApolloClient() { }; }); + // Error handling link const errorLink = onError(({ graphQLErrors, networkError, operation }) => { if (graphQLErrors) { console.log('operation', operation); graphQLErrors.forEach(err => { console.error('err', JSON.stringify(err)); - const { message, locations, path } = err; + const { message } = err; if (message.toLowerCase().includes('authentication required')) { console.log(Date.now(), 'sign out from graphQL'); // removes token and user from store @@ -190,7 +205,10 @@ function createApolloClient() { }); } -export function initializeApollo(initialState = null) { +// Initialize Apollo Client for SSR and client-side rendering +export function initializeApollo( + initialState: any = null, +): ApolloClient { const _apolloClient = apolloClient ?? createApolloClient(); // If your page has Next.js data fetching methods that use Apollo Client, the initial state @@ -202,7 +220,7 @@ export function initializeApollo(initialState = null) { // Merge the existing cache into data passed from getStaticProps/getServerSideProps const data = merge(initialState, existingCache, { // combine arrays using object equality (like in sets) - arrayMerge: (destinationArray, sourceArray) => [ + arrayMerge: (destinationArray: any[], sourceArray: any[]) => [ ...sourceArray, ...destinationArray.filter(d => sourceArray.every(s => !isEqual(d, s)), @@ -221,7 +239,11 @@ export function initializeApollo(initialState = null) { return _apolloClient; } -export function addApolloState(client: any, pageProps: any) { +// Adds Apollo Client's state to pageProps +export function addApolloState( + client: ApolloClient, + pageProps: any, +) { if (pageProps?.props) { pageProps.props[APOLLO_STATE_PROP_NAME] = client.cache.extract(); } @@ -229,10 +251,12 @@ export function addApolloState(client: any, pageProps: any) { return pageProps; } +// Custom React hook to use Apollo Client export function useApollo(pageProps: any) { const state = pageProps[APOLLO_STATE_PROP_NAME]; return useMemo(() => initializeApollo(state), [state]); } -export const client = initializeApollo(); +// Export the client instance +export const client: ApolloClient = initializeApollo(); diff --git a/src/apollo/gql/gqlProjects.ts b/src/apollo/gql/gqlProjects.ts index cc3d8a260b..6546c7d2c0 100644 --- a/src/apollo/gql/gqlProjects.ts +++ b/src/apollo/gql/gqlProjects.ts @@ -804,3 +804,9 @@ export const FETCH_RECURRING_DONATIONS_BY_DATE = gql` } } `; + +export const DELETE_DRAFT_PROJECT = gql` + mutation ($projectId: Float!) { + deleteDraftProject(projectId: $projectId) + } +`; diff --git a/src/components/VerificationBadge.tsx b/src/components/VerificationBadge.tsx index 3a1d001596..b741d8701c 100644 --- a/src/components/VerificationBadge.tsx +++ b/src/components/VerificationBadge.tsx @@ -3,12 +3,15 @@ import { EVerificationStatus } from '@/apollo/types/types'; import { Badge, EBadgeStatus } from './Badge'; interface IProps { - isVerified?: boolean; + isGivbackEligible?: boolean; verificationStatus?: EVerificationStatus; } -const VerificationBadge: FC = ({ isVerified, verificationStatus }) => { - const verStatus = isVerified +const VerificationBadge: FC = ({ + isGivbackEligible, + verificationStatus, +}) => { + const verStatus = isGivbackEligible ? EVerificationStatus.VERIFIED : verificationStatus !== EVerificationStatus.VERIFIED ? verificationStatus diff --git a/src/components/badges/ShareLikeBadge.tsx b/src/components/badges/ShareLikeBadge.tsx index d55776d3fd..9feb1d256d 100644 --- a/src/components/badges/ShareLikeBadge.tsx +++ b/src/components/badges/ShareLikeBadge.tsx @@ -54,7 +54,7 @@ const Wrapper = styled(FlexCenter)` const BadgeText = styled(ButtonText)<{ $fromDonate?: boolean | null }>` color: ${props => props.$fromDonate ? brandColors.pinky[500] : neutralColors.gray[700]}; - text-transform: ${props => (props.$fromDonate ? 'none' : 'uppercase')}; + text-transform: ${props => (props.$fromDonate ? 'none' : '')}; margin: 0 auto; `; diff --git a/src/components/views/project/ProjectBadges.tsx b/src/components/views/project/ProjectBadges.tsx index b6047975e0..bd2ff72ef5 100644 --- a/src/components/views/project/ProjectBadges.tsx +++ b/src/components/views/project/ProjectBadges.tsx @@ -17,12 +17,22 @@ import { IconWithTooltip } from '@/components/IconWithToolTip'; const ProjectBadges = () => { const { projectData } = useProjectContext(); - const { verified, isGivbackEligible, qfRounds, campaigns } = - projectData || {}; + const { + verified: projectVerified, + isGivbackEligible, + qfRounds, + campaigns, + } = projectData || {}; const { formatMessage } = useIntl(); const isQF = hasActiveRound(qfRounds); + const verified = projectVerified || isGivbackEligible; - if (!verified && !isQF && (!campaigns || campaigns.length === 0)) { + if ( + !verified && + !isGivbackEligible && + !isQF && + (!campaigns || campaigns.length === 0) + ) { return null; } @@ -92,11 +102,9 @@ const ProjectBadges = () => { }; const CustomFlex = styled(Flex)` - overflow-x: scroll; overflow-y: hidden; white-space: nowrap; - margin-bottom: -3px; - padding-top: 8px; + margin-bottom: 24px; `; export const TooltipContent = styled.div` diff --git a/src/components/views/project/ProjectDevouchBox.tsx b/src/components/views/project/ProjectDevouchBox.tsx index a076c327d2..eab38108c8 100644 --- a/src/components/views/project/ProjectDevouchBox.tsx +++ b/src/components/views/project/ProjectDevouchBox.tsx @@ -38,12 +38,12 @@ const ProjectDevouchBox = () => { {formatMessage({ - id: 'label.devouch.view_this_project', + id: 'label.devouch.title.vouch_this_project', })} {formatMessage({ - id: 'label.devouch.if_you_are_eligible', + id: 'label.devouch.description.vouch_this_project', })}{' '} @@ -62,7 +62,7 @@ const ProjectDevouchBox = () => { > { const isGivbackEligible = projectData?.isGivbackEligible; const { givbackFactor } = projectData || {}; const isOwnerGivbackEligible = isGivbackEligible && isAdmin; - const isOwnerNotVerified = !isVerified && isAdmin; + const isOwnerNotVerified = !isGivbackEligible && isAdmin; const isPublicGivbackEligible = isGivbackEligible && !isAdmin; const isPublicVerifiedNotEligible = isVerified && !isAdmin && !isGivbackEligible; @@ -92,7 +92,35 @@ const ProjectGIVbackToast = () => { const givbackFactorPercent = ((givbackFactor || 0) * 100).toFixed(); - if (isOwnerGivbackEligible) { + if (isPublicGivbackEligible) { + if (givbackFactor !== 0) { + title = formatMessage( + { + id: `${useIntlTitle}verified_public_3`, + }, + { + percent: givbackFactorPercent, + // value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, + }, + ); + } + description = formatMessage( + { + id: `${useIntlDescription}verified_public`, + }, + { + value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, + }, + ); + link = links.GIVPOWER_DOC; + Button = ( + } + /> + ); + } else if (isOwnerGivbackEligible) { if (givbackFactor !== 0) { title = formatMessage( { @@ -224,7 +252,7 @@ const ProjectGIVbackToast = () => { }, { stakeLock: ( - + {formatMessage({ id: 'label.stake_and_lock' })}{' '} ), @@ -242,37 +270,19 @@ const ProjectGIVbackToast = () => { title = formatMessage({ id: `${useIntlTitle}verified_owner_not_eligible`, }); - description = formatMessage({ - id: `${useIntlDescription}verified_owner_not_eligible`, - }); - link = links.GIVPOWER_DOC; - Button = ( - } - /> - ); - } else if (isPublicGivbackEligible) { - if (givbackFactor !== 0) { - title = - formatMessage({ - id: `${useIntlTitle}verified_public_1`, - }) + - Math.round(+(givbackFactor || 0) * 100) + - '%' + - formatMessage({ - id: `${useIntlTitle}verified_public_2`, - }); - } description = formatMessage( { - id: `${useIntlDescription}verified_public`, + id: `${useIntlDescription}verified_owner_not_eligible`, }, { - value: GIVBACKS_DONATION_QUALIFICATION_VALUE_USD, + stakeLock: ( + + {formatMessage({ id: 'label.stake_and_lock' })}{' '} + + ), }, ); + link = links.GIVPOWER_DOC; Button = ( = () => { orgLabel={projectData?.organization?.label} /> - + {isMobile && isAdmin && ( = () => { )} - + {isDraft && ( diff --git a/src/components/views/project/projectActionCard/ProjectActionCard.tsx b/src/components/views/project/projectActionCard/ProjectActionCard.tsx index 8850874513..9e6372df0d 100644 --- a/src/components/views/project/projectActionCard/ProjectActionCard.tsx +++ b/src/components/views/project/projectActionCard/ProjectActionCard.tsx @@ -2,11 +2,8 @@ import { mediaQueries, neutralColors, Flex, - Subline, brandColors, - IconChevronRight16, } from '@giveth/ui-design-system'; -import Link from 'next/link'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { ProjectStats } from './ProjectStats'; @@ -18,7 +15,6 @@ import MobileDonateFooter from './MobileDonateFooter'; import QFSection from './QFSection'; import { DonateSection } from './DonationSection'; import { ProjectPublicActions } from './ProjectPublicActions'; -import Routes from '@/lib/constants/Routes'; export const ProjectActionCard = () => { const isMobile = !useMediaQuery(device.tablet); @@ -34,7 +30,7 @@ export const ProjectActionCard = () => { return ( @@ -57,20 +53,6 @@ const ProjectActionInnerCard = () => { )} {!isMobile && !isAdmin && } {isAdmin && } - - - - {formatMessage({ - id: 'label.learn_more_about_donating_on_giveth', - })} - - - - ); }; diff --git a/src/components/views/project/projectActionCard/ProjectPublicActions.tsx b/src/components/views/project/projectActionCard/ProjectPublicActions.tsx index da97d83148..0d9fcc8724 100644 --- a/src/components/views/project/projectActionCard/ProjectPublicActions.tsx +++ b/src/components/views/project/projectActionCard/ProjectPublicActions.tsx @@ -149,7 +149,7 @@ export const ProjectPublicActions = () => { {reaction?.userId && reaction?.userId === user?.id ? ( ) : ( - + )} diff --git a/src/components/views/project/projectActionCard/ProjectStats.tsx b/src/components/views/project/projectActionCard/ProjectStats.tsx index 1ceb6644e2..bbdd203fad 100644 --- a/src/components/views/project/projectActionCard/ProjectStats.tsx +++ b/src/components/views/project/projectActionCard/ProjectStats.tsx @@ -68,7 +68,7 @@ export const ProjectStats = () => { diff --git a/src/components/views/project/projectActionCard/QFSection.tsx b/src/components/views/project/projectActionCard/QFSection.tsx index 18e11b18c6..352e987be3 100644 --- a/src/components/views/project/projectActionCard/QFSection.tsx +++ b/src/components/views/project/projectActionCard/QFSection.tsx @@ -138,7 +138,7 @@ const QFSection: FC = ({ projectData }) => { ); return ( - + {isOnDonatePage && ( <> @@ -302,7 +302,6 @@ const Amount = styled(H3)` const Description = styled(Caption)` color: ${neutralColors.gray[700]}; - margin-bottom: 24px; white-space: nowrap; & > div { color: ${neutralColors.gray[900]}; diff --git a/src/components/views/project/projectDonations/ProjectRecurringDonationTable.tsx b/src/components/views/project/projectDonations/ProjectRecurringDonationTable.tsx index c2401362a1..087fa11487 100644 --- a/src/components/views/project/projectDonations/ProjectRecurringDonationTable.tsx +++ b/src/components/views/project/projectDonations/ProjectRecurringDonationTable.tsx @@ -31,7 +31,7 @@ import { ONE_MONTH_SECONDS } from '@/lib/constants/constants'; import ExternalLink from '@/components/ExternalLink'; import { ChainType } from '@/types/config'; import NetworkLogo from '@/components/NetworkLogo'; -import { EOrderBy } from '../../userProfile/UserProfile.view'; +import { EOrderBy } from '../../userProfile/projectsTab/type'; const itemPerPage = 10; diff --git a/src/components/views/project/projectGIVPower/index.tsx b/src/components/views/project/projectGIVPower/index.tsx index b6cba48fef..3f9113b93e 100644 --- a/src/components/views/project/projectGIVPower/index.tsx +++ b/src/components/views/project/projectGIVPower/index.tsx @@ -28,7 +28,6 @@ const ProjectGIVPowerIndex: FC = () => { const { isBoostingsLoading, boostersData, projectData } = useProjectContext(); const hasGivPower = boostersData ? boostersData.totalCount > 0 : false; - if (isBoostingsLoading) return ; return hasGivPower ? ( diff --git a/src/components/views/userProfile/UserProfile.view.tsx b/src/components/views/userProfile/UserProfile.view.tsx index e84d4898b9..9235c4b532 100644 --- a/src/components/views/userProfile/UserProfile.view.tsx +++ b/src/components/views/userProfile/UserProfile.view.tsx @@ -29,7 +29,6 @@ import { isUserRegistered, shortenAddress, } from '@/lib/helpers'; -import { EDirection } from '@/apollo/types/gqlEnums'; import ExternalLink from '@/components/ExternalLink'; import IncompleteProfileToast from '@/components/views/userProfile/IncompleteProfileToast'; import { useAppDispatch, useAppSelector } from '@/features/hooks'; @@ -45,18 +44,6 @@ import { IGiverPFPToken } from '@/apollo/types/types'; import { useProfileContext } from '@/context/profile.context'; import { useGeneralWallet } from '@/providers/generalWalletProvider'; -export enum EOrderBy { - TokenAmount = 'TokenAmount', - UsdAmount = 'UsdAmount', - CreationDate = 'CreationDate', - Donations = 'Donations', -} - -export interface IOrder { - by: EOrderBy; - direction: EDirection; -} - export interface IUserProfileView {} const UserProfileView: FC = () => { diff --git a/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeDonationsTable.tsx b/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeDonationsTable.tsx index 5535169b73..0d60ef0e2e 100644 --- a/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeDonationsTable.tsx +++ b/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeDonationsTable.tsx @@ -13,10 +13,6 @@ import { smallFormatDate, formatTxLink } from '@/lib/helpers'; import { slugToProjectView } from '@/lib/routeCreators'; import ExternalLink from '@/components/ExternalLink'; import { IWalletDonation } from '@/apollo/types/types'; -import { - EOrderBy, - IOrder, -} from '@/components/views/userProfile/UserProfile.view'; import SortIcon from '@/components/SortIcon'; import DonationStatus from '@/components/badges/DonationStatusBadge'; import { @@ -27,6 +23,7 @@ import { import { Badge, EBadgeStatus } from '@/components/Badge'; import { formatDonation } from '@/helpers/number'; import NetworkLogo from '@/components/NetworkLogo'; +import { EOrderBy, IOrder } from '../../projectsTab/type'; interface OneTimeDonationTable { donations: IWalletDonation[]; diff --git a/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeTab.tsx b/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeTab.tsx index 4d5c713b58..7414084bd3 100644 --- a/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeTab.tsx +++ b/src/components/views/userProfile/donationsTab/oneTimeTab/OneTimeTab.tsx @@ -10,7 +10,7 @@ import { IWalletDonation } from '@/apollo/types/types'; import Pagination from '@/components/Pagination'; import NothingToSee from '@/components/views/userProfile/NothingToSee'; import DonationTable from '@/components/views/userProfile/donationsTab/oneTimeTab/OneTimeDonationsTable'; -import { IOrder, EOrderBy } from '../../UserProfile.view'; +import { EOrderBy, IOrder } from '../../projectsTab/type'; import { useProfileContext } from '@/context/profile.context'; import { WrappedSpinner } from '@/components/Spinner'; diff --git a/src/components/views/userProfile/projectsTab/DeleteProjectModal.tsx b/src/components/views/userProfile/projectsTab/DeleteProjectModal.tsx index edece33f41..04ffef2c7e 100644 --- a/src/components/views/userProfile/projectsTab/DeleteProjectModal.tsx +++ b/src/components/views/userProfile/projectsTab/DeleteProjectModal.tsx @@ -1,22 +1,55 @@ import styled from 'styled-components'; -import { type FC } from 'react'; +import { useState, type FC } from 'react'; import { Button, Flex, IconTrash32, P } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; +import { useMutation } from '@tanstack/react-query'; import { IProject } from '@/apollo/types/types'; import { Modal } from '@/components/modals/Modal'; import { IModal } from '@/types/common'; import { useModalAnimation } from '@/hooks/useModalAnimation'; +import { client } from '@/apollo/apolloClient'; +import { DELETE_DRAFT_PROJECT } from '@/apollo/gql/gqlProjects'; +import { useAppDispatch } from '@/features/hooks'; +import { fetchUserByAddress } from '@/features/user/user.thunks'; +import { useGeneralWallet } from '@/providers/generalWalletProvider'; interface IDeleteProjectModal extends IModal { project: IProject; + refetchProjects: () => void; } const DeleteProjectModal: FC = ({ setShowModal, project, + refetchProjects, }) => { + const [isLoading, setIsLoading] = useState(false); const { formatMessage } = useIntl(); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const dispatch = useAppDispatch(); + const { walletAddress } = useGeneralWallet(); + + const { mutate: deleteProject, isPending } = useMutation({ + mutationFn: (projectId: number) => + client.mutate({ + mutation: DELETE_DRAFT_PROJECT, + variables: { projectId: projectId }, + }), + onSuccess: async () => { + setIsLoading(true); + await refetchProjects(); + walletAddress && + (await dispatch(fetchUserByAddress(walletAddress))); + setIsLoading(false); + closeModal(); + }, + }); + + const handleRemoveProject = async () => { + deleteProject(Number(project.id)); + }; + + const loading = isPending || isLoading; return ( = ({ id: 'component.delete_project.yes', })} size='small' - onClick={() => setShowModal(true)} + onClick={handleRemoveProject} + loading={loading} />