-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement different statuses fix test fix icon color fix collection size (#3723) * fix collection size * fix height * slice string * add description to collection details * add cols * edit slice length * remove log added copy functionality to project owner address on ViewProjectDetails page. (#3724) * added copy functionality * Update package.json add verified filter
- Loading branch information
Showing
13 changed files
with
237 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
export type WhitelistStatus = "Accepted" | "Rejected" | "Pending"; | ||
|
||
interface ProgramData { | ||
programId: string; | ||
whitelistStatus: WhitelistStatus; | ||
} | ||
|
||
async function fetchProgramsData(): Promise<ProgramData[]> { | ||
try { | ||
const response = await fetch( | ||
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQxC34V_N3ubt3ycs7LvMya_zYeBmAqTxPczt0yDbLSfpI-kMp6o5E08fC0BxQG4uMp7EPV5bxP-64a/pub?gid=0&single=true&output=csv" | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
const csvText = await response.text(); | ||
|
||
const stringArray = csvText | ||
.split(/\r?\n/) | ||
.filter((line) => line.trim() !== ""); | ||
|
||
const programsData = stringArray.map((line) => { | ||
const [programId, whitelistStatus] = line.split(",") as [ | ||
string, | ||
WhitelistStatus, | ||
]; | ||
return { programId, whitelistStatus }; | ||
}); | ||
|
||
return programsData; | ||
} catch (error) { | ||
console.error("Failed to fetch or process the CSV:", error); | ||
return []; | ||
} | ||
} | ||
|
||
export async function getWhitelistedPrograms(): Promise<string[]> { | ||
const programsData = await fetchProgramsData(); | ||
return programsData | ||
.filter((program) => program.whitelistStatus === "Accepted") | ||
.map((program) => program.programId); | ||
} | ||
|
||
export async function isProgramWhitelisted( | ||
programId: string | ||
): Promise<boolean> { | ||
const whitelistedPrograms = await getWhitelistedPrograms(); | ||
return whitelistedPrograms.includes(programId); | ||
} | ||
|
||
export async function getAllProgramsData(): Promise<ProgramData[]> { | ||
return await fetchProgramsData(); | ||
} | ||
|
||
export async function getProgramWhitelistStatus( | ||
programId: string | ||
): Promise<WhitelistStatus | null> { | ||
const programsData = await fetchProgramsData(); | ||
const program = programsData.find( | ||
(program) => program.programId === programId | ||
); | ||
return program ? program.whitelistStatus : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.