I'm trying to require the number of contract NFTs in a wallet < declared uint256 variable in order to proceed with safemint function. I have the following code but I can't work out what is happening, or how to pass the result of balanceOf to a variable which I can later check against MAX_InWallet. Can anyone help please. Thanks
uint256 MAX_SUPPLY = 20;
uint256 MAX_InWallet = 5;
function safeMint(address to, string memory uri) public {
uint256 tokenId = _tokenIdCounter.current();
require(tokenId <= MAX_SUPPLY, "Error, Minted Out");
mapping (address => uint256) public view balanceOf; // week1 challenge
require(balanceOf(msg.sender) < MAX_InWallet, "error"); // week1 challenge
_tokenIdCounter.increment();
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}