linting and error amends

This commit is contained in:
Samantha Kellow 2023-11-24 09:11:29 +00:00
parent 4e33afc9dc
commit b349798017
2 changed files with 6 additions and 7 deletions

View File

@ -18,7 +18,7 @@ export function SustainabilityInfo() {
<AccordionItem id={credential} key={credential} value={credential}> <AccordionItem id={credential} key={credential} value={credential}>
<AccordionTrigger className="text-xs py-3">{credentials[credential as keyof typeof credentials].title}</AccordionTrigger> <AccordionTrigger className="text-xs py-3">{credentials[credential as keyof typeof credentials].title}</AccordionTrigger>
<AccordionContent> <AccordionContent>
"{credentials[credential as keyof typeof credentials].excerpt}" <br /><br/> `{credentials[credential as keyof typeof credentials].excerpt}` <br /><br/>
<Link <Link
className="text-bold pt-6" className="text-bold pt-6"
href={credentials[credential as keyof typeof credentials].link} href={credentials[credential as keyof typeof credentials].link}

View File

@ -26,18 +26,13 @@ export function VariantSelector({
}: { }: {
options: ProductOption[]; options: ProductOption[];
variants: ProductVariant[]; variants: ProductVariant[];
setSelectedVariant: (newVariant: ProductVariant) => void, setSelectedVariant: (newVariant: OptimizedVariant | undefined) => void,
}) { }) {
const pathname = usePathname(); const pathname = usePathname();
const currentParams = useSearchParams(); const currentParams = useSearchParams();
const router = useRouter(); const router = useRouter();
const hasNoOptionsOrJustOneOption = const hasNoOptionsOrJustOneOption =
!options.length || (options.length === 1 && options[0]?.values.length === 1); !options.length || (options.length === 1 && options[0]?.values.length === 1);
if (hasNoOptionsOrJustOneOption) {
return null;
}
// Discard any unexpected options or values from url and create params map. // Discard any unexpected options or values from url and create params map.
const paramsMap: ParamsMap = Object.fromEntries( const paramsMap: ParamsMap = Object.fromEntries(
Array.from(currentParams.entries()).filter(([key, value]) => Array.from(currentParams.entries()).filter(([key, value]) =>
@ -88,6 +83,10 @@ export function VariantSelector({
setSelectedVariant(selectedVariant); setSelectedVariant(selectedVariant);
}, [selectedVariantUrl]); }, [selectedVariantUrl]);
if (hasNoOptionsOrJustOneOption) {
return null;
}
if (currentUrl !== selectedVariantUrl) { if (currentUrl !== selectedVariantUrl) {
router.replace(selectedVariantUrl); router.replace(selectedVariantUrl);
} }