-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into NDT-529-Format-of-Federal-Funding-requested-…
…needs-refinement
- Loading branch information
Showing
37 changed files
with
1,024 additions
and
99 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
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,88 @@ | ||
import HistoryDetails from 'components/Analyst/History/HistoryDetails'; | ||
import cbcData from 'formSchema/uiSchema/history/cbcData'; | ||
import { DateTime } from 'luxon'; | ||
import styled from 'styled-components'; | ||
|
||
const StyledContent = styled.span` | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
margin-bottom: 8px; | ||
& span { | ||
margin: 0 4px; | ||
} | ||
& span:first-child { | ||
margin-left: 0; | ||
} | ||
`; | ||
|
||
const StyledChange = styled.div` | ||
padding: 8px 16px; | ||
`; | ||
|
||
const ChangeReason = ({ reason }) => { | ||
return ( | ||
<StyledChange> | ||
<b>Reason for change:</b> {reason} | ||
</StyledChange> | ||
); | ||
}; | ||
|
||
const HistoryContent = ({ | ||
createdAt, | ||
updatedAt, | ||
prevJson, | ||
json, | ||
givenName, | ||
changeReason, | ||
familyName, | ||
op, | ||
tableName, | ||
}) => { | ||
const fullName = `${givenName} ${familyName}`; | ||
|
||
const createdAtFormatted = | ||
op === 'UPDATE' | ||
? DateTime.fromJSDate(new Date(updatedAt)).toLocaleString( | ||
DateTime.DATETIME_MED | ||
) | ||
: DateTime.fromJSDate(new Date(createdAt)).toLocaleString( | ||
DateTime.DATETIME_MED | ||
); | ||
|
||
if (tableName === 'cbc_data') { | ||
return ( | ||
<> | ||
<StyledContent data-testid="cbc-data-updater-and-timestamp"> | ||
<span> | ||
{fullName} {op === 'UPDATE' ? 'updated' : 'created'} the CBC data on{' '} | ||
{createdAtFormatted} | ||
</span> | ||
</StyledContent> | ||
<HistoryDetails | ||
data-testid="cbc-data-history-details" | ||
json={json} | ||
prevJson={prevJson} | ||
excludedKeys={[ | ||
'id', | ||
'created_at', | ||
'updated_at', | ||
'change_reason', | ||
'cbc_data_id', | ||
]} | ||
diffSchema={cbcData} | ||
overrideParent="cbcData" | ||
/> | ||
{op === 'UPDATE' && changeReason !== '' && ( | ||
<ChangeReason reason={changeReason} /> | ||
)} | ||
</> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
export default HistoryContent; |
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,72 @@ | ||
import styled from 'styled-components'; | ||
import React from 'react'; | ||
import { HistoryIcon } from 'components/Analyst/History'; | ||
import CbcHistoryContent from './CbcHistoryContent'; | ||
|
||
const StyledIconCell = styled.td` | ||
width: 5px; | ||
border-left: 1px solid ${(props) => props.theme.color.links}; | ||
border-bottom: none; | ||
position: relative; | ||
& div { | ||
position: absolute; | ||
right: 2px; | ||
top: -2px; | ||
} | ||
`; | ||
|
||
const StyledCell = styled.td` | ||
border-bottom: none; | ||
& b { | ||
text-transform: capitalize; | ||
} | ||
`; | ||
|
||
interface Props { | ||
json: any; | ||
prevJson: any; | ||
changeReason: string; | ||
tableName: string; | ||
updatedAt: string; | ||
createdAt: string; | ||
givenName: string; | ||
familyName: string; | ||
op: string; | ||
} | ||
|
||
const CbcHistoryRow: React.FC<Props> = ({ | ||
json, | ||
prevJson, | ||
changeReason, | ||
tableName, | ||
createdAt, | ||
givenName, | ||
familyName, | ||
updatedAt, | ||
op, | ||
}) => { | ||
return ( | ||
<tr> | ||
<StyledIconCell> | ||
<HistoryIcon type="form_data" /> | ||
</StyledIconCell> | ||
<StyledCell> | ||
<CbcHistoryContent | ||
json={json} | ||
prevJson={prevJson} | ||
createdAt={createdAt} | ||
updatedAt={updatedAt} | ||
familyName={familyName} | ||
givenName={givenName} | ||
tableName={tableName} | ||
changeReason={changeReason} | ||
op={op} | ||
/> | ||
</StyledCell> | ||
</tr> | ||
); | ||
}; | ||
|
||
export default CbcHistoryRow; |
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,87 @@ | ||
import { CbcHistoryTable_query$key } from '__generated__/CbcHistoryTable_query.graphql'; | ||
import React from 'react'; | ||
import { useFragment, graphql } from 'react-relay'; | ||
import styled from 'styled-components'; | ||
import CbcHistoryRow from './CbcHistoryRow'; | ||
|
||
const StyledTable = styled.table` | ||
border: none; | ||
table-layout: fixed; | ||
margin-left: 8px; | ||
& td { | ||
padding-top: 0; | ||
padding-bottom: 16px; | ||
} | ||
& tr:last-child { | ||
& td:first-child { | ||
border: none; | ||
} | ||
td { | ||
padding-bottom: 0px; | ||
} | ||
} | ||
`; | ||
|
||
interface Props { | ||
query: any; | ||
} | ||
|
||
const CbcHistoryTable: React.FC<Props> = ({ query }) => { | ||
const queryFragment = useFragment<CbcHistoryTable_query$key>( | ||
graphql` | ||
fragment CbcHistoryTable_query on Query { | ||
cbcByRowId(rowId: $rowId) { | ||
history { | ||
nodes { | ||
rowId | ||
record | ||
oldRecord | ||
op | ||
tableName | ||
createdAt | ||
ccbcUserByCreatedBy { | ||
givenName | ||
familyName | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
query | ||
); | ||
|
||
const { cbcByRowId } = queryFragment; | ||
const { history } = cbcByRowId; | ||
|
||
return ( | ||
<StyledTable> | ||
<tbody> | ||
{history.nodes.map((historyItem) => ( | ||
<CbcHistoryRow | ||
key={historyItem.rowId} | ||
json={{ | ||
...historyItem.record?.json_data, | ||
project_number: historyItem.record?.project_number, | ||
}} | ||
prevJson={{ | ||
...historyItem.oldRecord?.json_data, | ||
project_number: historyItem.oldRecord?.project_number, | ||
}} | ||
changeReason={historyItem.record?.change_reason} | ||
tableName={historyItem.tableName} | ||
createdAt={historyItem.createdAt} | ||
updatedAt={historyItem.record?.updated_at} | ||
givenName={historyItem.ccbcUserByCreatedBy.givenName} | ||
familyName={historyItem.ccbcUserByCreatedBy.familyName} | ||
op={historyItem.op} | ||
/> | ||
))} | ||
</tbody> | ||
</StyledTable> | ||
); | ||
}; | ||
|
||
export default CbcHistoryTable; |
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
Oops, something went wrong.