fix: pages access (#754)

* fix: dashboard workspace activity mutation

* fix: page access operation
This commit is contained in:
Aaryan Khandelwal 2023-04-11 12:10:22 +05:30 committed by GitHub
parent f2c5bb5c03
commit 7aa0ace555
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 68 deletions

View file

@ -19,6 +19,7 @@ import pagesService from "services/pages.service";
import issuesService from "services/issues.service";
// hooks
import useToast from "hooks/use-toast";
import useUser from "hooks/use-user";
// layouts
import { ProjectAuthorizationWrapper } from "layouts/auth-layout";
// components
@ -61,6 +62,8 @@ const SinglePage: NextPage = () => {
const { setToastAlert } = useToast();
const { user } = useUser();
const { handleSubmit, reset, watch, setValue } = useForm<IPage>({
defaultValues: { name: "" },
});
@ -411,18 +414,22 @@ const SinglePage: NextPage = () => {
)}
</Popover>
</div>
{pageDetails.access ? (
<button onClick={() => partialUpdatePage({ access: 0 })} className="z-10">
<LockClosedIcon className="h-4 w-4" />
</button>
) : (
<button
onClick={() => partialUpdatePage({ access: 1 })}
type="button"
className="z-10"
>
<LockOpenIcon className="h-4 w-4" />
</button>
{pageDetails.created_by === user?.id && (
<>
{pageDetails.access ? (
<button onClick={() => partialUpdatePage({ access: 0 })} className="z-10">
<LockClosedIcon className="h-4 w-4" />
</button>
) : (
<button
onClick={() => partialUpdatePage({ access: 1 })}
type="button"
className="z-10"
>
<LockOpenIcon className="h-4 w-4" />
</button>
)}
</>
)}
{pageDetails.is_favorite ? (
<button onClick={handleRemoveFromFavorites} className="z-10">