<commit_before>import DialogContentText from "@material-ui/core/DialogContentText";
import * as React from "react";
import { Route } from "react-router-dom";

import ActionDialog from "../../components/ActionDialog";
import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
import i18n from "../../i18n";
import { getMutationState, maybe } from "../../misc";
import PageDetailsPage from "../components/PageDetailsPage";
import { TypedPageRemove, TypedPageUpdate } from "../mutations";
import { TypedPageDetailsQuery } from "../queries";
import { PageRemove } from "../types/PageRemove";
import { pageListUrl, pageRemovePath, pageRemoveUrl, pageUrl } from "../urls";

export interface PageDetailsProps {
  id: string;
}

export const PageDetails: React.StatelessComponent<PageDetailsProps> = ({
  id
}) => (
  <Navigator>
    {navigate => (
      <Messages>
        {pushMessage => {
          const handlePageRemove = (data: PageRemove) => {
            if (data.pageDelete.errors.length === 0) {
              pushMessage({
                text: i18n.t("Removed page", {
                  context: "notification"
                })
              });
              navigate(pageListUrl);
            }
          };
          return (
            <TypedPageRemove variables={{ id }} onCompleted={handlePageRemove}>
              {(pageRemove, pageRemoveOpts) => (
                <TypedPageUpdate>
                  {(pageUpdate, pageUpdateOpts) => (
                    <TypedPageDetailsQuery variables={{ id }}>
                      {pageDetails => {
                        const formTransitionState = getMutationState(
                          pageUpdateOpts.called,
                          pageUpdateOpts.loading,
                          maybe(() => pageUpdateOpts.data.pageUpdate.errors)
                        );
                        const removeTransitionState = getMutationState(
                          pageRemoveOpts.called,
                          pageRemoveOpts.loading,
                          maybe(() => pageRemoveOpts.data.pageDelete.errors)
                        );

                        return (
                          <>
                            <PageDetailsPage
                              disabled={pageDetails.loading}
                              errors={maybe(
                                () => pageUpdateOpts.data.pageUpdate.errors,
                                []
                              )}
                              saveButtonBarState={formTransitionState}
                              page={pageDetails.data.page}
                              onBack={() => navigate(pageListUrl)}
                              onRemove={() => navigate(pageRemoveUrl(id))}
                              onSubmit={formData => 
                                pageUpdate({
                                  variables: {
                                    id,
                                    input: {
                                      content: JSON.stringify(formData.content),
                                      isPublished: formData.isVisible
                                        ? true
                                        : formData.availableOn === "" ||
                                          formData.availableOn === null
                                        ? false
                                        : true,
                                      publicationDate: formData.isVisible
                                        ? null
                                        : formData.availableOn === ""
                                        ? null
                                        : formData.availableOn,
                                      seo: {
                                        description: formData.seoDescription,
                                        title: formData.seoTitle
                                      },
                                      slug: formData.slug,
                                      title: formData.title
                                    }
                                  }
                                });
                              }
                            />
                            <Route
                              exact
                              path={pageRemovePath(":id")}
                              render={({ match }) => (
                                <ActionDialog
                                  open={!!match}
                                  confirmButtonState={removeTransitionState}
                                  title={i18n.t("Remove Page")}
                                  onClose={() => navigate(pageUrl(id))}
                                  onConfirm={pageRemove}
                                  variant="delete"<commit_msg>Remove semicolon<commit_after>import DialogContentText from "@material-ui/core/DialogContentText";
import * as React from "react";
import { Route } from "react-router-dom";

import ActionDialog from "../../components/ActionDialog";
import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
import i18n from "../../i18n";
import { getMutationState, maybe } from "../../misc";
import PageDetailsPage from "../components/PageDetailsPage";
import { TypedPageRemove, TypedPageUpdate } from "../mutations";
import { TypedPageDetailsQuery } from "../queries";
import { PageRemove } from "../types/PageRemove";
import { pageListUrl, pageRemovePath, pageRemoveUrl, pageUrl } from "../urls";

export interface PageDetailsProps {
  id: string;
}

export const PageDetails: React.StatelessComponent<PageDetailsProps> = ({
  id
}) => (
  <Navigator>
    {navigate => (
      <Messages>
        {pushMessage => {
          const handlePageRemove = (data: PageRemove) => {
            if (data.pageDelete.errors.length === 0) {
              pushMessage({
                text: i18n.t("Removed page", {
                  context: "notification"
                })
              });
              navigate(pageListUrl);
            }
          };
          return (
            <TypedPageRemove variables={{ id }} onCompleted={handlePageRemove}>
              {(pageRemove, pageRemoveOpts) => (
                <TypedPageUpdate>
                  {(pageUpdate, pageUpdateOpts) => (
                    <TypedPageDetailsQuery variables={{ id }}>
                      {pageDetails => {
                        const formTransitionState = getMutationState(
                          pageUpdateOpts.called,
                          pageUpdateOpts.loading,
                          maybe(() => pageUpdateOpts.data.pageUpdate.errors)
                        );
                        const removeTransitionState = getMutationState(
                          pageRemoveOpts.called,
                          pageRemoveOpts.loading,
                          maybe(() => pageRemoveOpts.data.pageDelete.errors)
                        );

                        return (
                          <>
                            <PageDetailsPage
                              disabled={pageDetails.loading}
                              errors={maybe(
                                () => pageUpdateOpts.data.pageUpdate.errors,
                                []
                              )}
                              saveButtonBarState={formTransitionState}
                              page={pageDetails.data.page}
                              onBack={() => navigate(pageListUrl)}
                              onRemove={() => navigate(pageRemoveUrl(id))}
                              onSubmit={formData =>
                                pageUpdate({
                                  variables: {
                                    id,
                                    input: {
                                      content: JSON.stringify(formData.content),
                                      isPublished: formData.isVisible
                                        ? true
                                        : formData.availableOn === "" ||
                                          formData.availableOn === null
                                        ? false
                                        : true,
                                      publicationDate: formData.isVisible
                                        ? null
                                        : formData.availableOn === ""
                                        ? null
                                        : formData.availableOn,
                                      seo: {
                                        description: formData.seoDescription,
                                        title: formData.seoTitle
                                      },
                                      slug: formData.slug,
                                      title: formData.title
                                    }
                                  }
                                })
                              }
                            />
                            <Route
                              exact
                              path={pageRemovePath(":id")}
                              render={({ match }) => (
                                <ActionDialog
                                  open={!!match}
                                  confirmButtonState={removeTransitionState}
                                  title={i18n.t("Remove Page")}
                                  onClose={() => navigate(pageUrl(id))}
                                  onConfirm={pageRemove}
                                  variant="delete"
{'fraction_non_alphanumeric': 0.08798525043531702, 'fraction_numerical': 0.0018436955853733483, 'mean_word_length': 0.8672786383629757, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 76, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3311749', 'n_tokens_mistral': 1901, 'n_tokens_neox': 1857, 'n_words': 338}