Skip to content

Commit

Permalink
Merge branch 'develop' into fix/email_verify_notification
Browse files Browse the repository at this point in the history
  • Loading branch information
kkatusic authored Jan 29, 2025
2 parents b08e68a + 96b3b45 commit a1c6b4a
Show file tree
Hide file tree
Showing 22 changed files with 309 additions and 125 deletions.
2 changes: 2 additions & 0 deletions lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"component.pro_guide.tips.social_media.item3": "Giveth podria utilitzar els teus noms d'usuari a les xarxes socials per contactar-te o etiquetar-te en publicacions per suportar la teva recaptació de fons.",
"component.qf-section.tooltip": "Aquesta estimació és els fons d'emparellament que aquest projecte rebrà si la ronda acabés ara, sense tenir en compte l'anàlisi de frau.",
"component.qf-section.tooltip_polygon": "Aquesta estimació representa els fons coincidents que rebria aquest projecte si la ronda es tanqués ara, ignorant l'anàlisi del frau.",
"component.qf-section.estimated_time": "Càlcul de coincidència actualitzat fa {time} minuts",
"component.qf_middle_banner.desc": " Amb FQ, el nombre de donants compta més que la quantitat donada. Dona als projectes participants en la ronda i aconsegueix que les teves donacions siguin emparellades amb el poder del finançament quadràtic!",
"component.qf_middle_banner.title": "Finançament Quadràtic",
"component.regenstream_card.harvest_caption": "Utilitza el botó de Recollida per reclamar recompenses líquides d'aquest RegenStream",
Expand Down Expand Up @@ -556,6 +557,7 @@
"label.how_do_you_want_to_donate": "Com vols donar?",
"label.how_it_works": "Com Funciona",
"label.how_it_works?": "Com funciona?",
"label.last_updated_ago": "Última actualització: fa {time} minuts",
"label.how_referrals_work": "Com funcionen les referències",
"label.how_to_buy": "Com comprar",
"label.how_to_refer_your_friends": "Com referir als teus amics",
Expand Down
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"component.pro_guide.tips.social_media.item3": "Giveth might use your social media handles to contact you or tag you on posts to support your fundraising.",
"component.qf-section.tooltip": "This estimation is the matching funds that this project would get if the round ended now, disregarding fraud analysis.",
"component.qf-section.tooltip_polygon": "This estimate represents the matching funds this project would receive if the round closed now, ignoring the fraud analysis.",
"component.qf-section.estimated_time": "Estimated matching updated {time} min ago",
"component.qf_middle_banner.desc": "With QF, the number of donors matters more than the amout donated. Donate to participating projects in the round and get your donations matched with the power of quadratic funding!",
"component.qf_middle_banner.title": "Quadratic Funding",
"component.regenstream_card.harvest_caption": "Use the Harvest button to claim liquid rewards from this RegenStream",
Expand Down Expand Up @@ -556,6 +557,7 @@
"label.how_do_you_want_to_donate": "How do you want to donate?",
"label.how_it_works": "How It Works",
"label.how_it_works?": "How it works?",
"label.last_updated_ago": "Last updated: {time} min ago",
"label.how_referrals_work": "How referrals work",
"label.how_to_buy": "How to buy",
"label.how_to_refer_your_friends": "How to refer your friends",
Expand Down
2 changes: 2 additions & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"component.pro_guide.tips.social_media.item3": "Giveth podría usar tus identificadores de redes sociales para contactarte o etiquetarte en publicaciones para apoyar tu recaudación de fondos.",
"component.qf-section.tooltip": "Esta estimación es la cantidad de fondos complementarios que este proyecto recibiría si la ronda terminara ahora, sin tener en cuenta el análisis de fraude.",
"component.qf-section.tooltip_polygon": "Esta estimación representa los fondos de contrapartida que recibiría este proyecto si la ronda se cerrara ahora, ignorando el análisis de fraude.",
"component.qf-section.estimated_time": "Cálculo de coincidencias actualizado hace {time} minutos",
"component.qf_middle_banner.desc": "Con FC, el número de donantes importa más que la cantidad donada. ¡Dona a los proyectos participantes en la ronda y obtén tus donaciones emparejadas con el poder de la financiación cuadrática!",
"component.qf_middle_banner.title": "Financiación Cuadrática",
"component.regenstream_card.harvest_caption": "Utiliza el botón de Cosecha para reclamar recompensas líquidas de este RegenStream",
Expand Down Expand Up @@ -554,6 +555,7 @@
"label.how_do_you_want_to_donate": "¿Cómo quieres donar?",
"label.how_it_works": "Cómo Funciona",
"label.how_it_works?": "¿Cómo funciona?",
"label.last_updated_ago": "Última actualización: hace {time} minutos",
"label.how_referrals_work": "Cómo funcionan las referencias",
"label.how_to_buy": "Cómo comprar",
"label.how_to_refer_your_friends": "Como referir a tus amigos",
Expand Down
109 changes: 26 additions & 83 deletions pages/api/generate-sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ import fs from 'fs';
import path from 'path';
import { NextApiRequest, NextApiResponse } from 'next';
import { User } from '@sentry/types';
import { initializeApollo } from '@/apollo/apolloClient';
import { OPTIONS_HOME_PROJECTS } from '@/apollo/gql/gqlOptions';
import { FETCH_ALL_PROJECTS } from '@/apollo/gql/gqlProjects';
import { EProjectsSortBy } from '@/apollo/types/gqlEnums';
import { getMainCategorySlug } from '@/helpers/projects';
import { escapeXml } from '@/helpers/xml';
import { IProject, IQFRound } from '@/apollo/types/types';
import { FETCH_QF_ROUNDS_QUERY } from '@/apollo/gql/gqlQF';
import { FETCH_ALL_USERS_BASIC_DATA } from '@/apollo/gql/gqlUser';
import { addressToUserView } from '@/lib/routeCreators';
import { shortenAddress } from '@/lib/helpers';

