Skip to content

Commit

Permalink
Ricky/appeals-34224 (#20316)
Browse files Browse the repository at this point in the history
* Created functions to handle history generation

* WIP fixing the history db entry on save

* Set up lever history component to not error on newly sent data.

* Updated to display correct data on main page

* Commented out code that created bug displaying wrong units for affinity days lever history

* Updated formatting of time in lever history

* Added initial key seeding to update

---------

Co-authored-by: 631966 <amy.detwiler@va.gov>
  • Loading branch information
Blake-Manus and amybids authored Dec 22, 2023
1 parent 12ab324 commit d7d6992
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ const CaseflowDistributionContent = ({
sectionTitles
}) => {

const [seed, setSeed] = useState(1);

const reset = () => {
setSeed(Math.random());
};

useEffect(() => {
reset();
}, []);

return (
<div>
<h1>Administration</h1>
Expand Down Expand Up @@ -58,7 +68,7 @@ const CaseflowDistributionContent = ({
</h2>
<div {...sectionSegmentStyling}>
<p className="cf-lead-paragraph">{COPY.CASE_DISTRIBUTION_HISTORY_DESCRIPTION}</p>
<LeverHistory historyData={formattedHistory} leverStore={leverStore} />
<LeverHistory historyData={formattedHistory} leverStore={leverStore} key={seed} />
</div>
</div>
</div>
Expand Down
19 changes: 18 additions & 1 deletion client/app/caseflowDistribution/components/LeverHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ const LeverHistory = (props) => {
return user;
};


function formatTime(databaseDate) {
// Create a Date object from the database date string
const dateObject = new Date(databaseDate);
// Use toLocaleDateString() to get a localized date string for the United States
const options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' };
const datePart = dateObject.toLocaleDateString('en-US', options);
// Get hours, minutes, and seconds
const hours = dateObject.getHours();
const minutes = dateObject.getMinutes();
const seconds = dateObject.getSeconds();
// Format the date string
const formattedDate = `${datePart} ${hours}:${minutes}:${seconds}`;

return formattedDate;
}

const formatHistoryData = () => {

let formattedHistoryEntries = [];
Expand All @@ -126,7 +143,7 @@ const LeverHistory = (props) => {

sortedTimestamps.map((time) => {
let historyEntry = {
created_at: time,
created_at: formatTime(time),
user: getUserAtTimestamp(time),
titles: getLeverTitlesAtTimestamp(time),
previous_values: getPreviousValuesAtTimestamp(time),
Expand Down

0 comments on commit d7d6992

Please sign in to comment.