<commit_before>import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import { withStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import * as React from "react";

import CardTitle from "../../../components/CardTitle";
import { ControlledCheckbox } from "../../../components/ControlledCheckbox";
import Skeleton from "../../../components/Skeleton";
import i18n from "../../../i18n";
import { StaffMemberDetails_shop_permissions } from "../../types/StaffMemberDetails";

interface StaffPermissionsProps {
  permissions: StaffMemberDetails_shop_permissions[];
  data: {
    hasFullAccess: boolean;
    permissions: string[];
  };
  disabled: boolean;
  onChange: (event: React.ChangeEvent<any>) => void;
}

const decorate = withStyles(theme => ({
  checkbox: {
    marginBottom: theme.spacing.unit
  },
  hr: {
    backgroundColor: "#eaeaea",
    border: "none",
    height: 1,
    marginBottom: 0,
    marginTop: 0
  }
}));
const StaffPermissions = decorate<StaffPermissionsProps>(
  ({ classes, data, disabled, permissions, onChange }) => {
    const handleFullAccessChange = (event: React.ChangeEvent<any>) => {
      onChange(event);
      onChange({
        target: {
          name: "permissions",
          value: event.target.value ? permissions.map(perm => perm.code) : []
        }
      } as any);
    };
    const handlePermissionChange = (event: React.ChangeEvent<any>) => {
      onChange({
        target: {
          name: "permissions",
          value: event.target.value
            ? data.permissions.concat([event.target.name])
            : data.permissions.filter(perm => perm !== event.target.name)
        }
      } as any);
    };
    return (
      <Card>
        <CardTitle title={i18n.t("Permissions")} />
        <CardContent>
          <Typography>
            {i18n.t(
              "Expand or restrict user's permissions to access certain part of saleor system."
            )}
          </Typography>
          <ControlledCheckbox
            checked={data.hasFullAccess}
            disabled={disabled}
            label={i18n.t("User has full access to the store", {
              context: "checkbox label"
            })}
            name="hasFullAccess"
            onChange={handleFullAccessChange}
          />
        </CardContent>
        {!data.hasFullAccess && (<commit_msg>Add margin from top<commit_after>import Card from "@material-ui/core/Card";
import CardContent from "@material-ui/core/CardContent";
import { withStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import * as React from "react";

import CardTitle from "../../../components/CardTitle";
import { ControlledCheckbox } from "../../../components/ControlledCheckbox";
import Skeleton from "../../../components/Skeleton";
import i18n from "../../../i18n";
import { StaffMemberDetails_shop_permissions } from "../../types/StaffMemberDetails";

interface StaffPermissionsProps {
  permissions: StaffMemberDetails_shop_permissions[];
  data: {
    hasFullAccess: boolean;
    permissions: string[];
  };
  disabled: boolean;
  onChange: (event: React.ChangeEvent<any>) => void;
}

const decorate = withStyles(theme => ({
  checkboxContainer: {
    marginTop: theme.spacing.unit
  },
  hr: {
    backgroundColor: "#eaeaea",
    border: "none",
    height: 1,
    marginBottom: 0,
    marginTop: 0
  }
}));
const StaffPermissions = decorate<StaffPermissionsProps>(
  ({ classes, data, disabled, permissions, onChange }) => {
    const handleFullAccessChange = (event: React.ChangeEvent<any>) => {
      onChange(event);
      onChange({
        target: {
          name: "permissions",
          value: event.target.value ? permissions.map(perm => perm.code) : []
        }
      } as any);
    };
    const handlePermissionChange = (event: React.ChangeEvent<any>) => {
      onChange({
        target: {
          name: "permissions",
          value: event.target.value
            ? data.permissions.concat([event.target.name])
            : data.permissions.filter(perm => perm !== event.target.name)
        }
      } as any);
    };
    return (
      <Card>
        <CardTitle title={i18n.t("Permissions")} />
        <CardContent>
          <Typography>
            {i18n.t(
              "Expand or restrict user's permissions to access certain part of saleor system."
            )}
          </Typography>
          <div className={classes.checkboxContainer}>
            <ControlledCheckbox
              checked={data.hasFullAccess}
              disabled={disabled}
              label={i18n.t("User has full access to the store", {
                context: "checkbox label"
              })}
              name="hasFullAccess"
              onChange={handleFullAccessChange}
            />
          </div>
        </CardContent>
        {!data.hasFullAccess && (
{'fraction_non_alphanumeric': 0.13833028641072517, 'fraction_numerical': 0.005281332520820638, 'mean_word_length': 2.4361479413817166, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2896793', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1371, 'n_words': 304}