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