-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix improve qfround history matching Insertion #1799
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
23bdade
add projectId and qfRoundId to qf data export
CarlosQ96 cc79c2c
improve adminjs to import qfround matching and better filters
CarlosQ96 4e59a2b
fix eslint
CarlosQ96 78e1911
fix minor form issues
CarlosQ96 84f7cca
order middleware in bootstrap file
CarlosQ96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/server/adminJs/tabs/components/CustomIdFilterComponent.tsx
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,28 @@ | ||
import React from 'react'; | ||
import { FormGroup, Label, Input } from '@adminjs/design-system'; | ||
|
||
const CustomIdFilterComponent = props => { | ||
const { onChange, property, filter } = props; | ||
const handleChange = event => { | ||
onChange(property.path, event.target.value); | ||
}; | ||
|
||
return ( | ||
<FormGroup> | ||
<Label>{property.label}</Label> | ||
<Input | ||
type="text" | ||
onChange={handleChange} | ||
value={filter[property.path] || ''} | ||
placeholder={`Enter ${property.label} ID`} | ||
style={{ | ||
color: 'white', | ||
backgroundColor: 'rgba(255, 255, 255, 0.1)', // Semi-transparent white background | ||
borderColor: 'rgba(255, 255, 255, 0.3)', // Lighter border for contrast | ||
}} | ||
/> | ||
</FormGroup> | ||
); | ||
}; | ||
|
||
export default CustomIdFilterComponent; | ||
14 changes: 14 additions & 0 deletions
14
src/server/adminJs/tabs/components/CustomProjectReferenceComponent.tsx
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,14 @@ | ||
// components/CustomProjectReferenceListComponent.jsx | ||
import React from 'react'; | ||
import { Link } from '@adminjs/design-system'; | ||
|
||
const CustomProjectReferenceListComponent = props => { | ||
const { record } = props; | ||
const projectId = | ||
record.params.project?.id || record.params.projectId || 'N/A'; | ||
const href = `/admin/resources/Project/records/${projectId}/show`; | ||
|
||
return <Link href={href}>Project {projectId}</Link>; | ||
}; | ||
|
||
export default CustomProjectReferenceListComponent; |
20 changes: 20 additions & 0 deletions
20
src/server/adminJs/tabs/components/CustomProjectReferenceShowComponent.tsx
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,20 @@ | ||
// components/CustomProjectReferenceShowComponent.jsx | ||
import React from 'react'; | ||
import { Link, ValueGroup } from '@adminjs/design-system'; | ||
|
||
const CustomProjectReferenceShowComponent = props => { | ||
const { record } = props; | ||
const projectId = | ||
record.params.project?.id || record.params.projectId || 'N/A'; | ||
const href = `/admin/resources/Project/records/${projectId}/show`; | ||
|
||
return ( | ||
<ValueGroup label="Project"> | ||
<Link href={href} style={{ color: 'inherit', textDecoration: 'none' }}> | ||
{projectId} | ||
</Link> | ||
</ValueGroup> | ||
); | ||
}; | ||
|
||
export default CustomProjectReferenceShowComponent; |
187 changes: 187 additions & 0 deletions
187
src/server/adminJs/tabs/components/CustomQfRoundMultiUpdateComponent.tsx
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,187 @@ | ||
// customQfRoundMultiUpdateComponent.js | ||
import React, { useState } from 'react'; | ||
import { Box, Button, Text, DatePicker, Select } from '@adminjs/design-system'; | ||
import { FormGroup, Label, Input } from '@adminjs/design-system'; | ||
import { ApiClient } from 'adminjs'; | ||
|
||
const RecordInput = ({ index, record, updateRecord, removeRecord }) => ( | ||
<Box mb="lg" variant="white"> | ||
<FormGroup> | ||
<Label>Project ID</Label> | ||
<Input | ||
value={record.projectId} | ||
onChange={e => updateRecord(index, 'projectId', e.target.value)} | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>QF Round ID</Label> | ||
<Input | ||
value={record.qfroundId} | ||
onChange={e => updateRecord(index, 'qfroundId', e.target.value)} | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Matching Fund Amount</Label> | ||
<Input | ||
value={record.matchingFundAmount} | ||
onChange={e => | ||
updateRecord(index, 'matchingFundAmount', e.target.value) | ||
} | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Matching Fund Price USD</Label> | ||
<Input | ||
value={record.matchingFundPriceUsd} | ||
onChange={e => | ||
updateRecord(index, 'matchingFundPriceUsd', e.target.value) | ||
} | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Matching Fund Currency</Label> | ||
<Select | ||
options={[ | ||
{ value: 'ETH', label: 'ETH' }, | ||
{ value: 'DAI', label: 'DAI' }, | ||
{ value: 'USDC', label: 'USDC' }, | ||
]} | ||
value={record.matchingFundCurrency} | ||
onChange={selected => | ||
updateRecord(index, 'matchingFundCurrency', selected.value) | ||
} | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Distributed Fund Tx Hash</Label> | ||
<Input | ||
value={record.distributedFundTxHash} | ||
onChange={e => | ||
updateRecord(index, 'distributedFundTxHash', e.target.value) | ||
} | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Distributed Fund Network</Label> | ||
<Input | ||
value={record.distributedFundNetwork} | ||
onChange={e => | ||
updateRecord(index, 'distributedFundNetwork', e.target.value) | ||
} | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label>Distributed Fund Tx Date</Label> | ||
<DatePicker | ||
value={record.distributedFundTxDate} | ||
onChange={date => updateRecord(index, 'distributedFundTxDate', date)} | ||
/> | ||
</FormGroup> | ||
<Button onClick={() => removeRecord(index)} mt="default"> | ||
Remove | ||
</Button> | ||
</Box> | ||
); | ||
|
||
const CustomQfRoundMultiUpdateComponent = props => { | ||
const [records, setRecords] = useState([ | ||
{ | ||
projectId: '', | ||
qfroundId: '', | ||
matchingFundAmount: '', | ||
matchingFundPriceUsd: '', | ||
matchingFundCurrency: '', | ||
distributedFundTxHash: '', | ||
distributedFundNetwork: '', | ||
distributedFundTxDate: null, | ||
}, | ||
]); | ||
const [message, setMessage] = useState(''); | ||
|
||
const api = new ApiClient(); | ||
|
||
const addRecord = () => { | ||
setRecords([ | ||
...records, | ||
{ | ||
projectId: '', | ||
qfroundId: '', | ||
matchingFundAmount: '', | ||
matchingFundPriceUsd: '', | ||
matchingFundCurrency: '', | ||
distributedFundTxHash: '', | ||
distributedFundNetwork: '', | ||
distributedFundTxDate: null, | ||
}, | ||
]); | ||
}; | ||
|
||
const updateRecord = (index, field, value) => { | ||
const updatedRecords = [...records]; | ||
updatedRecords[index][field] = value; | ||
setRecords(updatedRecords); | ||
}; | ||
|
||
const removeRecord = index => { | ||
const updatedRecords = records.filter((_, i) => i !== index); | ||
setRecords(updatedRecords); | ||
}; | ||
|
||
const handleSubmit = async event => { | ||
event.preventDefault(); | ||
setMessage(''); | ||
|
||
try { | ||
const response = await api.resourceAction({ | ||
resourceId: 'QfRoundHistory', | ||
actionName: 'bulkUpdate', | ||
data: { records }, | ||
}); | ||
|
||
if (response.data.notice) { | ||
if (typeof response.data.notice === 'string') { | ||
setMessage(response.data.notice); | ||
} else if (typeof response.data.notice.message === 'string') { | ||
setMessage(response.data.notice.message); | ||
} else { | ||
setMessage('Update successful'); | ||
} | ||
} else { | ||
setMessage('Update successful'); | ||
} | ||
} catch (error) { | ||
setMessage(`Error: ${error.message}`); | ||
} | ||
}; | ||
|
||
return ( | ||
<Box as="form" onSubmit={handleSubmit}> | ||
<Text variant="lg" fontWeight="bold"> | ||
Update Multiple QfRoundHistory Records | ||
</Text> | ||
{records.map((record, index) => ( | ||
<RecordInput | ||
key={index} | ||
index={index} | ||
record={record} | ||
updateRecord={updateRecord} | ||
removeRecord={removeRecord} | ||
/> | ||
))} | ||
<Button onClick={addRecord} mt="default"> | ||
Add Another Record | ||
</Button> | ||
<Button type="submit" mt="xl"> | ||
Update All | ||
</Button> | ||
{message && <Text mt="default">{message}</Text>} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default CustomQfRoundMultiUpdateComponent; |
14 changes: 14 additions & 0 deletions
14
src/server/adminJs/tabs/components/CustomQfRoundReferenceComponent.tsx
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,14 @@ | ||
// components/CustomQfRoundReferenceListComponent.jsx | ||
import React from 'react'; | ||
import { Link } from '@adminjs/design-system'; | ||
|
||
const CustomQfRoundReferenceListComponent = props => { | ||
const { record } = props; | ||
const qfRoundId = | ||
record.params.qfRound?.id || record.params.qfRoundId || 'N/A'; | ||
const href = `/admin/resources/QfRound/records/${qfRoundId}/show`; | ||
|
||
return <Link href={href}>QF Round {qfRoundId}</Link>; | ||
}; | ||
|
||
export default CustomQfRoundReferenceListComponent; |
20 changes: 20 additions & 0 deletions
20
src/server/adminJs/tabs/components/CustomQfRoundReferenceShowComponent.tsx
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,20 @@ | ||
// components/CustomQfRoundReferenceShowComponent.jsx | ||
import React from 'react'; | ||
import { Link, ValueGroup } from '@adminjs/design-system'; | ||
|
||
const CustomQfRoundReferenceShowComponent = props => { | ||
const { record } = props; | ||
const qfRoundId = | ||
record.params.qfRound?.id || record.params.qfRoundId || 'N/A'; | ||
const href = `/admin/resources/QfRound/records/${qfRoundId}/show`; | ||
|
||
return ( | ||
<ValueGroup label="QF Round"> | ||
<Link href={href} style={{ color: 'inherit', textDecoration: 'none' }}> | ||
{qfRoundId} | ||
</Link> | ||
</ValueGroup> | ||
); | ||
}; | ||
|
||
export default CustomQfRoundReferenceShowComponent; | ||
Comment on lines
+5
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review of This component is well-structured and follows React functional component best practices. However, consider using styled components or external CSS for styling to enhance maintainability.
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Review of
CustomIdFilterComponent
This component is well-structured and follows React functional component best practices. However, consider using styled components or external CSS for styling to enhance maintainability.