-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[FEAT] Github connection with payouts #756
Conversation
WalkthroughThe pull request introduces several enhancements to the codebase, including the addition of a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Vault
participant GitHubAPI
participant SubmissionService
participant SubmissionCard
User->>Vault: Selects a vault
Vault->>SubmissionService: Fetch GitHub issues
SubmissionService->>GitHubAPI: Request issues for vault
GitHubAPI-->>SubmissionService: Return issues
SubmissionService-->>Vault: Send issues
Vault-->>SubmissionCard: Pass issues
SubmissionCard->>User: Display submission and GitHub issue info
Tip Announcements
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review due to trivial changes (1)
Additional comments not posted (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying dapp with
|
Latest commit: |
d10c406
|
Status: | ✅ Deploy successful! |
Preview URL: | https://d1b0bf44.dapp-a9y.pages.dev |
Branch Preview URL: | https://feat-better-payouts.dapp-a9y.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Outside diff range, codebase verification and nitpick comments (2)
packages/web/src/hooks/vaults/useUserVaults.tsx (1)
76-78
: Sorting function implemented correctly.The sorting function correctly organizes the
foundVaults
array in descending order based on thestarttime
. To improve code readability and maintainability, consider adding a comment explaining the defaulting to0
for undefinedstarttime
.+ // Sort vaults by `starttime` in descending order, defaulting to 0 if undefined
packages/shared/src/types/payout.ts (1)
45-55
: New typeGithubIssue
defined correctly.The
GithubIssue
type is well-defined with all necessary properties to represent GitHub issues in the payout system. Consider adding documentation comments to each property for better clarity and maintainability.+ /** + * Represents a GitHub issue in the payout system. + * @property {number} id - The unique identifier for the GitHub issue. + * @property {number} number - The issue number on GitHub. + * @property {string} title - The title of the issue. + * @property {number} createdBy - The user ID of the issue creator. + * @property {string[]} labels - Labels associated with the issue. + * @property {string[]} validLabels - Labels that are considered valid for processing. + * @property {string} createdAt - The creation date of the issue. + * @property {string} body - The body text of the issue. + * @property {string} [txHash] - Optional transaction hash linking the issue to a blockchain transaction. + */
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (17)
- packages/shared/src/types/payout.ts (3 hunks)
- packages/web/src/components/FormControls/FormSelectInput/FormSelectInput.tsx (3 hunks)
- packages/web/src/components/FormControls/FormSelectInput/styles.ts (1 hunks)
- packages/web/src/constants/constants.ts (1 hunks)
- packages/web/src/hooks/vaults/useUserVaults.tsx (1 hunks)
- packages/web/src/languages/en.json (2 hunks)
- packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutFormPage/forms/SinglePayout/SinglePayoutForm.tsx (4 hunks)
- packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx (4 hunks)
- packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionDetailsPage/SubmissionDetailsPage.tsx (4 hunks)
- packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx (3 hunks)
- packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionsListPage.tsx (15 hunks)
- packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/styles.ts (5 hunks)
- packages/web/src/pages/CommitteeTools/SubmissionsTool/submissionsService.api.ts (2 hunks)
- packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultScopeSection/InScopeSection/InScopeSection.tsx (2 hunks)
- packages/web/src/pages/VaultEditor/VaultEditorFormPage/SetupSteps/shared/VaultCuratorForm/VaultCuratorForm.tsx (1 hunks)
- packages/web/src/settings.ts (1 hunks)
- packages/web/src/utils/slug.utils.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- packages/web/src/settings.ts
Additional comments not posted (32)
packages/web/src/components/FormControls/FormSelectInput/styles.ts (1)
28-34
: Approve the addition ofspan.helper
style.The new CSS rules for
span.helper
are clear and well-defined, enhancing the visual presentation of helper text within theStyledFormSelectInput
component. The use of CSS variables for colors and spacing ensures consistency with the rest of the application's styling.packages/web/src/pages/VaultEditor/VaultEditorFormPage/SetupSteps/shared/VaultCuratorForm/VaultCuratorForm.tsx (1)
59-59
: Approve the addition of thehelper
property with a suggestion for verification.The implementation of the
helper
property in theFormSelectInput
component is well-done, enhancing the user experience by providing contextual information based on the selected curator. However, ensure that theaddresses
array is always populated for all curators to avoid displaying undefined or incorrect information.Consider adding a check or handling cases where the
addresses
array might be empty:helper={curators?.find((c) => c.username === selectedCurator)?.addresses?.[0] || 'No address available'}packages/web/src/constants/constants.ts (1)
12-12
: New constant added correctly.The addition of
SelectedVaultInSubmissions
to theLocalStorage
enum is correctly implemented and follows the established naming conventions.packages/shared/src/types/payout.ts (2)
79-79
: Integration ofghIssue
intoISinglePayoutData
is appropriate.The optional property
ghIssue
enhances the data structure by allowing the inclusion of GitHub issue details, which is crucial for linking payouts to specific GitHub activities.
105-105
: Integration ofghIssue
intoISplitPayoutBeneficiary
is appropriate.This integration allows for detailed data representation in split payouts, linking specific GitHub issues to payout beneficiaries.
packages/web/src/components/FormControls/FormSelectInput/FormSelectInput.tsx (2)
21-21
: Approved addition ofhelper
property.The addition of the
helper
property to theFormSelectInputProps
interface is correctly implemented and aligns with the PR objectives to enhance user experience by providing additional context.
56-56
: Approved modification in function signature.The inclusion of
helper
in theFormSelectInputComponent
function signature is correctly implemented, enabling the use of this property within the component.packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionCard.tsx (3)
21-21
: Approved addition ofghIssue
property.The addition of the
ghIssue
property to theSubmissionCardProps
type is correctly implemented, enabling the component to display GitHub issue information alongside submission details.
27-27
: Approved modification in function signature.The inclusion of
ghIssue
in theSubmissionCard
function signature is correctly implemented, enabling the use of this property within the component to display GitHub issue information.
70-90
: Approved conditional rendering of GitHub issue information.The conditional rendering of GitHub issue information in the
SubmissionCard
is correctly implemented. It enhances the component's functionality by allowing it to display relevant GitHub issue data alongside submission details.packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionDetailsPage/SubmissionDetailsPage.tsx (5)
25-32
: Approved addition of state variables and use ofuseVaults
hook.The introduction of the
vaultGithubIssues
andisLoadingGH
state variables, along with the use of theuseVaults
hook, is correctly implemented. These additions are essential for managing the fetching and display of GitHub issues related to vault submissions.
38-53
: Approved new useEffect logic for fetching GitHub issues.The new useEffect logic implemented for fetching GitHub issues is correctly set up. It ensures that GitHub issues are fetched and stored based on the submission's linked vault, aligning with the PR objectives to enhance functionality related to GitHub issue tracking.
108-112
: Approved modification inSubmissionCard
component usage.The update to the
SubmissionCard
component to include theghIssue
prop is correctly implemented. This modification enhances the component's functionality by linking the submission to its corresponding GitHub issue.
140-141
: Approved conditional rendering of loading indicators.The conditional rendering of loading indicators based on the states of vault readiness and GitHub issue loading is correctly implemented. This enhancement improves user feedback during data fetching.
Line range hint
1-141
: Approved overall integration of new functionality.The integration of new functionality related to fetching and displaying GitHub issues in the
SubmissionDetailsPage
is well-implemented. This enhances the component's ability to manage and display relevant data effectively.packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/styles.ts (6)
117-117
: Approved: Full width for controls and controls-row.The changes to set the width of
.controls
and.controls-row
to 100% are appropriate for ensuring that these elements occupy the full width of their container, enhancing the responsiveness of the layout.Also applies to: 129-130
130-130
: Approved: Full width for vaults-filter.Setting the
.vaults-filter
class to have a width of 100% aligns with the design goal of uniform filter widths across the interface.
134-136
: Approved: Right alignment for pagination controls.The addition of
margin-left: auto;
to the.pagination
class effectively aligns the pagination controls to the right, which is a standard practice for such UI elements.
151-153
: Approved: Fixed width for numerical indicators.The fixed width of 15px for the
.number
class helps standardize the appearance of numerical indicators, which is beneficial for maintaining a consistent UI.
186-197
: Approved: Flexbox layout for better alignment and spacing.The introduction of
.flex
and.flex-end
classes utilizes the flexbox layout to improve alignment and spacing of elements, with.flex-end
specifically ensuring right alignment of its contents.
280-289
: Approved: Enhanced visual hierarchy for severity indicators.The
.severity
class within theStyledSubmissionCard
uses a flex container to ensure proper alignment and spacing. The specific styles forspan
elements enhance the visual hierarchy by adjusting font size and weight, which improves clarity and emphasis on severity indicators.packages/web/src/languages/en.json (2)
733-737
: Review of New Localization Keys for GitHub IssuesThe new keys added for GitHub issue management are correctly formatted and seem appropriate for the described functionality. These keys will enhance the user interface by providing clear labels and messages related to GitHub issue handling within the application.
"loadingGithubIssues": "Loading GitHub issues"
- Indicates that GitHub issues are being loaded, which is a necessary feedback for the user."submittedAs": "Submitted as"
- Useful for labeling how issues were submitted."labeledAs": "Labeled as"
- Useful for displaying labels associated with issues."onlyShowLabeledIssues": "Show only labeled issues"
- Provides a filtering option to the user, enhancing usability."ghIssue": "GH issue"
- A concise label for referring to GitHub issues.
1133-1136
: Review of New Localization Keys for Vault ManagementThe newly added keys related to vault management are well-formulated and align with the intended enhancements for vault interaction capabilities:
"filterByVault": "Filter by vault"
- Allows users to filter data or views by specific vaults, which is crucial for navigation and usability in applications dealing with multiple vaults."showAllVaults": "Show all vaults"
- Provides a straightforward option for users wanting to view all vaults, enhancing the application's navigational aspects."goToVaultGithubIssues": "Go to vault GitHub issues"
- This key directly supports the new feature integration, linking vault management with GitHub issues, which is likely part of the feature set described in the PR objectives.These additions are consistent with the PR's goal of enhancing GitHub integration and vault management functionalities.
packages/web/src/pages/CommitteeTools/PayoutsTool/PayoutFormPage/forms/SinglePayout/SinglePayoutForm.tsx (2)
86-87
: State variables correctly initialized.The addition of
vaultGithubIssues
andisLoadingGH
state variables is correctly implemented with appropriate initial values.
122-125
: Correct integration ofghIssue
prop inSubmissionCard
.The
ghIssue
prop is correctly passed to theSubmissionCard
component, enhancing its functionality to display relevant GitHub issue information alongside the submission data.packages/web/src/pages/Honeypots/VaultDetailsPage/Sections/VaultScopeSection/InScopeSection/InScopeSection.tsx (2)
24-24
: Approved import statement for utility function.The import statement correctly imports
getForkedRepoName
fromutils/slug.utils
, which is used to abstract the logic for generating repository names.
73-73
: Refactor improves maintainability by using utility function.The use of
getForkedRepoName(vault)
at line 73 correctly abstracts the logic for generating theforkedRepoName
. This change enhances code readability and maintainability.packages/web/src/pages/CommitteeTools/SubmissionsTool/SubmissionsListPage/SubmissionsListPage.tsx (3)
81-104
: State management for filtering is correctly implemented.The new state variables
vaultFilter
,onlyShowLabeled
, andvaultGithubIssues
are correctly initialized and used to manage the filtering of submissions based on vaults and GitHub issues.
87-102
: Asynchronous function handles user confirmation and navigation correctly.The function
goToFilteredVaultGithubIssues
correctly prompts the user for confirmation before navigating to the GitHub issues page, ensuring a good user experience by preventing unwanted navigation.
130-143
: Expanded filtering logic is effectively implemented.The filtering logic for submissions, implemented using the
useMemo
hook, correctly evaluates conditions based on the selected vault and its associated GitHub issues, effectively refining the data presented to the user.packages/web/src/pages/CommitteeTools/SubmissionsTool/submissionsService.api.ts (1)
1-11
: Imports are correctly structured.The import statements are well-organized and include all necessary components for the new functionality.
packages/web/src/pages/CommitteeTools/PayoutsTool/components/PayoutAllocation/SplitPayoutAllocation/components/SplitPayoutBeneficiaryForm.tsx (1)
101-102
: State variables are appropriately used.The state variables
vaultGithubIssues
andisLoadingGH
are correctly declared and used to manage data and loading states effectively.
export const getForkedRepoName = (vault: IVault) => { | ||
const vaultName = vault.description?.["project-metadata"].name; | ||
if (!vaultName) return ""; | ||
|
||
const vaultSlug = vaultName.replace(/[^\w\s]| /gi, "-"); | ||
const forkedRepoName = `${vaultSlug}-${vault.id}`; | ||
|
||
return forkedRepoName; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve the addition of getForkedRepoName
with a suggestion for improvement.
The getForkedRepoName
function is well-implemented and follows good practices in handling potential null values and sanitizing input. However, consider enhancing the sanitization process to handle multiple consecutive non-word characters or spaces more gracefully by collapsing them into a single hyphen. This can improve the readability and consistency of the generated repository names.
Consider this improvement to the sanitization logic:
- const vaultSlug = vaultName.replace(/[^\w\s]| /gi, "-");
+ const vaultSlug = vaultName.replace(/[\W_]+/g, "-");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export const getForkedRepoName = (vault: IVault) => { | |
const vaultName = vault.description?.["project-metadata"].name; | |
if (!vaultName) return ""; | |
const vaultSlug = vaultName.replace(/[^\w\s]| /gi, "-"); | |
const forkedRepoName = `${vaultSlug}-${vault.id}`; | |
return forkedRepoName; | |
}; | |
export const getForkedRepoName = (vault: IVault) => { | |
const vaultName = vault.description?.["project-metadata"].name; | |
if (!vaultName) return ""; | |
const vaultSlug = vaultName.replace(/[\W_]+/g, "-"); | |
const forkedRepoName = `${vaultSlug}-${vault.id}`; | |
return forkedRepoName; | |
}; |
@@ -145,6 +147,7 @@ export function FormSelectInputComponent( | |||
})} | |||
</SelectMenuOptions> | |||
)} | |||
{!error && helper && <span className="helper">{helper}</span>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved conditional rendering of helper text.
The conditional rendering of the helper
text in the FormSelectInputComponent
is correctly implemented. It enhances the user experience by providing additional information without cluttering the interface when not needed.
Consider adding an aria-describedby
attribute to the select element to improve accessibility by linking the helper text.
// Get information from github | ||
useEffect(() => { | ||
if (!beneficiarySubmission || !vault) return; | ||
if (vaultGithubIssues !== undefined) return; | ||
|
||
const loadGhIssues = async () => { | ||
setIsLoadingGH(true); | ||
const ghIssues = await getGithubIssuesFromVault(vault); | ||
setVaultGithubIssues(ghIssues); | ||
setIsLoadingGH(false); | ||
}; | ||
loadGhIssues(); | ||
}, [vault, vaultGithubIssues, beneficiarySubmission]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well-implemented useEffect hook for fetching GitHub issues.
The useEffect
hook is well-structured to fetch GitHub issues based on the necessary conditions. However, consider adding error handling within the loadGhIssues
function to manage potential fetch failures gracefully.
Consider adding a try-catch block around the fetch operation to handle errors:
const loadGhIssues = async () => {
setIsLoadingGH(true);
try {
const ghIssues = await getGithubIssuesFromVault(vault);
setVaultGithubIssues(ghIssues);
} catch (error) {
console.error('Failed to fetch GitHub issues:', error);
// Optionally set an error state here
}
setIsLoadingGH(false);
};
export function getGhIssueFromSubmission(submission?: ISubmittedSubmission, ghIssues?: GithubIssue[]): GithubIssue | undefined { | ||
if (!ghIssues || !submission) return undefined; | ||
|
||
const sameTxHash = ghIssues.filter((issue) => issue.txHash === submission.txid); | ||
const sameTitle = sameTxHash.filter((issue) => issue.title === submission.submissionDataStructure?.title); | ||
|
||
return sameTitle[0]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function logic is clear, consider enhancing readability.
The getGhIssueFromSubmission
function is correctly implemented with efficient use of filtering. To enhance readability, consider using more descriptive variable names than sameTxHash
and sameTitle
.
Consider renaming variables for clarity:
- const sameTxHash = ghIssues.filter((issue) => issue.txHash === submission.txid);
- const sameTitle = sameTxHash.filter((issue) => issue.title === submission.submissionDataStructure?.title);
+ const issuesWithMatchingTxHash = ghIssues.filter((issue) => issue.txHash === submission.txid);
+ const matchingIssues = issuesWithMatchingTxHash.filter((issue) => issue.title === submission.submissionDataStructure?.title);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export function getGhIssueFromSubmission(submission?: ISubmittedSubmission, ghIssues?: GithubIssue[]): GithubIssue | undefined { | |
if (!ghIssues || !submission) return undefined; | |
const sameTxHash = ghIssues.filter((issue) => issue.txHash === submission.txid); | |
const sameTitle = sameTxHash.filter((issue) => issue.title === submission.submissionDataStructure?.title); | |
return sameTitle[0]; | |
} | |
export function getGhIssueFromSubmission(submission?: ISubmittedSubmission, ghIssues?: GithubIssue[]): GithubIssue | undefined { | |
if (!ghIssues || !submission) return undefined; | |
const issuesWithMatchingTxHash = ghIssues.filter((issue) => issue.txHash === submission.txid); | |
const matchingIssues = issuesWithMatchingTxHash.filter((issue) => issue.title === submission.submissionDataStructure?.title); | |
return matchingIssues[0]; | |
} |
export async function getGithubIssuesFromVault(vault: IVault): Promise<GithubIssue[]> { | ||
const extractTxHashFromBody = (issue: GithubIssue): any => { | ||
// const txHash = issue.body.match(/(0x[a-fA-F0-9]{64})/)?.[0]; | ||
const txHash = issue.body.match(/(\*\*Submission hash \(on-chain\):\*\* (.*)\n)/)?.[2] ?? undefined; | ||
return txHash; | ||
}; | ||
|
||
const mapGithubIssue = (issue: any): GithubIssue => { | ||
return { | ||
id: issue.id, | ||
number: issue.number, | ||
title: issue.title, | ||
createdBy: issue.user.id, | ||
labels: issue.labels.map((label: any) => label.name), | ||
validLabels: issue.labels | ||
.filter((label: any) => severitiesOrder.includes((label.name as string).toLowerCase())) | ||
.map((label: any) => (label.name as string).toLowerCase()), | ||
createdAt: issue.created_at, | ||
body: issue.body, | ||
txHash: extractTxHashFromBody(issue), | ||
}; | ||
}; | ||
|
||
const res = await axiosClient.get(`${BASE_SERVICE_URL}/github-repos/gh-issues/${vault.id}`); | ||
const issues = res.data.githubIssues.map(mapGithubIssue) as GithubIssue[]; | ||
|
||
return issues.filter((issue) => issue.createdBy === HATS_GITHUB_BOT_ID) ?? []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well-implemented function, consider adding error handling.
The getGithubIssuesFromVault
function is well-structured and effectively fetches and processes GitHub issues. However, consider adding error handling to manage potential issues with the network request or data processing.
Consider wrapping the axios call in a try-catch block to handle potential errors gracefully:
+ try {
const res = await axiosClient.get(`${BASE_SERVICE_URL}/github-repos/gh-issues/${vault.id}`);
const issues = res.data.githubIssues.map(mapGithubIssue) as GithubIssue[];
return issues.filter((issue) => issue.createdBy === HATS_GITHUB_BOT_ID) ?? [];
+ } catch (error) {
+ console.error('Failed to fetch GitHub issues:', error);
+ return [];
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export async function getGithubIssuesFromVault(vault: IVault): Promise<GithubIssue[]> { | |
const extractTxHashFromBody = (issue: GithubIssue): any => { | |
// const txHash = issue.body.match(/(0x[a-fA-F0-9]{64})/)?.[0]; | |
const txHash = issue.body.match(/(\*\*Submission hash \(on-chain\):\*\* (.*)\n)/)?.[2] ?? undefined; | |
return txHash; | |
}; | |
const mapGithubIssue = (issue: any): GithubIssue => { | |
return { | |
id: issue.id, | |
number: issue.number, | |
title: issue.title, | |
createdBy: issue.user.id, | |
labels: issue.labels.map((label: any) => label.name), | |
validLabels: issue.labels | |
.filter((label: any) => severitiesOrder.includes((label.name as string).toLowerCase())) | |
.map((label: any) => (label.name as string).toLowerCase()), | |
createdAt: issue.created_at, | |
body: issue.body, | |
txHash: extractTxHashFromBody(issue), | |
}; | |
}; | |
const res = await axiosClient.get(`${BASE_SERVICE_URL}/github-repos/gh-issues/${vault.id}`); | |
const issues = res.data.githubIssues.map(mapGithubIssue) as GithubIssue[]; | |
return issues.filter((issue) => issue.createdBy === HATS_GITHUB_BOT_ID) ?? []; | |
} | |
export async function getGithubIssuesFromVault(vault: IVault): Promise<GithubIssue[]> { | |
const extractTxHashFromBody = (issue: GithubIssue): any => { | |
// const txHash = issue.body.match(/(0x[a-fA-F0-9]{64})/)?.[0]; | |
const txHash = issue.body.match(/(\*\*Submission hash \(on-chain\):\*\* (.*)\n)/)?.[2] ?? undefined; | |
return txHash; | |
}; | |
const mapGithubIssue = (issue: any): GithubIssue => { | |
return { | |
id: issue.id, | |
number: issue.number, | |
title: issue.title, | |
createdBy: issue.user.id, | |
labels: issue.labels.map((label: any) => label.name), | |
validLabels: issue.labels | |
.filter((label: any) => severitiesOrder.includes((label.name as string).toLowerCase())) | |
.map((label: any) => (label.name as string).toLowerCase()), | |
createdAt: issue.created_at, | |
body: issue.body, | |
txHash: extractTxHashFromBody(issue), | |
}; | |
}; | |
try { | |
const res = await axiosClient.get(`${BASE_SERVICE_URL}/github-repos/gh-issues/${vault.id}`); | |
const issues = res.data.githubIssues.map(mapGithubIssue) as GithubIssue[]; | |
return issues.filter((issue) => issue.createdBy === HATS_GITHUB_BOT_ID) ?? []; | |
} catch (error) { | |
console.error('Failed to fetch GitHub issues:', error); | |
return []; | |
} | |
} |
// Get information from github | ||
useEffect(() => { | ||
if (!beneficiarySubmission || !vault) return; | ||
if (vaultGithubIssues !== undefined) return; | ||
|
||
const loadGhIssues = async () => { | ||
setIsLoadingGH(true); | ||
const ghIssues = await getGithubIssuesFromVault(vault); | ||
setVaultGithubIssues(ghIssues); | ||
setIsLoadingGH(false); | ||
}; | ||
loadGhIssues(); | ||
}, [vault, vaultGithubIssues, beneficiarySubmission]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useEffect is well-implemented, consider handling empty responses.
The useEffect hook correctly triggers the fetching of GitHub issues based on relevant dependencies. Consider handling cases where ghIssues
might be empty to improve user experience.
Consider adding a condition to handle empty responses and provide feedback to the user:
const ghIssues = await getGithubIssuesFromVault(vault);
+ if (ghIssues.length === 0) {
+ console.log('No GitHub issues found for this vault.');
+ }
setVaultGithubIssues(ghIssues);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Get information from github | |
useEffect(() => { | |
if (!beneficiarySubmission || !vault) return; | |
if (vaultGithubIssues !== undefined) return; | |
const loadGhIssues = async () => { | |
setIsLoadingGH(true); | |
const ghIssues = await getGithubIssuesFromVault(vault); | |
setVaultGithubIssues(ghIssues); | |
setIsLoadingGH(false); | |
}; | |
loadGhIssues(); | |
}, [vault, vaultGithubIssues, beneficiarySubmission]); | |
// Get information from github | |
useEffect(() => { | |
if (!beneficiarySubmission || !vault) return; | |
if (vaultGithubIssues !== undefined) return; | |
const loadGhIssues = async () => { | |
setIsLoadingGH(true); | |
const ghIssues = await getGithubIssuesFromVault(vault); | |
if (ghIssues.length === 0) { | |
console.log('No GitHub issues found for this vault.'); | |
} | |
setVaultGithubIssues(ghIssues); | |
setIsLoadingGH(false); | |
}; | |
loadGhIssues(); | |
}, [vault, vaultGithubIssues, beneficiarySubmission]); |
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Style