mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
28 lines
674 B
TypeScript
28 lines
674 B
TypeScript
import { Category, Link } from "../types"
|
|
|
|
export function BuildCategory({ id, name, order, links = [], createdAt, updatedAt }): Category {
|
|
return {
|
|
id,
|
|
name,
|
|
links: links.map((link) => BuildLink(link, { categoryId: id, categoryName: name })),
|
|
order,
|
|
createdAt,
|
|
updatedAt
|
|
}
|
|
}
|
|
|
|
export function BuildLink({ id, name, url, order, favorite, createdAt, updatedAt }, { categoryId, categoryName }): Link {
|
|
return {
|
|
id,
|
|
name,
|
|
url,
|
|
category: {
|
|
id: categoryId,
|
|
name: categoryName
|
|
},
|
|
order,
|
|
favorite,
|
|
createdAt,
|
|
updatedAt
|
|
}
|
|
} |