Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

fix(registry): redesign request detail page with SectionRow pattern and pending stripe

vholikf95339893544
diff --git a/packages/registry/r/requests.json b/packages/registry/r/requests.json
index b5762a24e..f7f2c1cb1 100644
--- a/packages/registry/r/requests.json
+++ b/packages/registry/r/requests.json
@@ -252,7 +252,7 @@
},
{
"path": "requests/admin/pages/requests/[type]/[id]/page.tsx",
- "content": "import { useParams, Link } from \"react-router-dom\";\nimport { useTranslation } from \"react-i18next\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport {\n Avatar,\n Badge,\n Button,\n Container,\n Heading,\n StatusBadge,\n Text,\n toast,\n usePrompt,\n} from \"@medusajs/ui\";\nimport { TriangleRightMini } from \"@medusajs/icons\";\n\nimport { SingleColumnPage } from \"@mercurjs/dashboard-shared\";\nimport {\n useRequest,\n useAcceptRequest,\n useRejectRequest,\n} from \"../../../../hooks/api/requests\";\nimport { client } from \"../../../../lib/client\";\n\nconst statusColor = (status: string) => {\n switch (status) {\n case \"accepted\":\n return \"green\" as const;\n case \"pending\":\n return \"orange\" as const;\n case \"rejected\":\n return \"red\" as const;\n default:\n return \"grey\" as const;\n }\n};\n\nconst TYPE_LABELS: Record<string, string> = {\n product_category: \"Category\",\n product_collection: \"Collection\",\n product_tag: \"Tag\",\n product_type: \"Type\",\n};\n\nconst ENTITY_FIELDS: Record<string, { key: string; label: string }[]> = {\n product_category: [\n { key: \"name\", label: \"Name\" },\n { key: \"handle\", label: \"Handle\" },\n { key: \"description\", label: \"Description\" },\n { key: \"is_active\", label: \"Active\" },\n { key: \"is_internal\", label: \"Internal\" },\n ],\n product_collection: [\n { key: \"title\", label: \"Title\" },\n { key: \"handle\", label: \"Handle\" },\n ],\n product_tag: [{ key: \"value\", label: \"Value\" }],\n product_type: [{ key: \"value\", label: \"Value\" }],\n};\n\nconst ENTITY_NAME_KEY: Record<string, string> = {\n product_category: \"name\",\n product_collection: \"title\",\n product_tag: \"value\",\n product_type: \"value\",\n};\n\nconst formatFieldValue = (key: string, value: unknown): string => {\n if (value === null || value === undefined) return \"—\";\n if (typeof value === \"boolean\") return value ? \"Yes\" : \"No\";\n return String(value);\n};\n\nconst useSeller = (id?: string | null) => {\n const { data, ...rest } = useQuery({\n queryKey: [\"seller\", id],\n queryFn: () => client.admin.sellers.$id.query({ $id: id! }),\n enabled: !!id,\n });\n\n return { seller: (data as any)?.seller, ...rest };\n};\n\nconst useUser = (id?: string | null) => {\n const { data, ...rest } = useQuery({\n queryKey: [\"user\", id],\n queryFn: () => client.admin.users.$id.query({ $id: id! }),\n enabled: !!id,\n });\n\n return { user: (data as any)?.user, ...rest };\n};\n\nconst RequestDetailPage = () => {\n const { type, id } = useParams<{ type: string; id: string }>();\n const { t } = useTranslation();\n const prompt = usePrompt();\n\n const { request, isLoading, isError, error } = useRequest(type!, id!);\n\n const { mutateAsync: acceptRequest, isPending: isAccepting } =\n useAcceptRequest(type!, id!);\n\n const { mutateAsync: rejectRequest, isPending: isRejecting } =\n useRejectRequest(type!, id!);\n\n const customFields = (request?.custom_fields ?? {}) as Record<string, any>;\n\n const { seller } = useSeller(customFields?.submitter_id);\n const { user } = useUser(customFields?.reviewer_id);\n\n if (isLoading || !request) {\n return (\n <SingleColumnPage>\n <Container className=\"animate-pulse p-6\">\n <div className=\"h-6 w-48 rounded bg-gray-200\" />\n </Container>\n </SingleColumnPage>\n );\n }\n\n if (isError) throw error;\n\n const status = customFields?.request_status ?? \"draft\";\n const isPending = status === \"pending\";\n const entityFields = ENTITY_FIELDS[type!] ?? [];\n const typeLabel = TYPE_LABELS[type!] ?? type;\n const nameKey = ENTITY_NAME_KEY[type!] ?? \"name\";\n const entityName = (request as Record<string, any>)[nameKey] ?? request.id;\n\n const handleAccept = async () => {\n const res = await prompt({\n title: \"Accept request\",\n description:\n \"Are you sure you want to accept this request? This action will create the entity.\",\n verificationText: entityName,\n confirmText: t(\"actions.confirm\"),\n cancelText: t(\"actions.cancel\"),\n });\n\n if (!res) return;\n\n await acceptRequest(\n {},\n {\n onSuccess: () => {\n toast.success(\"Request accepted\");\n },\n onError: (err) => toast.error(err.message),\n },\n );\n };\n\n const handleReject = async () => {\n const res = await prompt({\n title: \"Reject request\",\n description:\n \"Are you sure you want to reject this request? This action cannot be undone.\",\n verificationText: entityName,\n confirmText: t(\"actions.confirm\"),\n cancelText: t(\"actions.cancel\"),\n });\n\n if (!res) return;\n\n await rejectRequest(\n {},\n {\n onSuccess: () => {\n toast.success(\"Request rejected\");\n },\n onError: (err) => toast.error(err.message),\n },\n );\n };\n\n return (\n <SingleColumnPage hasOutlet={false}>\n {/* Header */}\n <Container className=\"divide-y p-0\">\n <div className=\"flex items-center justify-between px-6 py-4\">\n <div className=\"flex items-center gap-x-4\">\n <Heading>{entityName}</Heading>\n <StatusBadge color={statusColor(status)}>\n {status.charAt(0).toUpperCase() + status.slice(1)}\n </StatusBadge>\n <Badge size=\"2xsmall\" color=\"grey\">\n {typeLabel}\n </Badge>\n </div>\n {isPending && (\n <div className=\"flex items-center gap-x-2\">\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={handleReject}\n disabled={isAccepting || isRejecting}\n >\n Reject\n </Button>\n <Button\n variant=\"primary\"\n size=\"small\"\n onClick={handleAccept}\n disabled={isAccepting || isRejecting}\n >\n Accept\n </Button>\n </div>\n )}\n </div>\n </Container>\n\n {/* Details */}\n <Container className=\"divide-y p-0\">\n <div className=\"px-6 py-4\">\n <Heading level=\"h2\">Details</Heading>\n </div>\n <div className=\"flex flex-col gap-y-3 px-6 py-4\">\n {entityFields.map(({ key, label }) => {\n const value = (request as Record<string, any>)[key];\n if (value === undefined) return null;\n return (\n <div key={key} className=\"grid grid-cols-2\">\n <Text size=\"small\" leading=\"compact\" weight=\"plus\">\n {label}\n </Text>\n <Text size=\"small\" className=\"text-ui-fg-subtle\">\n {formatFieldValue(key, value)}\n </Text>\n </div>\n );\n })}\n <div className=\"grid grid-cols-2\">\n <Text size=\"small\" leading=\"compact\" weight=\"plus\">\n Created\n </Text>\n <Text size=\"small\" className=\"text-ui-fg-subtle\">\n {new Date(request.created_at as string).toLocaleString()}\n </Text>\n </div>\n <div className=\"grid grid-cols-2\">\n <Text size=\"small\" leading=\"compact\" weight=\"plus\">\n Updated\n </Text>\n <Text size=\"small\" className=\"text-ui-fg-subtle\">\n {new Date(request.updated_at as string).toLocaleString()}\n </Text>\n </div>\n </div>\n </Container>\n\n {/* Submitter (Seller) */}\n <Container className=\"divide-y p-0\">\n <div className=\"px-6 py-4\">\n <Heading level=\"h2\">Submitter</Heading>\n </div>\n <div className=\"txt-small flex flex-col gap-2 px-2 pb-2\">\n {seller ? (\n <Link\n to={`/sellers/${seller.id}`}\n className=\"outline-none focus-within:shadow-borders-interactive-with-focus rounded-md [&:hover>div]:bg-ui-bg-component-hover\"\n >\n <div className=\"shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2 transition-colors\">\n <div className=\"flex items-center gap-3\">\n <Avatar\n src={seller.logo ?? undefined}\n fallback={seller.name?.charAt(0).toUpperCase() ?? \"S\"}\n />\n <div className=\"flex flex-1 flex-col\">\n <span className=\"text-ui-fg-base font-medium\">\n {seller.name}\n </span>\n </div>\n <div className=\"size-7 flex items-center justify-center\">\n <TriangleRightMini className=\"text-ui-fg-muted\" />\n </div>\n </div>\n </div>\n </Link>\n ) : (\n <div className=\"px-4 py-2\">\n <Text size=\"small\" className=\"text-ui-fg-muted\">\n {customFields?.submitter_id ?? \"—\"}\n </Text>\n </div>\n )}\n </div>\n </Container>\n\n {/* Reviewer (User) */}\n {(customFields?.reviewer_id || customFields?.reviewer_note) && (\n <Container className=\"divide-y p-0\">\n <div className=\"px-6 py-4\">\n <Heading level=\"h2\">Reviewer</Heading>\n </div>\n <div className=\"txt-small flex flex-col gap-2 px-2 pb-2\">\n {user ? (\n <div className=\"shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-2\">\n <div className=\"flex items-center gap-3\">\n <Avatar\n fallback={\n (user.first_name ?? user.email ?? \"U\")\n .charAt(0)\n .toUpperCase()\n }\n />\n <div className=\"flex flex-1 flex-col\">\n <span className=\"text-ui-fg-base font-medium\">\n {[user.first_name, user.last_name]\n .filter(Boolean)\n .join(\" \") || user.email}\n </span>\n {user.first_name && user.email && (\n <span className=\"text-ui-fg-muted text-xs\">\n {user.email}\n </span>\n )}\n </div>\n </div>\n </div>\n ) : customFields?.reviewer_id ? (\n <div className=\"px-4 py-2\">\n <Text size=\"small\" className=\"text-ui-fg-muted\">\n {customFields.reviewer_id}\n </Text>\n </div>\n ) : null}\n </div>\n {customFields?.reviewer_note && (\n <div className=\"px-6 py-4\">\n <Text size=\"small\" leading=\"compact\" weight=\"plus\" className=\"mb-1\">\n Note\n </Text>\n <Text size=\"small\" className=\"text-ui-fg-subtle\">\n {customFields.reviewer_note}\n </Text>\n </div>\n )}\n </Container>\n )}\n </SingleColumnPage>\n );\n};\n\nexport default RequestDetailPage;\n",
+ "content": "import { useParams, Link } from \"react-router-dom\";\nimport { useTranslation } from \"react-i18next\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport {\n Avatar,\n Badge,\n Button,\n Container,\n Heading,\n StatusBadge,\n Text,\n toast,\n usePrompt,\n} from \"@medusajs/ui\";\nimport { TriangleRightMini } from \"@medusajs/icons\";\n\nimport { SingleColumnPage } from \"@mercurjs/dashboard-shared\";\nimport {\n useRequest,\n useAcceptRequest,\n useRejectRequest,\n} from \"../../../../hooks/api/requests\";\nimport { client } from \"../../../../lib/client\";\n\nconst statusColor = (status: string) => {\n switch (status) {\n case \"accepted\":\n return \"green\" as const;\n case \"pending\":\n return \"orange\" as const;\n case \"rejected\":\n return \"red\" as const;\n default:\n return \"grey\" as const;\n }\n};\n\nconst TYPE_LABELS: Record<string, string> = {\n product_category: \"Category\",\n product_collection: \"Collection\",\n product_tag: \"Tag\",\n product_type: \"Type\",\n};\n\nconst ENTITY_FIELDS: Record<string, { key: string; label: string }[]> = {\n product_category: [\n { key: \"name\", label: \"Name\" },\n { key: \"handle\", label: \"Handle\" },\n { key: \"description\", label: \"Description\" },\n { key: \"is_active\", label: \"Active\" },\n { key: \"is_internal\", label: \"Internal\" },\n ],\n product_collection: [\n { key: \"title\", label: \"Title\" },\n { key: \"handle\", label: \"Handle\" },\n ],\n product_tag: [{ key: \"value\", label: \"Value\" }],\n product_type: [{ key: \"value\", label: \"Value\" }],\n};\n\nconst ENTITY_NAME_KEY: Record<string, string> = {\n product_category: \"name\",\n product_collection: \"title\",\n product_tag: \"value\",\n product_type: \"value\",\n};\n\nconst formatFieldValue = (key: string, value: unknown): string => {\n if (value === null || value === undefined) return \"-\";\n if (typeof value === \"boolean\") return value ? \"Yes\" : \"No\";\n return String(value);\n};\n\nconst SectionRow = ({\n title,\n value,\n}: {\n title: string;\n value?: string | null;\n}) => (\n <div className=\"text-ui-fg-subtle grid grid-cols-2 items-center gap-4 px-6 py-4\">\n <Text size=\"small\" weight=\"plus\" leading=\"compact\">\n {title}\n </Text>\n <Text size=\"small\" leading=\"compact\" className=\"whitespace-pre-line text-pretty\">\n {value ?? \"-\"}\n </Text>\n </div>\n);\n\nconst useSeller = (id?: string | null) => {\n const { data, ...rest } = useQuery({\n queryKey: [\"seller\", id],\n queryFn: () => client.admin.sellers.$id.query({ $id: id! }),\n enabled: !!id,\n });\n\n return { seller: (data as any)?.seller, ...rest };\n};\n\nconst useUser = (id?: string | null) => {\n const { data, ...rest } = useQuery({\n queryKey: [\"user\", id],\n queryFn: () => client.admin.users.$id.query({ $id: id! }),\n enabled: !!id,\n });\n\n return { user: (data as any)?.user, ...rest };\n};\n\nconst RequestDetailPage = () => {\n const { type, id } = useParams<{ type: string; id: string }>();\n const { t } = useTranslation();\n const prompt = usePrompt();\n\n const { request, isLoading, isError, error } = useRequest(type!, id!);\n\n const { mutateAsync: acceptRequest, isPending: isAccepting } =\n useAcceptRequest(type!, id!);\n\n const { mutateAsync: rejectRequest, isPending: isRejecting } =\n useRejectRequest(type!, id!);\n\n const customFields = (request?.custom_fields ?? {}) as Record<string, any>;\n\n const { seller } = useSeller(customFields?.submitter_id);\n const { user } = useUser(customFields?.reviewer_id);\n\n if (isLoading || !request) {\n return (\n <SingleColumnPage>\n <Container className=\"animate-pulse p-6\">\n <div className=\"h-6 w-48 rounded bg-gray-200\" />\n </Container>\n </SingleColumnPage>\n );\n }\n\n if (isError) throw error;\n\n const status = customFields?.request_status ?? \"draft\";\n const isPending = status === \"pending\";\n const entityFields = ENTITY_FIELDS[type!] ?? [];\n const typeLabel = TYPE_LABELS[type!] ?? type;\n const nameKey = ENTITY_NAME_KEY[type!] ?? \"name\";\n const entityName = (request as Record<string, any>)[nameKey] ?? request.id;\n\n const handleAccept = async () => {\n const res = await prompt({\n title: \"Accept request\",\n description:\n \"Are you sure you want to accept this request? This action will create the entity.\",\n verificationText: entityName,\n confirmText: t(\"actions.confirm\"),\n cancelText: t(\"actions.cancel\"),\n });\n\n if (!res) return;\n\n await acceptRequest(\n {},\n {\n onSuccess: () => toast.success(\"Request accepted\"),\n onError: (err) => toast.error(err.message),\n },\n );\n };\n\n const handleReject = async () => {\n const res = await prompt({\n title: \"Reject request\",\n description:\n \"Are you sure you want to reject this request? This action cannot be undone.\",\n verificationText: entityName,\n confirmText: t(\"actions.confirm\"),\n cancelText: t(\"actions.cancel\"),\n });\n\n if (!res) return;\n\n await rejectRequest(\n {},\n {\n onSuccess: () => toast.success(\"Request rejected\"),\n onError: (err) => toast.error(err.message),\n },\n );\n };\n\n return (\n <SingleColumnPage hasOutlet={false}>\n {/* General */}\n <div\n style={\n isPending\n ? {\n background:\n \"repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)\",\n }\n : undefined\n }\n className={isPending ? \"-m-4 mb-1 border-b border-l p-4\" : undefined}\n >\n <Container className=\"divide-y p-0\">\n <div className=\"flex items-center justify-between px-6 py-4\">\n <Heading>{entityName}</Heading>\n <div className=\"flex items-center gap-x-4\">\n <StatusBadge color={statusColor(status)}>\n {status.charAt(0).toUpperCase() + status.slice(1)}\n </StatusBadge>\n <Badge size=\"2xsmall\" color=\"grey\">\n {typeLabel}\n </Badge>\n {isPending && (\n <div className=\"flex items-center gap-x-2\">\n <Button\n variant=\"secondary\"\n size=\"small\"\n onClick={handleReject}\n disabled={isAccepting || isRejecting}\n >\n Reject\n </Button>\n <Button\n variant=\"primary\"\n size=\"small\"\n onClick={handleAccept}\n disabled={isAccepting || isRejecting}\n >\n Accept\n </Button>\n </div>\n )}\n </div>\n </div>\n {entityFields.map(({ key, label }) => {\n const value = (request as Record<string, any>)[key];\n if (value === undefined) return null;\n return (\n <SectionRow\n key={key}\n title={label}\n value={formatFieldValue(key, value)}\n />\n );\n })}\n </Container>\n </div>\n\n {/* Submitter (Seller) */}\n <Container className=\"divide-y p-0\">\n <div className=\"px-6 py-4\">\n <Heading level=\"h2\">Submitter</Heading>\n </div>\n <div className=\"px-6 py-4\">\n {seller ? (\n <Link\n to={`/sellers/${seller.id}`}\n className=\"outline-none focus-within:shadow-borders-interactive-with-focus rounded-md [&:hover>div]:bg-ui-bg-component-hover\"\n >\n <div className=\"shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-3 transition-colors\">\n <div className=\"flex items-center gap-3\">\n <Avatar\n src={seller.logo ?? undefined}\n fallback={seller.name?.charAt(0).toUpperCase() ?? \"S\"}\n />\n <div className=\"flex flex-1 flex-col\">\n <span className=\"text-ui-fg-base txt-small font-medium\">\n {seller.name}\n </span>\n </div>\n <div className=\"size-7 flex items-center justify-center\">\n <TriangleRightMini className=\"text-ui-fg-muted\" />\n </div>\n </div>\n </div>\n </Link>\n ) : (\n <Text size=\"small\" className=\"text-ui-fg-muted\">\n {customFields?.submitter_id ?? \"-\"}\n </Text>\n )}\n </div>\n </Container>\n\n {/* Reviewer (User) */}\n {(customFields?.reviewer_id || customFields?.reviewer_note) && (\n <Container className=\"divide-y p-0\">\n <div className=\"px-6 py-4\">\n <Heading level=\"h2\">Reviewer</Heading>\n </div>\n {(user || customFields?.reviewer_id) && (\n <div className=\"px-6 py-4\">\n {user ? (\n <div className=\"shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <Avatar\n fallback={\n (user.first_name ?? user.email ?? \"U\")\n .charAt(0)\n .toUpperCase()\n }\n />\n <div className=\"flex flex-1 flex-col\">\n <span className=\"text-ui-fg-base txt-small font-medium\">\n {[user.first_name, user.last_name]\n .filter(Boolean)\n .join(\" \") || user.email}\n </span>\n {user.first_name && user.email && (\n <span className=\"text-ui-fg-muted text-xs\">\n {user.email}\n </span>\n )}\n </div>\n </div>\n </div>\n ) : (\n <Text size=\"small\" className=\"text-ui-fg-muted\">\n {customFields.reviewer_id}\n </Text>\n )}\n </div>\n )}\n {customFields?.reviewer_note && (\n <SectionRow title=\"Note\" value={customFields.reviewer_note} />\n )}\n </Container>\n )}\n </SingleColumnPage>\n );\n};\n\nexport default RequestDetailPage;\n",
"type": "registry:admin"
},
{
diff --git a/packages/registry/src/requests/admin/pages/requests/[type]/[id]/page.tsx b/packages/registry/src/requests/admin/pages/requests/[type]/[id]/page.tsx
index 90854ea3b..fac6423c6 100644
--- a/packages/registry/src/requests/admin/pages/requests/[type]/[id]/page.tsx
+++ b/packages/registry/src/requests/admin/pages/requests/[type]/[id]/page.tsx
@@ -66,11 +66,28 @@ const ENTITY_NAME_KEY: Record<string, string> = {
};
const formatFieldValue = (key: string, value: unknown): string => {
- if (value === null || value === undefined) return "—";
+ if (value === null || value === undefined) return "-";
if (typeof value === "boolean") return value ? "Yes" : "No";
return String(value);
};
+const SectionRow = ({
+ title,
+ value,
+}: {
+ title: string;
+ value?: string | null;
+}) => (
+ <div className="text-ui-fg-subtle grid grid-cols-2 items-center gap-4 px-6 py-4">
+ <Text size="small" weight="plus" leading="compact">
+ {title}
+ </Text>
+ <Text size="small" leading="compact" className="whitespace-pre-line text-pretty">
+ {value ?? "-"}
+ </Text>
+ </div>
+);
+
const useSeller = (id?: string | null) => {
const { data, ...rest } = useQuery({
queryKey: ["seller", id],
@@ -143,9 +160,7 @@ const RequestDetailPage = () => {
await acceptRequest(
{},
{
- onSuccess: () => {
- toast.success("Request accepted");
- },
+ onSuccess: () => toast.success("Request accepted"),
onError: (err) => toast.error(err.message),
},
);
@@ -166,9 +181,7 @@ const RequestDetailPage = () => {
await rejectRequest(
{},
{
- onSuccess: () => {
- toast.success("Request rejected");
- },
+ onSuccess: () => toast.success("Request rejected"),
onError: (err) => toast.error(err.message),
},
);
@@ -176,79 +189,63 @@ const RequestDetailPage = () => {
return (
<SingleColumnPage hasOutlet={false}>
- {/* Header */}
- <Container className="divide-y p-0">
- <div className="flex items-center justify-between px-6 py-4">
- <div className="flex items-center gap-x-4">
+ {/* General */}
+ <div
+ style={
+ isPending
+ ? {
+ background:
+ "repeating-linear-gradient(-45deg, rgb(212, 212, 216, 0.15), rgb(212, 212, 216,.15) 10px, transparent 10px, transparent 20px)",
+ }
+ : undefined
+ }
+ className={isPending ? "-m-4 mb-1 border-b border-l p-4" : undefined}
+ >
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
<Heading>{entityName}</Heading>
- <StatusBadge color={statusColor(status)}>
- {status.charAt(0).toUpperCase() + status.slice(1)}
- </StatusBadge>
- <Badge size="2xsmall" color="grey">
- {typeLabel}
- </Badge>
- </div>
- {isPending && (
- <div className="flex items-center gap-x-2">
- <Button
- variant="secondary"
- size="small"
- onClick={handleReject}
- disabled={isAccepting || isRejecting}
- >
- Reject
- </Button>
- <Button
- variant="primary"
- size="small"
- onClick={handleAccept}
- disabled={isAccepting || isRejecting}
- >
- Accept
- </Button>
+ <div className="flex items-center gap-x-4">
+ <StatusBadge color={statusColor(status)}>
+ {status.charAt(0).toUpperCase() + status.slice(1)}
+ </StatusBadge>
+ <Badge size="2xsmall" color="grey">
+ {typeLabel}
+ </Badge>
+ {isPending && (
+ <div className="flex items-center gap-x-2">
+ <Button
+ variant="secondary"
+ size="small"
+ onClick={handleReject}
+ disabled={isAccepting || isRejecting}
+ >
+ Reject
+ </Button>
+ <Button
+ variant="primary"
+ size="small"
+ onClick={handleAccept}
+ disabled={isAccepting || isRejecting}
+ >
+ Accept
+ </Button>
+ </div>
+ )}
</div>
- )}
- </div>
- </Container>
-
- {/* Details */}
- <Container className="divide-y p-0">
- <div className="px-6 py-4">
- <Heading level="h2">Details</Heading>
- </div>
- <div className="flex flex-col gap-y-3 px-6 py-4">
+ </div>
{entityFields.map(({ key, label }) => {
const value = (request as Record<string, any>)[key];
if (value === undefined) return null;
return (
- <div key={key} className="grid grid-cols-2">
- <Text size="small" leading="compact" weight="plus">
- {label}
- </Text>
- <Text size="small" className="text-ui-fg-subtle">
- {formatFieldValue(key, value)}
- </Text>
- </div>
+ <SectionRow
+ key={key}
+ title={label}
+ value={formatFieldValue(key, value)}
+ />
);
})}
- <div className="grid grid-cols-2">
- <Text size="small" leading="compact" weight="plus">
- Created
- </Text>
- <Text size="small" className="text-ui-fg-subtle">
- {new Date(request.created_at as string).toLocaleString()}
- </Text>
- </div>
- <div className="grid grid-cols-2">
- <Text size="small" leading="compact" weight="plus">
- Updated
- </Text>
- <Text size="small" className="text-ui-fg-subtle">
- {new Date(request.updated_at as string).toLocaleString()}
- </Text>
- </div>
- </div>
- </Container>
+ </Container>
+ </div>
{/* Submitter (Seller) */}
<Container className="divide-y p-0">
@@ -280,7 +277,7 @@ const RequestDetailPage = () => {
</Link>
) : (
<Text size="small" className="text-ui-fg-muted">
- {customFields?.submitter_id ?? "—"}
+ {customFields?.submitter_id ?? "-"}
</Text>
)}
</div>
@@ -292,47 +289,42 @@ const RequestDetailPage = () => {
<div className="px-6 py-4">
<Heading level="h2">Reviewer</Heading>
</div>
- <div className="px-6 py-4">
- {user ? (
- <div className="shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-3">
- <div className="flex items-center gap-3">
- <Avatar
- fallback={
- (user.first_name ?? user.email ?? "U")
- .charAt(0)
- .toUpperCase()
- }
- />
- <div className="flex flex-1 flex-col">
- <span className="text-ui-fg-base txt-small font-medium">
- {[user.first_name, user.last_name]
- .filter(Boolean)
- .join(" ") || user.email}
- </span>
- {user.first_name && user.email && (
- <span className="text-ui-fg-muted text-xs">
- {user.email}
+ {(user || customFields?.reviewer_id) && (
+ <div className="px-6 py-4">
+ {user ? (
+ <div className="shadow-elevation-card-rest bg-ui-bg-component rounded-md px-4 py-3">
+ <div className="flex items-center gap-3">
+ <Avatar
+ fallback={
+ (user.first_name ?? user.email ?? "U")
+ .charAt(0)
+ .toUpperCase()
+ }
+ />
+ <div className="flex flex-1 flex-col">
+ <span className="text-ui-fg-base txt-small font-medium">
+ {[user.first_name, user.last_name]
+ .filter(Boolean)
+ .join(" ") || user.email}
</span>
- )}
+ {user.first_name && user.email && (
+ <span className="text-ui-fg-muted text-xs">
+ {user.email}
+ </span>
+ )}
+ </div>
</div>
</div>
- </div>
- ) : customFields?.reviewer_id ? (
- <Text size="small" className="text-ui-fg-muted">
- {customFields.reviewer_id}
- </Text>
- ) : null}
- </div>
- {customFields?.reviewer_note && (
- <div className="px-6 py-4">
- <Text size="small" leading="compact" weight="plus" className="mb-1">
- Note
- </Text>
- <Text size="small" className="text-ui-fg-subtle">
- {customFields.reviewer_note}
- </Text>
+ ) : (
+ <Text size="small" className="text-ui-fg-muted">
+ {customFields.reviewer_id}
+ </Text>
+ )}
</div>
)}
+ {customFields?.reviewer_note && (
+ <SectionRow title="Note" value={customFields.reviewer_note} />
+ )}
</Container>
)}
</SingleColumnPage>