fix: handle nullable ads data and ensure safe filtering in advertisements
This commit is contained in:
@@ -28,11 +28,13 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||
const { data: subscribePlanData } = await getSubscribePlan()
|
||||
const { data: categoriesData } = await getCategories()
|
||||
let { data: adsData } = await getAds()
|
||||
adsData = adsData.filter(
|
||||
(ad) =>
|
||||
new Date(ad.start_date) <= new Date() &&
|
||||
new Date(ad.end_date) >= new Date(),
|
||||
)
|
||||
if (adsData) {
|
||||
adsData = adsData?.filter(
|
||||
(ad) =>
|
||||
new Date(ad.start_date) <= new Date() &&
|
||||
new Date(ad.end_date) >= new Date(),
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
userData,
|
||||
|
||||
Reference in New Issue
Block a user