Skip to content

Commit

Permalink
update call api
Browse files Browse the repository at this point in the history
  • Loading branch information
Quyenld9699 committed Aug 22, 2024
1 parent 29cb419 commit 378d9e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions lib/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function filterDataCampaign(item: any): Campaign {
banner: item.ipfsData?.coverImage || '',
state: state,
organizer: {
address: item?.ownerInfo?.address || '',
avatar: item?.ownerInfo?.img || '',
name: item?.ownerInfo?.name || 'Unnkown Name',
address: item?.founderInfo?.address || '',
avatar: item?.founderInfo?.img || '',
name: item?.founderInfo?.name || 'Unnkown Name',
},
description: item.ipfsData?.description || '',
timeline: timeLine,
Expand Down Expand Up @@ -113,7 +113,7 @@ function filterDataCampaignFundraising(campaign: any, dataJoinCampaign: any): Ca
scopeOfWorks: dataJoinCampaign.ipfsData?.scopeOfWorks || [],
questions: campaign?.ipfsData?.questions || [],
answers: dataJoinCampaign.ipfsData?.answers || [],
ownerAddress: campaign?.owner || '',
ownerAddress: campaign?.founder || '',
timeline: {
startParticipation: campaign?.ipfsData?.timeline?.startParticipation || '',
startFunding: campaign?.ipfsData?.timeline?.startFunding || '',
Expand All @@ -123,12 +123,11 @@ function filterDataCampaignFundraising(campaign: any, dataJoinCampaign: any): Ca
tokenFunding: campaign?.ipfsData?.tokenFunding || { address: '0x00', decimals: 0, symbol: '', name: '0x00' },
};
}
export async function getFundraisingInfoByProjectId(projectId: string, governorAddress: Address, client: AppPublicClient): Promise<CampaignFundraising[]> {
// const response = await axios.get(apiUrl.getFundraisingInfoByProjectId(projectId));
export async function getFundraisingInfoByProjectId(governorAddress: Address): Promise<CampaignFundraising[]> {
const joinedCampaigns = (await axios.get(apiUrl.getFundraisingInfoByProjectId(governorAddress))).data;
// console.log('getCampaignsJoinedByProjectId', response);
const listIdJoinedCampaign = await getJoinedCampaigns(client, governorAddress);
const response = await Promise.all(listIdJoinedCampaign.map((idCampaign) => getFundraisingInfoOfProjectInCampaign(projectId, idCampaign.toString())));
return response;
const campaigns = await Promise.all(joinedCampaigns.map((data: any) => axios.get(apiUrl.campaign + `/${data.campaignId}`)));
return joinedCampaigns.map((data: any, index: number) => filterDataCampaignFundraising(campaigns[index], data));
}

export async function getFundraisingInfoOfProjectInCampaign(projectId: string, campaignId: string): Promise<CampaignFundraising> {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/apiUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const apiUrl = {
getListProjectJoinedInCampaign: (campaignId: string) => `${BACKEND_BASE_URL}/campaigns/${campaignId}/projects`, // ? return list project that joined campaign
ifpsHashCreateCourse: `${BACKEND_BASE_URL1}/builders/create-course-ipfs-hash`,

getFundraisingInfoByProjectId: (projectId: string) => `${BACKEND_BASE_URL}/projects/${projectId}/participations`, // ? return campaign that project joined
getFundraisingInfoByProjectId: (governorAddress: string) => `${BACKEND_BASE_URL1}/non-privacy/governors/joined-campaigns?governorAddress=${governorAddress}`, // ? return campaign that project joined
getFundraisingInfoOfProjectInCampaign: (projectId: string, campaignId: string) => `${BACKEND_BASE_URL}/projects/${projectId}/participations/${campaignId}`, // ? return campaign and info mileton that project joined
campaign: `${BACKEND_BASE_URL1}/non-privacy/campaigns`,
ipfsHashJoinCampaign: `${BACKEND_BASE_URL1}/non-privacy/campaigns/create-join-campaign-ipfs-hash`,
Expand Down

0 comments on commit 378d9e2

Please sign in to comment.