diff --git a/src/components/matrix/MaProductForm.tsx b/src/components/matrix/MaProductForm.tsx index f0aed9c..8b1507a 100644 --- a/src/components/matrix/MaProductForm.tsx +++ b/src/components/matrix/MaProductForm.tsx @@ -1,6 +1,6 @@ import { Collapse, Alert, TextField, Button, Box } from '@mui/material' import { useRouter } from 'next-nprogress-bar' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import { MaProduct } from 'solar-js-sdk' @@ -11,6 +11,9 @@ export interface MatrixProductForm { alias: string description: string introduction: string + icon: string + previews: string[] + tags: string[] } export default function MaProductForm({ @@ -28,11 +31,24 @@ export default function MaProductForm({ alias: defaultValue?.alias ?? '', description: defaultValue?.description ?? '', introduction: defaultValue?.meta?.introduction ?? '', + icon: defaultValue?.icon ?? '', }, }) const router = useRouter() + const [previews, setPreviews] = useState([]) + const [tags, setTags] = useState([]) + + useEffect(() => { + if (defaultValue?.previews) { + setPreviews(defaultValue.previews) + } + if (defaultValue?.tags) { + setTags(defaultValue.tags) + } + }, []) + const [error, setError] = useState(null) const [busy, setBusy] = useState(false) @@ -47,7 +63,11 @@ export default function MaProductForm({ async function submit(data: MatrixProductForm) { try { setBusy(true) - await onSubmit(data) + await onSubmit({ + ...data, + previews, + tags, + }) callback() } catch (err: any) { setError(err.toString()) @@ -65,10 +85,26 @@ export default function MaProductForm({ + + + setPreviews(val.target.value.split(',').map((v) => v.trim()))} + /> + + setTags(val.target.value.split(',').map((v) => v.trim()))} + /> + diff --git a/src/pages/console/matrix/products/[id]/index.tsx b/src/pages/console/matrix/products/[id]/index.tsx index 2fd4d97..5ec355b 100644 --- a/src/pages/console/matrix/products/[id]/index.tsx +++ b/src/pages/console/matrix/products/[id]/index.tsx @@ -1,9 +1,10 @@ import { ConsoleLayout, getConsoleStaticProps } from '@/components/layouts/ConsoleLayout' import { Box, Button, Container, Typography, Grid2 as Grid, Card, CardContent, CardActions } from '@mui/material' import { GetServerSideProps, InferGetServerSidePropsType } from 'next' -import { sni, MaProduct, MaRelease } from 'solar-js-sdk' +import { sni, MaProduct, MaRelease, getAttachmentUrl } from 'solar-js-sdk' import { useEffect, useState } from 'react' import NextLink from 'next/link' +import Image from 'next/image' export const getServerSideProps: GetServerSideProps = (async (context) => { const id = context.params!.id @@ -45,52 +46,63 @@ export default function ProductDetails({ product }: InferGetServerSidePropsType< return ( - - - - {product.name} - - {product.description} - + <> + {product.previews && ( + {product.name} + )} - - - Releases - + + + + {product.name} + + {product.description} + - - - + + + Releases + - - {releases.map((r: any) => ( - - - - {r.version} - - {r.meta.title} - - - {r.type == 0 ? 'Full Release' : 'Patch Release'} - + + + - {r.meta.description} - - - - - - - - - - ))} - - - + + {releases.map((r: any) => ( + + + + {r.version} + + {r.meta.title} + + + {r.type == 0 ? 'Full Release' : 'Patch Release'} + + + {r.meta.description} + + + + + + + + + + ))} + + + + ) }