Files
website/data/business.ts
T

230 lines
7.3 KiB
TypeScript

import { featuredProducers } from "@/data/home";
import { defaultBlogPosts, defaultPortfolios } from "@/data/details";
export type BusinessTabId =
| "products"
| "contact"
| "blog"
| "gallery"
| "portfolios";
export type BusinessDetail = {
slug: string;
name: string;
tagline: string;
breadcrumbs: string[];
hero: string;
logo: string;
since: string;
province: string;
activeProducts: string;
telephone: string;
description: string;
productCategories: string[];
products: {
id: string;
title: string;
image: string;
rating: string;
minOrder: string;
shipsIn: string;
category: string;
}[];
contact: {
address: string;
landlines: string[];
socials: { network: string; handle: string; icon: string }[];
map: string;
};
blogCategories: string[];
posts: {
id: string;
slug: string;
title: string;
excerpt: string;
image: string;
date: string;
author: string;
}[];
gallery: { id: string; image: string; tall?: boolean; medium?: boolean }[];
portfolioCategories: string[];
portfolios: {
id: string;
slug: string;
title: string;
description: string;
image: string;
}[];
};
export const businessTabs: { id: BusinessTabId; label: string }[] = [
{ id: "products", label: "Products" },
{ id: "contact", label: "Contact info" },
{ id: "blog", label: "blog" },
{ id: "gallery", label: "gallery" },
{ id: "portfolios", label: "Portfolios" },
];
const productImage = "/images/business/product-necklace.png";
const productAlt = "/images/business/product-alt.png";
const productRing = "/images/business/product-ring.png";
const galleryImage = "/images/business/gallery.jpg";
const blogImage = "/images/business/blog.jpg";
export const businesses: BusinessDetail[] = [
{
slug: "ayoubi-gallery",
name: "ayoubi gallery",
tagline: "we produce bread materials",
breadcrumbs: ["producers", "industry", "Food", "processed"],
hero: "/images/business/hero.jpg",
logo: "/images/business/logo.png",
since: "2018",
province: "Tehran",
activeProducts: "121",
telephone: "+9821-31634",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
productCategories: ["All", "Neckleses", "Earrings", "Bracelet"],
products: Array.from({ length: 6 }, (_, i) => ({
id: `p-${i + 1}`,
title: "Gold scarlet necklace",
image: [productImage, productAlt, productRing][i % 3],
rating: "4.3",
minOrder: "3",
shipsIn: "7",
category: ["Neckleses", "Earrings", "Bracelet"][i % 3],
})),
contact: {
address: "Tehran, Jordan St., beside Sina Bank, number 27",
landlines: ["+98 212243248", "+98 212243249"],
socials: [
{
network: "instagram",
handle: "ayoubi.jewelery",
icon: "/images/icons/instagram.png",
},
{
network: "Telegram",
handle: "ayoubi.jewelery",
icon: "/images/icons/telegram.png",
},
{
network: "Facebook",
handle: "ayoubi.jewelery",
icon: "/images/icons/facebook.png",
},
{
network: "Whatsapp",
handle: "ayoubi.jewelery",
icon: "/images/icons/telegram.png",
},
],
map: "/images/business/map.png",
},
blogCategories: ["All", "Neckleses", "Earrings", "Bracelet"],
posts: Array.from({ length: 6 }, (_, i) => ({
id: `b-${i + 1}`,
slug: i === 0 ? "gold-scarlet-necklace" : `gold-scarlet-necklace-${i + 1}`,
title: "Gold scarlet necklace",
excerpt:
"we will show your business to verity of visitor around the world.we will show your business to verity of visitor around the world.we will show your business to verity of visitor around the world.",
image: "/images/blog/thumb.jpg",
date: "September 11",
author: "Mohammadi",
})),
gallery: [
{ id: "g1", image: galleryImage, tall: true },
{ id: "g2", image: productAlt },
{ id: "g3", image: blogImage, medium: true },
{ id: "g4", image: productImage },
{ id: "g5", image: "/images/producers/cover-jewelry.png", tall: true },
{ id: "g6", image: productRing, tall: true },
{ id: "g7", image: galleryImage },
],
portfolioCategories: ["All", "Ring", "Earrings", "Bracelet"],
portfolios: [
{
id: "pf1",
slug: "gold-scarlet-necklace",
title: "Gold scarlet necklace",
description: "we will show your business to verity of visitor ",
image: "/images/portfolio/main.jpg",
},
{
id: "pf2",
slug: "gold-scarlet-necklace-2",
title: "Gold scarlet necklace",
description: "we will show your business to verity of visitor ",
image: "/images/business/portfolio-1.jpg",
},
{
id: "pf3",
slug: "gold-scarlet-necklace-3",
title: "Gold scarlet necklace",
description: "we will show your business to verity of visitor ",
image: "/images/business/portfolio-3.jpg",
},
],
},
];
function fromProducer(slug: string): BusinessDetail | undefined {
const producer = featuredProducers.find((p) => p.slug === slug);
if (!producer) return undefined;
const base = businesses[0];
return {
...base,
slug: producer.slug,
name: producer.name,
tagline: producer.tagline,
logo: producer.logo,
activeProducts: producer.products,
since: producer.since,
};
}
export function getBusinessBySlug(slug: string) {
return businesses.find((b) => b.slug === slug) ?? fromProducer(slug);
}
export function getAllBusinessSlugs() {
const detailSlugs = businesses.map((b) => b.slug);
const producerSlugs = featuredProducers.map((p) => p.slug);
return [...new Set([...detailSlugs, ...producerSlugs])];
}
export function getBusinessBlogPost(businessSlug: string, postSlug: string) {
const business = getBusinessBySlug(businessSlug);
if (!business) return null;
const list = defaultBlogPosts.map((post, i) => ({
...post,
image: business.posts[i]?.image ?? post.image,
slug: business.posts[i]?.slug ?? post.slug,
}));
const post = list.find((p) => p.slug === postSlug);
if (!post) return null;
const related = list.filter((p) => p.slug !== post.slug).slice(0, 4);
return { business, post: { ...post, hero: "/images/blog/hero.jpg" }, related };
}
export function getBusinessPortfolio(businessSlug: string, portfolioSlug: string) {
const business = getBusinessBySlug(businessSlug);
if (!business) return null;
const list = defaultPortfolios.map((item, i) => ({
...item,
slug: business.portfolios[i]?.slug ?? item.slug,
image: business.portfolios[i]?.image ?? item.image,
images:
i === 0
? item.images
: [
business.portfolios[i]?.image ?? item.image,
...item.images.slice(1),
],
}));
const portfolio = list.find((p) => p.slug === portfolioSlug);
if (!portfolio) return null;
return { business, portfolio };
}