<commit_before>import React, {Fragment, useState, useCallback} from 'react';
import {useSnackbar} from 'service/snackbar';
import Section from 'component/section';
import {Form, Input, useForm} from 'component/form';
import Card from 'component/card';
import Button from 'component/button';
import Table from 'component/table';
import Tabbar from 'component/tabbar';
import FaIcon from 'component/faicon';

const TableData = [
  {
    name: 'Elrond',
    description:
      'a Half-elven conveyor, member of White Council and lord of Rivendell.',
  },
  {
    name: 'Erestor',
    description: 'an Elf-lord, advisor, and the chief of the House of Elrond.',
  },
  {
    name: '<NAME>',
    description:
      'a Wizard, one of the Istari, and member of both the White Council and The Fellowship.',
  },
  {
    name: 'Aragorn',
    description:
      'a Ranger, heir of Isildur, member of The Fellowship, and Chieftain of the Dúnedain in the North.',
  },
  {
    name: '<NAME>',
    description:
      'a Hobbit of the Shire, member of The Fellowship, and Ring-bearer.',
  },
  {
    name: '<NAME>',
    description:
      'a Hobbit of the Shire, former Ring-bearer, uncle of Frodo and long resident in Rivendell.',
  },
  {
    name: '<NAME>',
    description:
      'son of Denethor II Ruling Steward of Minas Tirith, and member of The Fellowship.',
  },
  {
    name: '<NAME> the Lonely Mountain',
    description:
      'representative of the King under the Mountain, Dain Ironfoot of the Dwarves.',
  },
  {
    name: 'Gimli',
    description:
      'son of Gloin, member of The Fellowship, and dwarf of the Lonely Mountain.',
  },
  {
    name: 'Legolas',
    description:
      'a Sindar Elf of the Woodland Realm (Mirkwood), son of Thranduil the Elvenking, and member of The Fellowship.',
  },
  {
    name: 'Glorfindel',
    description:
      'an Elf-lord of Rivendell, rescuer of Frodo and his company from the Nine.',
  },
  {
    name: '<NAME>',
    description: 'messenger from Círdan of the Grey Havens.',
  },
];

const emailRegex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]+$/;
const phoneRegex = /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/;
const imageSetType = new Set(['image/png', 'image/jpeg']);
const formErrCheck = ({
  email,
  phone,
  password,
  confirm_password,
  checkbox2,
  radioval,
  fileval,
}) => {
  const err = {};
  if (email.length > 0 && !emailRegex.test(email)) {
    Object.assign(err, {email: true});
  }
  if (phone.length > 0 && !phoneRegex.test(phone)) {
    Object.assign(err, {phone: true});
  }
  if (password.length > 0 && password.length < 10) {
    Object.assign(err, {password: true});
  }
  if (confirm_password.length > 0 && confirm_password !== password) {
    Object.assign(err, {confirm_password: '<PASSWORD>'});
  }
  if (checkbox2) {
    Object.assign(err, {checkbox2: true});
  }
  if (radioval === 'two') {
    Object.assign(err, {radioval: true});
  }
  if (fileval && !imageSetType.has(fileval.type)) {
    Object.assign(err, {fileval: 'File must be a png or jpeg'});
  }
  return err;
};
const formValidCheck = ({
  name,
  email,
  phone,
  password,
  confirm_password,
  checkbox,
  radioval,
  fileval,
  lang,
}) => {
  const valid = {};
  if (name.length > 0) {
    Object.assign(valid, {name: true});
  }
  if (emailRegex.test(email)) {
    Object.assign(valid, {email: true});
  }
  if (phoneRegex.test(phone)) {
    Object.assign(valid, {phone: true});
  }
  if (password.length > 9) {
    Object.assign(valid, {password: true});
  }
  if (password.length > 0 && confirm_password === password) {
    Object.assign(valid, {confirm_password: true});
  }
  if (checkbox) {
    Object.assign(valid, {checkbox: true});
  }
  if (radioval === 'one') {
    Object.assign(valid, {radioval: true});
  }
  if (fileval && imageSetType.has(fileval.type)) {
    Object.assign(valid, {fileval: true});
  }
  if (lang === '100' || lang === '200') {
    Object.assign(valid, {lang: true});
  }
  return valid;
};

