<commit_before>/*
 * This file contains the state and functions
 * required for displaying user groups pages
 */

import React from "react";

import {
  showNotification,
  showErrorNotification
} from "../modules/notifications";
import { deleteUserGroup } from "../apis/users/groups";
import { navigate } from "@reach/router";

const initialContext = {};

const UserGroupsContext = React.createContext(initialContext);

function UserGroupsProvider(props) {
  /*
   * Deletes User Group and show confirmation notification.
   */
  function userGroupsContextDeleteUserGroup(id, url) {
    deleteUserGroup(id).then(res => {
      if (res.type === "error") {
        showErrorNotification({ text: res.text, type: res.type });
      } else {
        navigate(`${url}`, { replace: true });
        showNotification({ text: "User Group deleted successfully" });
      }
    });
  }

  return (
    <UserGroupsContext.Provider
      value={{
        userGroupsContextDeleteUserGroup
      }}
    >
      {props.children}
    </UserGroupsContext.Provider>
  );
}
export { UserGroupsContext, UserGroupsProvider };<commit_msg>Changed delete user group notification to use antd and fixed problem of it not showing up in admin panel<commit_after>/*
 * This file contains the state and functions
 * required for displaying user groups pages
 */

import React from "react";
import { deleteUserGroup } from "../apis/users/groups";
import { navigate } from "@reach/router";
import { notification } from "antd";

const initialContext = {};

const UserGroupsContext = React.createContext(initialContext);

function UserGroupsProvider(props) {
  /*
   * Deletes User Group and shows confirmation notification.
   */
  function userGroupsContextDeleteUserGroup(id, url) {
    deleteUserGroup(id).then((message) => {
      navigate(`${url}`, { replace: true });
      notification.success({ message });
    }).catch((message) => {
      notification.error({ message })
    });
  }

  return (
    <UserGroupsContext.Provider
      value={{
        userGroupsContextDeleteUserGroup
      }}
    >
      {props.children}
    </UserGroupsContext.Provider>
  );
}
export { UserGroupsContext, UserGroupsProvider };
{'fraction_non_alphanumeric': 0.11928702010968921, 'fraction_numerical': 0.0, 'mean_word_length': 3.54149377593361, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '3017121', 'n_tokens_mistral': 579, 'n_tokens_neox': 576, 'n_words': 159}