-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49e1431
commit e23b3a2
Showing
2 changed files
with
37 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
import { getActiveSponsors } from "@/lib/api"; | ||
import { formatAllTools } from "./formatToolContent"; | ||
|
||
const getSponsors = async () => { | ||
let sponsors = await getActiveSponsors(); | ||
sponsors = formatAllTools({ tools: sponsors.posts, tagNumber: 1 }); | ||
|
||
const getSponsors = async() =>{ | ||
let sponsors = await getActiveSponsors(); | ||
sponsors = formatAllTools({ tools: sponsors.posts, tagNumber: 1 }); | ||
const navSponsorId = "2"; | ||
// const navSponsor = | ||
// sponsors?.find(sponsor => sponsor.weeks?. === navSponsorId) || null; | ||
|
||
const navSponsorId = '2'; | ||
const navSponsor = | ||
sponsors?.find(sponsor => sponsor.productId === navSponsorId) || null; | ||
|
||
return{ | ||
navSponsor, | ||
sponsors | ||
// let navSponsor = null; | ||
// console.log(sponsors) | ||
// for (let i = 0; i < sponsors.length; i++) { | ||
// console.log(sponsors[i].weeks?.id, navSponsorId) | ||
// if (sponsors[i].weeks?.id === navSponsorId) { | ||
// navSponsor = sponsors[i]; | ||
// break; | ||
// } | ||
// } | ||
|
||
//find the sponsor where a week's website array object is equal to the navSponsorId | ||
let navSponsor = null; | ||
for (let i = 0; i < sponsors.length; i++) { | ||
if (sponsors[i].weeks) { | ||
for (let j = 0; j < sponsors[i].weeks.website.length; j++) { | ||
if (sponsors[i].weeks.website[j].productId === navSponsorId) { | ||
navSponsor = sponsors[i]; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
if (navSponsor) break; // If navSponsor is found, break the outer loop | ||
} | ||
|
||
|
||
return { | ||
navSponsor, | ||
sponsors, | ||
}; | ||
}; | ||
|
||
export default getSponsors; |