import { WebView as RNWebView } from "react-native-webview";

export function WebView({
  url,
  accessToken,
  env,
}: {
  url: string;
  accessToken?: string;
  env?: string;
}) {
  return (
    <RNWebView
      source={{
        uri: env ? `${env}/${url}` : url,
        ...(accessToken
          ? { headers: { Authorization: "Bearer " + accessToken } }
          : {}),
      }}
      sharedCookiesEnabled={true}
      javaScriptEnabled={true}
      startInLoadingState={true}
    />
  );
}
