Skip to content

Commit

Permalink
Fix/cms 80 fix the resource page (#269)
Browse files Browse the repository at this point in the history
* refactor: updated editor settings for react typescript

* fix: fixed the resource error
  • Loading branch information
ebukaodini authored Feb 4, 2022
1 parent df48fa6 commit 611d453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"search.exclude": {
"**/build": true,
"**/node_modules": true
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
16 changes: 8 additions & 8 deletions packages/cms/pages/resources/resource/resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export const ResourceView: React.FunctionComponent = () => {
const { push } = useHistory()
const { resource, findResource } = useResourceStore()
const { hasPermission } = useAuthStore()
const { toast } = useToastStore()
const [isLoading, setIsLoading] = useState(true)

const { resource: resourceSlug } = useParams<{
resource: string
Expand All @@ -547,6 +547,8 @@ export const ResourceView: React.FunctionComponent = () => {
if (!found) {
push(window.Tensei.getPath(''))
}

setIsLoading(false)
}, [resourceSlug])

const { setSidebarState } = useSidebarStore()
Expand All @@ -559,7 +561,7 @@ export const ResourceView: React.FunctionComponent = () => {
{hasPermission(`create:${resource?.slugPlural}`) ? (
<Link to={window.Tensei.getPath(`resources/${resourceSlug}/create`)}>
<EuiButton
size={'s'}
size={'m'}
fill
iconType={'plus'}
onClick={() => {
Expand All @@ -573,13 +575,11 @@ export const ResourceView: React.FunctionComponent = () => {
</DashboardLayout.Topbar>
<DashboardLayout.Content>
<PageWrapper>
{resource ? (
hasPermission(`index:${resource?.slugPlural}`) ? (
<Resource resource={resource} />
) : null
) : (
{isLoading ? (
<p>Loading ...</p>
)}
) : hasPermission(`index:${resource?.slugPlural}`) ? (
<Resource resource={resource!} />
) : null}
</PageWrapper>
</DashboardLayout.Content>
</>
Expand Down

0 comments on commit 611d453

Please sign in to comment.