fix: 🚸 set message when there isn't value in dynamic-pages data
This commit is contained in:
parent
2c85e780f4
commit
a551ee242a
4 changed files with 40 additions and 25 deletions
|
|
@ -79,9 +79,7 @@ export default function DataTable<TData, TValue>({
|
|||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
data-state={
|
||||
row.getIsSelected() && "selected"
|
||||
}
|
||||
data-state={row.getIsSelected() && "selected"}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<TableCell
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ interface DetailsTableProps {
|
|||
forceRenderValue?: boolean;
|
||||
}
|
||||
|
||||
function DetailsTable({
|
||||
export default function DetailsTable({
|
||||
columns,
|
||||
model,
|
||||
forceRenderValue = false,
|
||||
|
|
@ -84,5 +84,3 @@ function DetailsTable({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DetailsTable;
|
||||
|
|
|
|||
|
|
@ -76,19 +76,32 @@ export default function Dashboard({
|
|||
/>
|
||||
),
|
||||
cell: ({ row }: { row: Row<DynamicPageModel> }) => {
|
||||
return row.getValue("config") ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
type="button"
|
||||
size="sm"
|
||||
asChild
|
||||
>
|
||||
<Link href={route('back.dynamic-pages.show', row.getValue("config"))}>
|
||||
<Cog />
|
||||
<span>{(row.getValue("config") as PageConfigModel).label[appEnv.locale]}</span>
|
||||
</Link>
|
||||
</Button>
|
||||
) : (<p className="text-muted-foreground italic m-0">{useTrans('back.table_not_known')}</p>);
|
||||
if (row.getValue("config")) {
|
||||
const cellValue = (row.getValue("config") as PageConfigModel).label[appEnv.locale];
|
||||
return auth.policies.pageConfigs.viewAny ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
type="button"
|
||||
size="sm"
|
||||
asChild
|
||||
>
|
||||
<Link
|
||||
href={route("back.page-configs.show", row.getValue("config"))}
|
||||
>
|
||||
<Cog />
|
||||
<span>{cellValue}</span>
|
||||
</Link>
|
||||
</Button>
|
||||
) : (
|
||||
<span>{cellValue}</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<p className="text-muted-foreground italic m-0">
|
||||
{useTrans("back.table_not_known")}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export default function Show({ data }: { data: SingleResource }) {
|
|||
{
|
||||
accessorKey: "config",
|
||||
header: str(useTrans("validation.custom.config")).ucFirst().value(),
|
||||
cell: ({ value }: { value: PageConfigModel }) => (
|
||||
cell: ({ value }: { value: PageConfigModel }) => auth.policies.pageConfigs.viewAny ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
|
|
@ -83,14 +83,14 @@ export default function Show({ data }: { data: SingleResource }) {
|
|||
})}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
) : <span>{value.label[appEnv.locale]}</span>
|
||||
},
|
||||
{
|
||||
accessorKey: "content",
|
||||
header: str(useTrans("validation.attributes.content")).ucFirst().value(),
|
||||
cell: ({ value }: { value: TranslationField<object | string> }) => {
|
||||
return typeof value[appEnv.locale] === "object" ? (
|
||||
<Table>
|
||||
if (typeof value[appEnv.locale] === "object") {
|
||||
return <Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>
|
||||
|
|
@ -116,8 +116,13 @@ export default function Show({ data }: { data: SingleResource }) {
|
|||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
) : (
|
||||
<p>{String(value[appEnv.locale])}</p>
|
||||
} else if (typeof value[appEnv.locale] === "string" && String(value[appEnv.locale]).trim().length > 0) {
|
||||
return <p>{String(value[appEnv.locale])}</p>
|
||||
};
|
||||
return (
|
||||
<span className="text-sm italic text-muted-foreground">
|
||||
{tableNotKnownTrans}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
@ -167,6 +172,7 @@ export default function Show({ data }: { data: SingleResource }) {
|
|||
),
|
||||
},
|
||||
];
|
||||
const tableNotKnownTrans = useTrans("back.table_not_known");
|
||||
|
||||
const beforeNode = () => {
|
||||
return viewAny && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue