Disable revoke button if ticket link does not match format

This commit is contained in:
Regalijan 2023-11-05 00:12:02 -04:00
parent 74157822dc
commit bfb027310f
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -67,6 +67,7 @@ export default function () {
const [loading, setLoading] = useState(false);
const { isOpen, onClose, onOpen } = useDisclosure();
const toast = useToast();
const ticketRegex = /https:\/\/carcrushers\.modmail\.dev\/logs\/[a-f\d]{12}$/;
async function getHistory() {
setVisible(false);
@ -260,11 +261,7 @@ export default function () {
maxLength={49}
/>
<InputRightElement>
{ticketLink.match(
/https:\/\/carcrushers\.modmail\.dev\/logs\/[a-f\d]{12}$/,
)
? validIcon
: invalidIcon}
{ticketLink.match(ticketRegex) ? validIcon : invalidIcon}
</InputRightElement>
</InputGroup>
</ModalBody>
@ -279,6 +276,7 @@ export default function () {
</Button>
<Button
colorScheme="red"
disabled={!Boolean(ticketLink.match(ticketRegex))}
ml="8px"
onClick={async () => await revokePunishment()}
>