export const config = {
maxDuration: 300,
api: {
bodyParser: {
sizeLimit: '10mb',
},
},
};

const URL = process.env.NEXT_PUBLIC_FRONTEND_LINK;
Expand Down Expand Up @@ -112,8 +109,10 @@ export default async function handler(
) {
const authHeader = req.headers['authorization'];

console.log('API route /api/generate-sitemap was called');

// Only allow GET requests
if (req.method !== 'GET') {
if (req.method !== 'POST') {
return res.status(405).end();
}

Expand All @@ -122,18 +121,15 @@ export default async function handler(
}

try {
/* PROJECT SITEMAP */
// Parse the POST data from the request body
const { projects, users, qfRounds } = req.body;

// Get first project data
const projectData = await getProjects(0);

const projects: IProject[] = projectData.allProjects?.projects || [];
/* PROJECT SITEMAP */

if (projectData.allProjects.totalCount > 50) {
for (let i = 50; i < projectData.allProjects.totalCount; i += 50) {
const fetchNewProjectData = await getProjects(i);
projects.push(...fetchNewProjectData.allProjects?.projects);
}
if (!projects || !Array.isArray(projects)) {
return res
.status(400)
.json({ message: 'Invalid request payload projects' });
}

// Generate XML content
Expand All @@ -152,11 +148,14 @@ export default async function handler(

/* QF ARCHIVED ROUNDS SITEMAP */

// Get first project data
const roundsData = await getArchivedRounds();
if (!qfRounds || !Array.isArray(qfRounds)) {
return res
.status(400)
.json({ message: 'Invalid request payload qfRounds' });
}

// // Generate XML content
const sitemapRoundsContent = generateQFRoundsSiteMap(roundsData);
const sitemapRoundsContent = generateQFRoundsSiteMap(qfRounds);

// Define the file path
const filePathQFRounds = path.join(
Expand All @@ -175,21 +174,14 @@ export default async function handler(

/* USER SITEMAP */

// Fetch user data
const users = await getUsers(0);
const userTotalCount = users.totalCount;
const userEntries = [...users.users];

// Fetch remaining users if necessary
if (userTotalCount > 50) {
for (let i = 50; i < userTotalCount; i += 50) {
const nextBatch = await getUsers(i);
userEntries.push(...nextBatch.users);
}
if (!users || !Array.isArray(users)) {
return res
.status(400)
.json({ message: 'Invalid request payload users' });
}

// Generate XML content for users
const sitemapUsersContent = generateUsersSiteMap(userEntries);
const sitemapUsersContent = generateUsersSiteMap(users);

// Define the file path for users sitemap
const filePathUsers = path.join(
Expand All @@ -215,52 +207,3 @@ export default async function handler(
res.status(500).json({ error: 'Failed to generate sitemap' });
}
}

// Fetch project data from GraphQL
async function getProjects(skip: number) {
const apolloClient = initializeApollo();
const slug = 'all';
const { variables, notifyOnNetworkStatusChange } = OPTIONS_HOME_PROJECTS;

const { data } = await apolloClient.query({
query: FETCH_ALL_PROJECTS,
variables: {
...variables,
limit: 50,
skip: skip,
sortingBy: EProjectsSortBy.INSTANT_BOOSTING,
mainCategory: getMainCategorySlug({ slug }),
notifyOnNetworkStatusChange,
},
fetchPolicy: 'no-cache',
});

return data;
}

// Fetch qf archived rounds data from GraphQL
async function getArchivedRounds() {
const apolloClient = initializeApollo();

const { data } = await apolloClient.query({
query: FETCH_QF_ROUNDS_QUERY,
});

return data.qfRounds || [];
}

// Fetch user data from GraphQL
async function getUsers(skip: number) {
const apolloClient = initializeApollo();

const { data } = await apolloClient.query({
query: FETCH_ALL_USERS_BASIC_DATA, // Query for user data
variables: {
limit: 50,
skip: skip,
},
fetchPolicy: 'no-cache',
});

return data.allUsersBasicData || { users: [], totalCount: 0 };
}
11 changes: 11 additions & 0 deletions public/images/icons/clock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/apollo/gql/gqlProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const PROJECT_CORE_FIELDS = gql`
allocatedFundUSDPreferred
allocatedFundUSD
qfStrategy
clusterMatchingSyncAt
}
}
`;
Expand Down Expand Up @@ -197,6 +198,7 @@ export const FETCH_PROJECT_BY_SLUG_DONATION = gql`
allocatedFundUSD
minimumValidUsdValue
qfStrategy
clusterMatchingSyncAt
}
anchorContracts {
address
Expand Down Expand Up @@ -294,6 +296,7 @@ export const FETCH_PROJECT_BY_SLUG_SINGLE_PROJECT = gql`
allocatedFundUSDPreferred
allocatedFundUSD
qfStrategy
clusterMatchingSyncAt
}
campaigns {
id
Expand Down
1 change: 1 addition & 0 deletions src/apollo/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ export interface IQFRound {
minimumValidUsdValue?: number;
minMBDScore: number;
qfStrategy: QfStrategyEnum;
clusterMatchingSyncAt: string;
}

export interface IArchivedQFRound extends IQFRound {
Expand Down
4 changes: 2 additions & 2 deletions src/components/AmountInput/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const AmountInput: FC<IAmountInput> = ({
const isZero = regex.test(displayAmount);
if (amount === 0n && isZero) return;

const maxDecimals = decimals === 8 ? 8 : decimals / 3;
const maxDecimals = decimals === 8 ? 6 : decimals / 3;

const _displayAmount = truncateToDecimalPlaces(
formatUnits(amount, decimals),
Expand Down Expand Up @@ -80,7 +80,7 @@ export const AmountInput: FC<IAmountInput> = ({

// Allow more decimals if token has 8 decimals
if (decimals === 8) {
if (_decimals?.length > 8) return; // Limit to 8 decimals
if (_decimals?.length > 6) return; // Limit to 8 decimals
} else {
if (_decimals?.length > decimals / 3) return; // Limit to 6 or 2 decimals for other tokens
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/modals/HarvestAll.sc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const HarvestAllPending = styled(Pending)`

export const TooltipContent = styled(Subline)`
${mediaQueries.tablet} {
width: 200px;
width: 250px;
text-align: left;
}
`;

Expand Down
38 changes: 38 additions & 0 deletions src/components/project-card/ProjectCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import Image from 'next/image';
import {
P,
H6,
Expand Down Expand Up @@ -36,6 +37,7 @@ import { TooltipContent } from '@/components/modals/HarvestAll.sc';
import { IconWithTooltip } from '@/components/IconWithToolTip';
import { FETCH_RECURRING_DONATIONS_BY_DATE } from '@/apollo/gql/gqlProjects';
import { client } from '@/apollo/apolloClient';
import { calculateQFTimeDifferences } from '@/helpers/time';

const cardRadius = '12px';
const imgHeight = '226px';
Expand Down Expand Up @@ -106,8 +108,13 @@ const ProjectCard = (props: IProjectCard) => {
allocatedFundUSD,
allocatedTokenSymbol,
qfStrategy,
clusterMatchingSyncAt,
} = activeQFRound || {};

const clusterMatchingSyncAtDiff = calculateQFTimeDifferences(
clusterMatchingSyncAt || '',
);

const projectLink = slugToProjectView(slug);
const donateLink = slugToProjectDonate(slug);

Expand Down Expand Up @@ -330,6 +337,24 @@ const ProjectCard = (props: IProjectCard) => {
{formatMessage({
id: 'component.qf-section.tooltip_polygon',
})}
<ToolTipBellow>
<Image
src={
'/images/icons/clock.svg'
}
alt='score'
width={16}
height={16}
/>
{formatMessage(
{
id: 'component.qf-section.estimated_time',
},
{
time: clusterMatchingSyncAtDiff,
},
)}
</ToolTipBellow>
</TooltipContent>
</IconWithTooltip>
</EstimatedMatching>
Expand Down Expand Up @@ -593,4 +618,17 @@ const QFBadge = styled(Subline)`
align-items: center;
`;

const ToolTipBellow = styled.div`
display: flex;
align-items: center;
justify-content: flex-start;
border-top: 1px solid #121848;
margin: 7px 0;
padding: 7px 0 0 0;
line-height: 16px;
& img {
margin: 0 6px 0 0;
}
`;

export default ProjectCard;
19 changes: 17 additions & 2 deletions src/components/views/donate/DonateHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ import { useDonateData } from '@/context/donate.context';
import { EScrollDir, useScrollDetection } from '@/hooks/useScrollDetection';
import { useGeneralWallet } from '@/providers/generalWalletProvider';
import { setShowWelcomeModal } from '@/features/modal/modal.slice';
import { getActiveRound } from '@/helpers/qf';

export interface IHeader {
theme?: ETheme;
show?: boolean;
isSuccessDonation?: boolean;
}

export const DonateHeader: FC<IHeader> = () => {
export const DonateHeader: FC<IHeader> = props => {
const { isSuccessDonation } = props;
const theme = useAppSelector(state => state.general.theme);
const { formatMessage } = useIntl();
const { walletAddress } = useGeneralWallet();
Expand All @@ -44,14 +47,26 @@ export const DonateHeader: FC<IHeader> = () => {

const isGIVeconomyRoute = checkIsGIVeconomyRoute(router.route);

let routePath = Routes.Project + '/' + project.slug;

// Change route if donation done successfully
if (isSuccessDonation) {
const { qfRounds } = project;
const { activeQFRound } = getActiveRound(qfRounds);

const isActiveQF = activeQFRound?.isActive;

routePath = isActiveQF ? Routes.AllQFProjects : Routes.AllProjects;
}

return (
<StyledHeader
$alignItems='center'
$baseTheme={theme}
$show={scrollDir !== EScrollDir.Down}
>
<Flex $alignItems='center' gap='16px'>
<Link href={Routes.Project + '/' + project.slug}>
<Link href={routePath}>
<Logo>
<Image
width='26'
Expand Down
Loading

0 comments on commit a1c6b4a

Please sign in to comment.