Skip to content

Commit

Permalink
enhancement: Added latest version as default project card version
Browse files Browse the repository at this point in the history
  • Loading branch information
Pramit Dutta committed Feb 22, 2024
1 parent 042e0cb commit 05d3d8f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/pages/BesVersionHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,18 @@ function BesVersionHistory() {
const [selectedOption, setSelectedOption] = React.useState("");

try {
if (!selectedOption && versionSummary[0].version) {
setSelectedOption(versionSummary[0].version);
if (!selectedOption && versionSummary){
const latestVersion = versionSummary.reduce((latest, current) => {
const currentDate = new Date(current.release_date);
const latestDate = new Date(latest.release_date);
return currentDate > latestDate ? current : latest;
}, versionSummary[0]);
if (latestVersion.version){
setSelectedOption(latestVersion.version);
}
}
} catch (e: any) {
//ignore
console.log(e);
}

const handleOptionChange = (event: any) => {
Expand Down Expand Up @@ -311,8 +318,6 @@ function BesVersionHistory() {
.join("");
const envpath: string = `https://github.com/Be-Secure/besecure-ce-env-repo/tree/master/${camelCaseString}/`;
const languages = Object.keys(item.language) // To get the list of languages
// console.log(item.owner)
// debugger
return (
<>
<Card key={`TOPCARD${index}`} style={{ marginTop: "-1.5rem", paddingTop: "6px" }}>
Expand Down Expand Up @@ -362,7 +367,7 @@ function BesVersionHistory() {
fontSize: "15px",
height: "fit-content"
}}
>
>
{versionSummary.map((option: any, index1: any) => (
<MenuItem
key={`TOPMENUITEM${index}${index1}`}
Expand Down

0 comments on commit 05d3d8f

Please sign in to comment.