import Link from 'next/link' import { Fragment } from 'react' import { cn } from 'ui' import { TroubleshootingFilter } from './Troubleshooting.ui.client' import { type ITroubleshootingEntry, type ITroubleshootingMetadata, getArticleSlug, getTroubleshootingUpdatedDates, } from './Troubleshooting.utils' import { formatError, TROUBLESHOOTING_DATA_ATTRIBUTES, TROUBLESHOOTING_CONTAINER_ID, } from './Troubleshooting.utils.shared' export async function TroubleshootingPreview({ entry }: { entry: ITroubleshootingEntry }) { const dateUpdated = entry.data.database_id.startsWith('pseudo-') ? new Date() : (await getTroubleshootingUpdatedDates()).get(entry.data.database_id) const keywords = [...entry.data.topics, ...(entry.data.keywords ?? [])] const attributes = { [TROUBLESHOOTING_DATA_ATTRIBUTES.QUERY_ATTRIBUTE]: TROUBLESHOOTING_DATA_ATTRIBUTES.QUERY_VALUE_ENTRY, [TROUBLESHOOTING_DATA_ATTRIBUTES.PRODUCTS_LIST_ATTRIBUTE]: entry.data.topics.join(','), [TROUBLESHOOTING_DATA_ATTRIBUTES.KEYWORDS_LIST_ATTRIBUTE]: keywords.join(','), [TROUBLESHOOTING_DATA_ATTRIBUTES.ERRORS_LIST_ATTRIBUTE]: entry.data.errors ?.map((error) => formatError(error)) .join(','), } return (

{entry.data.title}

{entry.data.errors?.length && entry.data.errors.length > 0 && ( {(entry.data.errors || []) .map(formatError) .filter(Boolean) .map((error, index) => ( {error} {index < (entry.data.errors?.length || 0) - 1 ? ', ' : ''} ))} )}
{entry.data.topics.map((topic) => ( {topic[0].toUpperCase() + topic.slice(1)} ))}
{dateUpdated && (() => { const options = { month: 'short', day: 'numeric' } as Intl.DateTimeFormatOptions if (dateUpdated.getFullYear() !== new Date().getFullYear()) { options.year = 'numeric' } return dateUpdated.toLocaleDateString(undefined, options) })()}
) } export function TroubleshootingHeader({ title, description, keywords, products, errors, }: { title: string description: string keywords: Array products?: Array errors: ITroubleshootingMetadata['errors'] }) { return (

{title}

{description}


) } export function TroubleshootingEntries({ name, entries, }: { name: string entries: Array }) { return (

Matching troubleshooting entries

{entries.length === 0 ? (

No troubleshooting guides available for {name} yet.

) : (
    {entries.map((entry) => (
  • ))}
)}
) }