Skip to content

Commit

Permalink
fix edit issue
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamejason committed Jan 25, 2024
1 parent 83619ba commit 6d05a9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
14 changes: 5 additions & 9 deletions packages/builder/src/__tests__/components/grants/Show.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { web3AccountLoaded, web3ChainIDLoaded } from "../../../actions/web3";
import setupStore from "../../../store";
import {
addressFrom,
buildProjectMetadata
buildProjectMetadata,
// renderWrapped,
} from "../../../utils/test_utils";
// import { Show } from "@chakra-ui/react";
// import { waitFor } from "@testing-library/react";
// import { fetchProjectOwners } from "../../../utils/projects";

jest.mock("react-router-dom", () => ({
...jest.requireActual("react-router-dom"),
Expand Down Expand Up @@ -51,29 +55,21 @@ describe("<Show />", () => {
describe("edit button", () => {
it("shows when the user is an owner", async () => {
// (fetchProjectOwners as jest.Mock).mockResolvedValue(["0x123"]);

// const dom = renderWrapped(<Show />, store);

// await waitFor(() => expect(fetchProjectOwners).toBeCalled());

// expect((fetchProjectOwners as jest.Mock).mock.calls[0][0]).toBe(1);
// expect((fetchProjectOwners as jest.Mock).mock.calls[0][1]).toBe("1");

// await waitFor(() => {
// expect(dom.getByText("Edit")).toBeInTheDocument();
// });
});

it("hides when the user is not an owner", async () => {
// (fetchProjectOwners as jest.Mock).mockResolvedValue(["0x321"]);

// const dom = renderWrapped(<Show />, store);

// await waitFor(() => expect(fetchProjectOwners).toBeCalled());

// expect((fetchProjectOwners as jest.Mock).mock.calls[0][0]).toBe(1);
// expect((fetchProjectOwners as jest.Mock).mock.calls[0][1]).toBe("1");

// await waitFor(() => {
// expect(dom.queryByText("Edit")).not.toBeInTheDocument();
// });
Expand Down
8 changes: 3 additions & 5 deletions packages/builder/src/components/grants/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ function Project() {

const props = useSelector((state: RootState) => {
const fullId = `${params.chainId}:${params.registryAddress}:${params.id}`;

const grantMetadata = state.grantsMetadata[fullId];
const owners = state.projects.owners[fullId];

const loading = grantMetadata
? grantMetadata.status === Status.Loading
: false;

const loadingFailed =
grantMetadata && grantMetadata.status === Status.Error;

const bannerImg = getProjectImage(
loading,
ImgTypes.bannerImg,
Expand Down Expand Up @@ -74,6 +70,8 @@ function Project() {
if (props.projectEvents === undefined) {
dispatch(loadAllChainsProjects(dataLayer, true));
}

console.log("props.owners", props.owners);
}, [props.projectEvents, global, dispatch]);

if (
Expand Down Expand Up @@ -112,7 +110,7 @@ function Project() {
</Link>
{props.id &&
props.owners &&
props.owners.includes(props.signerAddress!) && (
props.owners.includes(props.signerAddress!.toLowerCase()) && (
<Link
to={createEditPath()}
className="sm:w-auto mx-w-full ml-0"
Expand Down

0 comments on commit 6d05a9b

Please sign in to comment.