1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +00:00

🔧 Display not found errors for not available resource keys

This commit is contained in:
Steffo 2021-11-08 18:59:10 +01:00 committed by Stefano Pigozzi
parent 85d251f799
commit ad1f12393c

View file

@ -50,7 +50,15 @@ export function ViewSetRouter<Resource extends DjangoResource>({viewSet, unselec
) )
} }
const selection = pk ? viewSet.resources?.find(res => res.value[pkKey] === pk) : undefined let selection
if(pk) {
selection = viewSet.resources?.find(res => res.value[pkKey] === pk)
if(!selection) {
return (
<ErrorBox error={new Error(`Resource not found: ${pk}`)}/>
)
}
}
return ( return (
<ResourceRouter <ResourceRouter