types#AuthSetup TypeScript Examples

The following examples show how to use types#AuthSetup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Auth.test.tsx    From knboard with MIT License 5 votes vote down vote up
authSetup: AuthSetup = {
  ALLOW_GUEST_ACCESS: false,
}
Example #2
Source File: EnterAsGuest.tsx    From knboard with MIT License 5 votes vote down vote up
EnterAsGuest = () => {
  const dispatch = useDispatch();
  const history = useHistory();
  const [allowGuest, setAllowGuest] = useState(false);

  useEffect(() => {
    const source = api.CancelToken.source();

    const fetchData = async () => {
      try {
        const response: AxiosResponse<AuthSetup> = await api(
          `${API_AUTH_SETUP}`,
          {
            cancelToken: source.token,
          }
        );
        setAllowGuest(response.data.ALLOW_GUEST_ACCESS);
      } catch (err) {
        if (!api.isCancel(err)) {
          console.error(err);
        }
      }
    };
    fetchData();

    return () => source.cancel();
  }, []);

  const handleClick = () => {
    dispatch(guestRegister());
    history.push("/");
  };

  if (!allowGuest) {
    return null;
  }

  return (
    <Fade in={allowGuest}>
      <Container>
        <Separator>or</Separator>
        <Button
          css={css`
            text-transform: initial;
          `}
          onClick={handleClick}
        >
          Enter as a guest
        </Button>
      </Container>
    </Fade>
  );
}