Skip to content

Commit 6a63a4e

Browse files
committed
Make linter happy
1 parent 15cb1dd commit 6a63a4e

3 files changed

Lines changed: 67 additions & 74 deletions

File tree

src/app/sponsors/gallery.tsx

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,61 @@
11
"use client";
22
import Image from "next/image";
3-
import { useEffect, useState } from "react";
3+
import { useEffect, useState, useMemo } from "react";
44

55
type Sponsor = {
66
src: string;
77
alt: string;
88
href: string | null;
99
};
1010

11+
let sponsors: Sponsor[] = [
12+
{
13+
src: "/sponsors/abc.jpg",
14+
alt: "Abergavenny Brake & Clutch",
15+
href: "http://www.abcmotorfactors.com/",
16+
},
17+
{
18+
src: "/sponsors/cwbs.jpg",
19+
alt: "Caldicot Windows & Building Services",
20+
href: "mailto:chippyatwork78@gmail.com",
21+
},
22+
{
23+
src: "/sponsors/muddyseries4x4.jpg",
24+
alt: "Muddy Series 4x4",
25+
href: "https://www.ebay.co.uk/str/seriesuser4x4",
26+
},
27+
{
28+
src: "/sponsors/whitecliff4x4.jpg",
29+
alt: "Whitecliff 4x4",
30+
href: "https://www.whitecliff4x4.co.uk/",
31+
},
32+
{
33+
src: "/sponsors/lewis-thomas-spares.png",
34+
alt: "Lewis Thomas Spares",
35+
href: "tel:+44 7876 826194",
36+
},
37+
{
38+
src: "/sponsors/wye-valley-carpet-and-upholstery-cleaners.png",
39+
alt: "Wye Valley Carpet and Upholstery Cleaners",
40+
href: "mailto:wyevalleycarpetcleaners@gmail.com",
41+
},
42+
{
43+
src: "/sponsors/amorgan-property-maintenance.png",
44+
alt: "A.Morgan Property Maintenance",
45+
href: "tel:+44 1495 215381",
46+
},
47+
{
48+
src: "/sponsors/ak-inspection-services.jpg",
49+
alt: "AK Inspection Services",
50+
href: "tel:+44 7765 196119",
51+
},
52+
].sort(() => Math.random() - 0.5);
53+
1154
export default function SponsorGallery() {
1255
const [images, setImages] = useState<Sponsor[]>([]);
1356

1457
useEffect(() => {
15-
let images: Sponsor[] = [
16-
{
17-
src: "/sponsors/abc.jpg",
18-
alt: "Abergavenny Brake & Clutch",
19-
href: "http://www.abcmotorfactors.com/",
20-
},
21-
{
22-
src: "/sponsors/cwbs.jpg",
23-
alt: "Caldicot Windows & Building Services",
24-
href: "mailto:chippyatwork78@gmail.com",
25-
},
26-
{
27-
src: "/sponsors/muddyseries4x4.jpg",
28-
alt: "Muddy Series 4x4",
29-
href: "https://www.ebay.co.uk/str/seriesuser4x4",
30-
},
31-
{
32-
src: "/sponsors/whitecliff4x4.jpg",
33-
alt: "Whitecliff 4x4",
34-
href: "https://www.whitecliff4x4.co.uk/",
35-
},
36-
{
37-
src: "/sponsors/lewis-thomas-spares.png",
38-
alt: "Lewis Thomas Spares",
39-
href: "tel:+44 7876 826194",
40-
},
41-
{
42-
src: "/sponsors/wye-valley-carpet-and-upholstery-cleaners.png",
43-
alt: "Wye Valley Carpet and Upholstery Cleaners",
44-
href: "mailto:wyevalleycarpetcleaners@gmail.com",
45-
},
46-
{
47-
src: "/sponsors/amorgan-property-maintenance.png",
48-
alt: "A.Morgan Property Maintenance",
49-
href: "tel:+44 1495 215381",
50-
},
51-
{
52-
src: "/sponsors/ak-inspection-services.jpg",
53-
alt: "AK Inspection Services",
54-
href: "tel:+44 7765 196119",
55-
},
56-
];
57-
58-
images = images.sort(() => Math.random() - 0.5);
59-
setImages(images);
58+
(async () => setImages(sponsors))();
6059
}, []);
6160

6261
if (images.length == 0) {

src/components/footer.tsx

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@
22
import Link from "next/link";
33
import { use, useEffect, useState, useCallback, useMemo } from "react";
44

5-
export default function Footer() {
6-
const sponsors = useMemo(() => {
7-
return [
8-
"Caldicot Windows & Building Services",
9-
"Abergavenny Brake & Clutch",
10-
"Muddy Series 4X4 Parts",
11-
"Whitecliff 4X4",
12-
"AK Inspection Services Ltd",
13-
"A.Morgan Property Maintenance",
14-
"Wye Valley Carpet & Upholstery Cleaners",
15-
"Lewis Thomas Spares",
16-
];
17-
}, []);
18-
19-
const [sponsorIndex, setSponsorIndex] = useState(-1);
5+
const sponsors = [
6+
"Caldicot Windows & Building Services",
7+
"Abergavenny Brake & Clutch",
8+
"Muddy Series 4X4 Parts",
9+
"Whitecliff 4X4",
10+
"AK Inspection Services Ltd",
11+
"A.Morgan Property Maintenance",
12+
"Wye Valley Carpet & Upholstery Cleaners",
13+
"Lewis Thomas Spares",
14+
];
2015

21-
const switchSponsor = useCallback(() => {
22-
let index = Math.floor(Math.random() * sponsors.length);
23-
24-
setSponsorIndex(index);
25-
}, [sponsors]);
16+
export default function Footer() {
17+
const [sponsorIndex, setSponsorIndex] = useState<number>(-1);
2618

2719
useEffect(() => {
28-
switchSponsor();
20+
const stepSponsor = async () => {
21+
setSponsorIndex(Math.floor(Math.random() * sponsors.length));
22+
};
2923

30-
const intervalId = setInterval(() => {
31-
switchSponsor();
32-
}, 5000);
24+
const intervalId = setInterval(stepSponsor, 5000);
3325

3426
return () => clearInterval(intervalId);
35-
}, [switchSponsor]);
27+
}, [sponsorIndex]);
3628

3729
return (
3830
<main>

src/components/navbar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ import Image from "next/image";
99
export default function Navbar() {
1010
const [navbarOpen, setNavbarOpen] = React.useState(false);
1111

12-
function navbarToggle() {
12+
const navbarToggle = () => {
1313
setNavbarOpen(!navbarOpen);
14-
}
14+
};
1515

1616
const pathname = usePathname();
1717

1818
useEffect(() => {
19-
setNavbarOpen(false);
19+
(async () => {
20+
setNavbarOpen(false);
21+
})();
2022
}, [pathname]);
2123

2224
return (

0 commit comments

Comments
 (0)