diff --git a/src/components/EntityScaffold.res b/src/components/EntityScaffold.res index d9d048b33..68afbe809 100644 --- a/src/components/EntityScaffold.res +++ b/src/components/EntityScaffold.res @@ -1,85 +1,32 @@ -module ComingSoon = { - @react.component - let make = (~title) => { -
-
{React.string(title)}
-
{React.string("Coming soon...")}
-
- } -} - -module ShowPage = { - @react.component - let make = (~entityName, ~id) => { -
-
- {React.string(`Show ${entityName} `)} - {React.string(`#${id}`)} -
-
{React.string("Coming soon...")}
-
- } -} - -module UnauthorizedPage = { - @react.component - let make = (~entityName) => { -
-
{React.string(entityName)}
-
{React.string("You don't have access to this module. Contact admin for access")}
-
- } -} - @react.component let make = ( ~entityName="", ~remainingPath, ~isAdminAccount=false, - ~access: AuthTypes.authorization=ReadWrite, - ~renderList=() => , - ~renderNewForm=() => , + ~access: AuthTypes.authorization=Access, + ~renderList, + ~renderNewForm=?, ~renderShow=?, - ~renderOrder=?, - ~renderEdit=_id => , - ~renderEditWithMultiId=(_id1, _id2) => , - ~renderClone=_id => , ) => { if access === NoAccess { - + } else { switch remainingPath { | list{"new"} => switch access { - | ReadWrite => renderNewForm() - | _ => - } - | list{id, "clone"} => - switch access { - | ReadWrite => renderClone(id) - | _ => + | Access => + switch renderNewForm { + | Some(element) => element() + | None => React.null + } + | NoAccess => } | list{id} => let page = switch renderShow { | Some(fn) => fn(id) - | None => + | None => React.null } page - | list{id, "edit"} => - switch access { - | ReadWrite => renderEdit(id) - | _ => - } - | list{id1, id2, "edit"} => - switch access { - | ReadWrite => renderEditWithMultiId(id1, id2) - | _ => - } - | list{"order", id} => - switch renderOrder { - | Some(fn) => fn(id) - | None => - } | list{} => renderList() | _ => } diff --git a/src/components/UnauthorizedPage.res b/src/components/UnauthorizedPage.res new file mode 100644 index 000000000..55bddadc9 --- /dev/null +++ b/src/components/UnauthorizedPage.res @@ -0,0 +1,19 @@ +@react.component +let make = (~message="You don't have access to this module. Contact admin for access") => { + let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) + React.useEffect0(() => { + RescriptReactRouter.replace("/unauthorized") + None + }) + +