-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-1116] Implement contribution record page #397
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
Merged
Innavin369
merged 112 commits into
main
from
OSDEV-1116-implement-contribution-record-page
Nov 12, 2024
Merged
Changes from 95 commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
ab502a2
Add route to moderation queue
mazursasha1990 8235d29
Add route to moderation queue
mazursasha1990 af8bbb6
Add filters components for moderation queue page
mazursasha1990 b384e66
Add actions for record type options
mazursasha1990 4c7f799
Add reducers for record type options
mazursasha1990 ecc286d
Use fetchRecordTypes and fetchCountries in the DashboardModerationQue…
mazursasha1990 1141614
Use recordTypesOptions from the state
mazursasha1990 b978501
Add actions for fetching match status options options
mazursasha1990 0f56d47
Add reducers for match status options options
mazursasha1990 aed78ac
Use fetchMatchStatusOptions in the DashboardModerationQueue component
mazursasha1990 8105f02
Use matchStatusesOptions from the state
mazursasha1990 42e502b
Use options for moderation queue filters from constant values
mazursasha1990 ac86145
Remove actions and reducers for the moderation queue filters
mazursasha1990 9c129ab
Revert changes in filterOptions.js
mazursasha1990 221e46c
Add DashboardModerationQueueReducer
mazursasha1990 43819a4
Add actions for the moderation queue
mazursasha1990 4e7b318
Add moderationEventsPropType
mazursasha1990 99d34f7
Correct moderationEventsPropType
mazursasha1990 b4cca62
Change name import CLAIM_DECISION_EMPTY to EMPTY_PLACEHOLDER
mazursasha1990 649278f
Add className prop to the moderation queue page filters
mazursasha1990 b3c1ddb
Change value in the RECORD_TYPES_OPTIONS
mazursasha1990 83f3995
Add width for the DownloadFacilityClaimsButton
mazursasha1990 7670d7b
Introduce DatePicker component
mazursasha1990 4b3503b
Introduce DownloadExcelButton component
mazursasha1990 ce7de07
Add actions for downloading moderation events
mazursasha1990 362ed95
Add util functions used by actions for downloading moderation events
mazursasha1990 f831dae
Add reducers for downloading moderation events
mazursasha1990 b249c7e
Make DashboardDownloadDataButton as reusable
mazursasha1990 10a1cbc
Use DashboardDownloadDataButton in the DashboardClaims component inst…
mazursasha1990 5c2836b
Addapt filters to updated specifications
mazursasha1990 01185d0
Modify mocked data acording to the updated specifications
mazursasha1990 b55c867
Remove DownloadFacilityClaimsButton.jsx as redundant
mazursasha1990 c1575b1
Add default prop type for filter options
mazursasha1990 7ec2320
Add reducers for sourceTypes and moderationStatuses filter values
mazursasha1990 a6fb212
Refactor SourceTypeFilter
mazursasha1990 d90e78e
Refactor ModerationStatusFilter
mazursasha1990 2475d4a
Add defaultProps for the downloadError value in the DashboardDownload…
mazursasha1990 5ac81bf
Add updateSourceTypeFilter and updateModerationStatusFilter actions
mazursasha1990 a7d96a9
Organize colors based on their general color family
mazursasha1990 1e8eeac
Add createOptionsFromConstants function to the util.js
mazursasha1990 94fe475
Modify creation of options for the SourceType and ModerationStatus f…
mazursasha1990 1914a99
Add dinamic value for the background color of the selected value
mazursasha1990 2ba44f8
Refactor main components
mazursasha1990 6022be9
Add ROWS_PER_PAGE_OPTIONS and DEFAULT_ROWS_PER_PAGE constants to esca…
mazursasha1990 61060cf
Merge branch 'main' into OSDEV-1120-create-new-moderation-queue-page
mazursasha1990 2261ed3
Refactor DashboardModerationQueueListTableHeader component
mazursasha1990 cda55cb
Refactor DashboardModerationQueueListTable component
mazursasha1990 65fdeeb
Refactor DashboardModerationQueue component
mazursasha1990 982be9d
Add tests for the DashboardDownloadDataButton component
mazursasha1990 bfeffd4
Add tests for the DashboardDownloadDataButton component
mazursasha1990 907ea26
Add tests for the DatePicker component
mazursasha1990 bd10501
Modify formatDate util function
mazursasha1990 4af82da
Add tests for the DashboardModerationQueueListTable component
mazursasha1990 436368a
Add tests for the DashboardModerationQueueListTableHeader component
mazursasha1990 ed92d86
Fix linter error
mazursasha1990 394ac20
Fix error in tests
mazursasha1990 7264882
Fix sonar duplicated lines error
mazursasha1990 0386537
Fix sonar duplicated lines error
mazursasha1990 92d6676
Fix sonar duplicated lines error
mazursasha1990 d61a592
Merge branch 'main' into OSDEV-1120-create-new-moderation-queue-page
mazursasha1990 7d213cc
Fix linter error
mazursasha1990 6de9c36
Fix test for the DownloadExcelButton component
mazursasha1990 eaee0b4
Fix linter error
mazursasha1990 5a68fb6
Remove link to Moderation Queue from the Dashboard
mazursasha1990 799df0f
Use formatDate util function in the DashboardModerationQueueListTable…
mazursasha1990 bf669ae
Add release notes
mazursasha1990 8b28c22
Use formatDate util function in the formatFacilityClaimsDataForXLSX a…
mazursasha1990 4c65786
Add TODO comment to the dashboardModerationQueue.js
mazursasha1990 852e994
Added prop types for the moderationStatuses and sourceTypes
mazursasha1990 5305ea1
Restrict the order prop to specific values in the DashboardModeration…
mazursasha1990 8208b71
Modify test for the DashboardModerationQueueListTable component
mazursasha1990 7f4c3a7
Rename downloadError to downloadClaimsError in the DashboardClaims co…
mazursasha1990 c7fe2cb
Rename downloadError to downloadEventsError in the DashboardModeratio…
mazursasha1990 cbc7053
Change prop types for error and downloadEventsError to string
mazursasha1990 44d9fe1
Change default prop type for events to empty array
mazursasha1990 b2a9eaa
Add aria-label to the TableSortLabel
mazursasha1990 78a09ba
Fix warning about missing prop validation for handleDownload in the D…
mazursasha1990 8b7e2cd
Update release notes
mazursasha1990 10fec52
Merge branch 'main' into OSDEV-1120-create-new-moderation-queue-page
mazursasha1990 7ac79a5
Fix warning about missing prop validation for handleDownload in the D…
mazursasha1990 c1e4f1f
Create DATE_FORMATS constant and use it in the changed files
mazursasha1990 69855cf
Remove unused import of 'func' in the DashboardDownloadDataButton.tes…
mazursasha1990 2b614e9
Fix linter error
mazursasha1990 82b8192
Add kunk to the ticket in the TODO comment
mazursasha1990 0b2ee75
Add date validation to prevent invalid ranges
mazursasha1990 525fa63
Merge branch 'main' into OSDEV-1120-create-new-moderation-queue-page
mazursasha1990 c22616e
added screen with dummy data
ed14fed
code refactoring, added actions and reducer
2e398f3
merged main
ab245e8
added react tests, passed moderation id from params to method
141772e
added task description
eb7a996
Merge branch 'main' into OSDEV-1116-implement-contribution-record-page
e5ce87d
removed routing with flag
237a285
commented routing
ea5e6e9
removed unneseccary comment
1d8047a
aded changes for coderabbit comments
247a5a2
changes according comments
0046606
added Object.freeze for styles, added butto attr for row and changed…
2aa5763
fixed tests
a54c11b
replaced colors with const vars
ef71a57
changed moderation id, fixed propTypes
bc3f471
changed mod event prop type
5ec2510
fixed structure of List component
bd5e551
added NOSONAR justification for ignoring specific code
464f282
changed mocked data
60f4429
renamed vars similar to Moderation Queue, changed mock data to avoid …
b020d50
revert changes in Olek file
2e1aa5b
Update .editorconfig
Innavin369 efbb55e
reverted changes in test file
ad54324
added tests for avaliable data, fixes
7bc8773
Merge branch 'main' into OSDEV-1116-implement-contribution-record-page
483e00c
fixed linter
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
This file contains hidden or 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
82 changes: 82 additions & 0 deletions
82
src/react/src/__tests__/components/ContributionRecord.test.js
This file contains hidden or 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,82 @@ | ||
| import React from 'react'; | ||
| import DashboardContributionRecord from '../../components/Dashboard/DashboardContributionRecord'; | ||
| import renderWithProviders from '../../util/testUtils/renderWithProviders'; | ||
|
|
||
| describe('DashboardContributionRecord component', () => { | ||
| const routeProps = { | ||
| match: { | ||
| params: { | ||
| moderationID: '1', | ||
| }, | ||
| }, | ||
| }; | ||
| const defaultProps = { | ||
| event: {}, | ||
| potentialMatches: [], | ||
| error: null, | ||
| fetchPotentialMatchError: null, | ||
| }; | ||
|
|
||
| const renderComponent = (props = {}) => renderWithProviders( | ||
| <DashboardContributionRecord {...defaultProps} {...routeProps} {...props}/> | ||
| ); | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| test('should render the CreateButton', () => { | ||
| const {getByText} = renderComponent(); | ||
|
|
||
| expect(getByText('Create New Location')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('should render the RejectButton', () => { | ||
| const {getByText} = renderComponent(); | ||
|
|
||
| expect(getByText('Reject Contribution')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('should render the ClaimButton', () => { | ||
| const {getByText} = renderComponent(); | ||
|
|
||
| expect(getByText('Go to Claim')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('should disable button when fetching is true', () => { | ||
| const {getByRole} = renderComponent({ fetching: true }); | ||
| const createButton = getByRole('button', { name: /Create New Location/i }); | ||
| const rejectButton = getByRole('button', { name: /Reject Contribution/i }); | ||
| const claimButton = getByRole('button', { name: /Go to Claim/i }); | ||
|
|
||
| expect(createButton).toBeDisabled(); | ||
| expect(rejectButton).toBeDisabled(); | ||
| expect(claimButton).toBeDisabled(); | ||
| }); | ||
|
|
||
| test('should enable button when fetching is false', () => { | ||
| const {getByRole} = renderComponent({fetching: false,moderationID :'2'}); | ||
Innavin369 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const createButton = getByRole('button', { name: /Create New Location/i }); | ||
| const rejectButton = getByRole('button', { name: /Reject Contribution/i }); | ||
| const claimButton = getByRole('button', { name: /Go to Claim/i }); | ||
|
|
||
| expect(createButton.getAttribute("disabled")).toBe(''); | ||
| expect(rejectButton.getAttribute("disabled")).toBe(''); | ||
| expect(claimButton.getAttribute("disabled")).toBe(''); | ||
| }); | ||
Innavin369 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| test('renders the "No potential matches found" block if no potential matches', () => { | ||
| const {getByText} = renderComponent(); | ||
|
|
||
| expect(getByText('No potential matches found')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
|
|
||
| it('renders the loading spinner', () => { | ||
| const {getByRole} = renderComponent({ fetching: true }); | ||
|
|
||
| expect(getByRole('progressbar')).toBeInTheDocument(); | ||
| }); | ||
roman-stolar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| }); | ||
mazursasha1990 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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,129 @@ | ||
| import { createAction } from 'redux-act'; | ||
| import { logErrorAndDispatchFailure } from '../util/util'; | ||
|
|
||
| export const startFetchingModerationEvent = createAction( | ||
| 'START_FETCHING_MODERATION_EVENT', | ||
| ); | ||
| export const failFetchingModerationEvent = createAction( | ||
| 'FAIL_FETCHING_MODERATION_EVENT', | ||
| ); | ||
| export const completeFetchingModerationEvent = createAction( | ||
| 'COMPLETE_FETCHING_MODERATION_EVENT', | ||
| ); | ||
Innavin369 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export const startFetchingPotentialMatches = createAction( | ||
| 'START_FETCHING_POTENTIAL_MATCHES', | ||
| ); | ||
| export const failFetchingPotentialMatches = createAction( | ||
| 'FAIL_FETCHING_POTENTIAL_MATCHES', | ||
| ); | ||
| export const completeFetchingPotentialMatches = createAction( | ||
| 'COMPLETE_FETCHING_POTENTIAL_MATCHES', | ||
| ); | ||
|
|
||
| // TODO: Remove mock data and replace with actual API call as part of https://opensupplyhub.atlassian.net/browse/OSDEV-1347 | ||
| const eventMockData = { | ||
| moderation_id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
| created_at: '2024-10-17T11:30:20.287Z', | ||
| updated_at: '2024-10-18T11:30:20.287Z', | ||
| os_id: 'CN2021250D1DTN7', | ||
| cleaned_data: { | ||
| name: 'Eco Friendly Plastics', | ||
| address: '435 Main St, Manhattan, NY - USA', | ||
| country: { | ||
| name: 'Germany', | ||
| alpha_2: 'DE', | ||
| alpha_3: 'DEU', | ||
| numeric: '276', | ||
| }, | ||
| }, | ||
| contributor_id: 0, | ||
| contributor_name: 'Green Solutions Corp', | ||
| request_type: 'CREATE', | ||
| source: 'API', | ||
| moderation_status: 'PENDING', | ||
| moderation_decision_date: null, | ||
| claim_id: 0, | ||
| }; | ||
|
|
||
| // TODO: Remove mock data and replace with actual API call as part of /v1/production-locations endpoint | ||
| const potentialMatchesMockData = [ | ||
| { | ||
| os_id: 'CN2021250D1DTN7', | ||
| name: 'Test name INC', | ||
| address: '435 Main St, Manhattan, NY - USA', | ||
| sector: ['Apparel'], | ||
| parent_company: 'ASI GLOBAL LIMITED', | ||
| product_type: ['Accessories'], | ||
| location_type: [], | ||
| processing_type: ['Final Product Assembly'], | ||
| number_of_workers: { | ||
| min: 0, | ||
| max: 0, | ||
| }, | ||
| coordinates: { | ||
| lat: 0, | ||
| lng: 0, | ||
| }, | ||
| local_name: '', | ||
| description: '', | ||
| business_url: '', | ||
| minimum_order_quantity: '', | ||
| average_lead_time: '', | ||
| percent_female_workers: 0, | ||
| affiliations: [], | ||
| certifications_standards_regulations: [], | ||
| historical_os_id: [], | ||
| country: { | ||
| name: 'Germany', | ||
| alpha_2: 'DE', | ||
| alpha_3: 'DEU', | ||
| numeric: '276', | ||
| }, | ||
| claim_status: 'unclaimed', | ||
| }, | ||
| ]; | ||
Innavin369 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // eslint-disable-next-line no-unused-vars | ||
| export function fetchModerationEvent(moderationID) { | ||
Innavin369 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return async dispatch => { | ||
| dispatch(startFetchingModerationEvent()); | ||
|
|
||
| // TODO: Replace the mock implementation with an actual API call as part of https://opensupplyhub.atlassian.net/browse/OSDEV-1347 | ||
| return new Promise(resolve => { | ||
| setTimeout(() => resolve({ data: eventMockData }), 1000); | ||
| }) | ||
| .then(({ data }) => dispatch(completeFetchingModerationEvent(data))) | ||
| .catch(err => | ||
| dispatch( | ||
| logErrorAndDispatchFailure( | ||
| err, | ||
| 'An error prevented fetching moderation event', | ||
| failFetchingModerationEvent, | ||
| ), | ||
| ), | ||
| ); | ||
| }; | ||
| } | ||
roman-stolar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Innavin369 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export function fetchPotentialMatches() { | ||
| return async dispatch => { | ||
| dispatch(startFetchingPotentialMatches()); | ||
|
|
||
| // TODO: Replace the mock implementation with an actual API call as part of /v1/production-locations endpoint | ||
| return new Promise(resolve => { | ||
| setTimeout(() => resolve({ data: potentialMatchesMockData }), 1000); | ||
| }) | ||
| .then(({ data }) => | ||
| dispatch(completeFetchingPotentialMatches(data)), | ||
| ) | ||
| .catch(err => | ||
| dispatch( | ||
| logErrorAndDispatchFailure( | ||
| err, | ||
| 'An error prevented fetching potential matches', | ||
| failFetchingPotentialMatches, | ||
| ), | ||
| ), | ||
| ); | ||
| }; | ||
| } | ||
Innavin369 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.