Country name, 404

This commit is contained in:
2023-07-09 21:41:47 +04:00
parent 6438d1900c
commit feec2dd87e
5 changed files with 24 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import { Link } from '@chakra-ui/next-js'
import { Box, Button, Flex, Heading, Image, List, ListIcon, ListItem, SimpleGrid, Text } from '@chakra-ui/react'
import { FaFacebookSquare, FaLinkedin, FaTwitterSquare } from 'react-icons/fa'
import { TbWorldWww } from 'react-icons/tb'
import { iso31661 } from 'iso-3166'
export const getStaticPaths = async () => {
const url = new URL(`${process.env.NEXT_PUBLIC_DIRECTUS_API_URL}/items/vendors`)
@@ -34,7 +35,7 @@ export const getStaticProps = async ({ params: { slug } }) => {
data: [vendor],
} = await res.json()
return { props: vendor }
return { props: { ...vendor, country: iso31661.find((iso) => iso.alpha3 === vendor.country)?.name || '' } }
}
export default function VendorPage(vendor) {
@@ -84,12 +85,7 @@ export default function VendorPage(vendor) {
<br />
</>
)}
{vendor.country && (
<>
{vendor.country}
<br />
</>
)}
{vendor.country && <>{vendor.country}</>}
</Text>
</Box>
<Box>