const FormContainer = () => {
  const [formState, updateForm] = useForm({
    name: '',
    email: '',
    phone: '',
    tagline: '',
    password: '',
    confirm_password: '',
    checkbox: false,
    radioval: false,
    fileval: undefined,
    lang: '200',
  });<commit_msg>Bugfix example form init state<commit_after>import React, {Fragment, useState, useCallback} from 'react';
import {useSnackbar} from 'service/snackbar';
import Section from 'component/section';
import {Form, Input, useForm} from 'component/form';
import Card from 'component/card';
import Button from 'component/button';
import Table from 'component/table';
import Tabbar from 'component/tabbar';
import FaIcon from 'component/faicon';

const TableData = [
  {
    name: 'Elrond',
    description:
      'a Half-elven conveyor, member of White Council and lord of Rivendell.',
  },
  {
    name: 'Erestor',
    description: 'an Elf-lord, advisor, and the chief of the House of Elrond.',
  },
  {
    name: '<NAME>',
    description:
      'a Wizard, one of the Istari, and member of both the White Council and The Fellowship.',
  },
  {
    name: 'Aragorn',
    description:
      'a Ranger, heir of Isildur, member of The Fellowship, and Chieftain of the Dúnedain in the North.',
  },
  {
    name: '<NAME>',
    description:
      'a Hobbit of the Shire, member of The Fellowship, and Ring-bearer.',
  },
  {
    name: '<NAME>',
    description:
      'a Hobbit of the Shire, former Ring-bearer, uncle of Frodo and long resident in Rivendell.',
  },
  {
    name: '<NAME>',
    description:
      'son of Denethor II Ruling Steward of Minas Tirith, and member of The Fellowship.',
  },
  {
    name: '<NAME> the Lonely Mountain',
    description:
      'representative of the King under the Mountain, Dain Ironfoot of the Dwarves.',
  },
  {
    name: 'Gimli',
    description:
      'son of Gloin, member of The Fellowship, and dwarf of the Lonely Mountain.',
  },
  {
    name: 'Legolas',
    description:
      'a Sindar Elf of the Woodland Realm (Mirkwood), son of Thranduil the Elvenking, and member of The Fellowship.',
  },
  {
    name: 'Glorfindel',
    description:
      'an Elf-lord of Rivendell, rescuer of Frodo and his company from the Nine.',
  },
  {
    name: '<NAME>',
    description: 'messenger from Círdan of the Grey Havens.',
  },
];

const emailRegex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]+$/;
const phoneRegex = /^[0-9]{3}-[0-9]{3}-[0-9]{4}$/;
const imageSetType = new Set(['image/png', 'image/jpeg']);
const formErrCheck = ({
  email,
  phone,
  password,
  confirm_password,
  checkbox2,
  radioval,
  fileval,
}) => {
  const err = {};
  if (email.length > 0 && !emailRegex.test(email)) {
    Object.assign(err, {email: true});
  }
  if (phone.length > 0 && !phoneRegex.test(phone)) {
    Object.assign(err, {phone: true});
  }
  if (password.length > 0 && password.length < 10) {
    Object.assign(err, {password: true});
  }
  if (confirm_password.length > 0 && confirm_password !== password) {
    Object.assign(err, {confirm_password: '<PASSWORD>'});
  }
  if (checkbox2) {
    Object.assign(err, {checkbox2: true});
  }
  if (radioval === 'two') {
    Object.assign(err, {radioval: true});
  }
  if (fileval && !imageSetType.has(fileval.type)) {
    Object.assign(err, {fileval: 'File must be a png or jpeg'});
  }
  return err;
};
const formValidCheck = ({
  name,
  email,
  phone,
  password,
  confirm_password,
  checkbox,
  radioval,
  fileval,
  lang,
}) => {
  const valid = {};
  if (name.length > 0) {
    Object.assign(valid, {name: true});
  }
  if (emailRegex.test(email)) {
    Object.assign(valid, {email: true});
  }
  if (phoneRegex.test(phone)) {
    Object.assign(valid, {phone: true});
  }
  if (password.length > 9) {
    Object.assign(valid, {password: true});
  }
  if (password.length > 0 && confirm_password === password) {
    Object.assign(valid, {confirm_password: true});
  }
  if (checkbox) {
    Object.assign(valid, {checkbox: true});
  }
  if (radioval === 'one') {
    Object.assign(valid, {radioval: true});
  }
  if (fileval && imageSetType.has(fileval.type)) {
    Object.assign(valid, {fileval: true});
  }
  if (lang === '100' || lang === '200') {
    Object.assign(valid, {lang: true});
  }
  return valid;
};

const FormContainer = () => {
  const [formState, updateForm] = useForm({
    name: '',
    email: '',
    phone: '',
    tagline: '',
    password: '',
    confirm_password: '',
    checkbox: false,
    checkbox2: false,
    radioval: false,
    fileval: undefined,
    lang: '200',
  });
{'fraction_non_alphanumeric': 0.1586555411916794, 'fraction_numerical': 0.008109060994241392, 'mean_word_length': 3.165442976015663, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 37, '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': '3999336', 'n_tokens_mistral': 2975, 'n_tokens_neox': 2900, 'n_words': 820}