Skip to content

Commit

Permalink
Added Default Image for broken images
Browse files Browse the repository at this point in the history
  • Loading branch information
promiseonuoha committed Nov 15, 2024
1 parent f200bd4 commit 2e4db9e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
15 changes: 11 additions & 4 deletions app/(guest)/jobs/components/job-grid-tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Link from 'next/link'
import { formatNumber, formatUnitText } from '@/configs/jobs/format'
import { useRouter } from 'next/navigation'
import { useState } from 'react'

export default function JobGridTile({
item,
Expand All @@ -14,6 +15,10 @@ export default function JobGridTile({
notruncate,
}) {
const router = useRouter()
const [imgSrc, setImgSrc] = useState(
item?.hiringOrganization?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg',
)

return (
<div
Expand All @@ -29,16 +34,18 @@ export default function JobGridTile({
: 'w-[calc(100%-350px)] tablet:w-full large:w-[calc(100%-384px)]'
}`}>
<img
src={
item?.hiringOrganization?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
src={imgSrc}
alt=""
className={`${
dashboard
? 'large:w-[49px] large:h-[49px] w-10 h-10 tablet:w-8 tablet:h-8'
: 'large:w-16 large:h-16 w-[50px] tablet:w-10 tablet:h-10 h-[50px]'
} rounded-full object-cover`}
onError={() =>
setImgSrc(
'/images/guest-layout/hero/filled_briefcase.svg',
)
}
/>
<div
className={`flex flex-col w-[calc(100%-64px)] ${
Expand Down
7 changes: 5 additions & 2 deletions app/job-seeker/dashboard/components/more-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import { useJobs } from '@/hooks/jobs'
import React, { useState, useEffect } from 'react'
import Cookies from 'js-cookie'
import { useRouter } from 'next/navigation'
import Link from 'next/link'
import { formatNumber, formatUnitText } from '@/configs/jobs/format'

export default function MoreJobs() {
const { getRecommendedJobs } = useJobs()
const [data, setData] = useState(null)
const [loading, setLoading] = useState(false)
const router = useRouter()

let url = `/jobs/recommend`
const token = Cookies.get('analogueshifts')
Expand Down Expand Up @@ -47,6 +45,11 @@ export default function MoreJobs() {
item?.hiringOrganization?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
onError={e => {
e.target.onerror = null
e.target.src =
'/images/guest-layout/hero/filled_briefcase.svg'
}}
alt=""
className="w-[33px] h-[33px] rounded-full object-cover"
/>
Expand Down
5 changes: 5 additions & 0 deletions app/recruiter/companies/components/companies-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export default function CompaniesOverview() {
item?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
onError={e => {
e.target.onerror = null
e.target.src =
'/images/guest-layout/hero/filled_briefcase.svg'
}}
alt=""
className={`w-[33px] min-w-[33px] min-h-[33px] h-[33px] rounded-full object-cover`}
/>
Expand Down
5 changes: 5 additions & 0 deletions app/recruiter/dashboard/components/jobs-posted.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default function JobsPosted() {
item?.hiringOrganization?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
onError={e => {
e.target.onerror = null
e.target.src =
'/images/guest-layout/hero/filled_briefcase.svg'
}}
alt=""
className={`w-8 min-w-8 min-h-8 h-8 rounded-full object-cover`}
/>
Expand Down
5 changes: 5 additions & 0 deletions app/recruiter/dashboard/components/more-jobs-posted.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default function MoreJobsPosted({ data }) {
item?.hiringOrganization?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
onError={e => {
e.target.onerror = null
e.target.src =
'/images/guest-layout/hero/filled_briefcase.svg'
}}
alt=""
className="w-[33px] h-[33px] rounded-full object-cover"
/>
Expand Down
5 changes: 5 additions & 0 deletions app/recruiter/hire/components/hires-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export default function HiresOverview() {
?.logo ||
'/images/guest-layout/hero/filled_briefcase.svg'
}
onError={e => {
e.target.onerror = null
e.target.src =
'/images/guest-layout/hero/filled_briefcase.svg'
}}
alt=""
className={`w-10 min-w-10 min-h-10 h-10 rounded-full object-cover`}
/>
Expand Down

0 comments on commit 2e4db9e

Please sign in to comment.