How to use the sweetalert2/src/sweetalert2.fire function in sweetalert2

To help you get started, we’ve selected a few sweetalert2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github video-annotation-project / video-annotation-tool / client / src / components / Model / CreateModel.jsx View on Github external
handleNext = event => {
    const { toggleStateVariable } = this.props;
    const { activeStep, models, modelName } = this.state;

    event.preventDefault();
    // If step = 0 then need to check
    // If model name exists
    if (activeStep === 0) {
      if (models.includes(modelName)) {
        Swal.fire('Model Already Exists', '', 'info');
        return;
      }
    }
    // If step = 2 then model ready to submit
    if (activeStep === 2) {
      this.postModel();
      toggleStateVariable(false, 'createOpen');
    }

    this.setState(state => ({
      activeStep: state.activeStep + 1
    }));
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / VideoCollection.jsx View on Github external
loadCollections = async () => {
    const config = {
      headers: {
        Authorization: `Bearer ${localStorage.getItem('token')}`
      }
    };
    try {
      const collections = await axios.get('/api/collections/videos', config);
      if (collections) {
        return collections.data;
      }
    } catch (error) {
      console.log(error);
      Swal.fire('Error Getting Collection', '', 'error');
      return error;
    }
    return false;
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / CollectionVideoList.jsx View on Github external
}).then(async result => {
      if (result.value) {
        try {
          await axios.delete(`/api/collections/videos/elements/${id}`, config);
          Swal.fire('Deleted!', 'Videos have been removed.', 'success');
          this.setState({
            data: await this.loadCollections()
          });
        } catch (error) {
          console.log(error);

          Swal.fire('Error removing', '', 'error');
        }
      }
    });
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / CollectionVideoList.jsx View on Github external
}).then(async result => {
      if (result.value) {
        try {
          await axios.delete(`/api/collections/videos/elements/${id}`, config);
          Swal.fire('Deleted!', 'Videos have been removed.', 'success');
          this.setState({
            data: await this.loadCollections()
          });
        } catch (error) {
          console.log(error);

          Swal.fire('Error removing', '', 'error');
        }
      }
    });
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / CollectionVideoList.jsx View on Github external
removeVideo = async id => {
    const { data } = this.state;
    const videoList = data.find(col => col.id === id).checked;
    console.log(`${id} ${videoList}`);
    const config = {
      headers: {
        Authorization: `Bearer ${localStorage.getItem('token')}`
      },
      data: {
        videos: videoList
      }
    };
    this.toggle(false, 'CollectionOpen');
    Swal.fire({
      title: 'Are you sure?',
      text: `Removing ${videoList} from Collection ${id}`,
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes, delete it!'
    }).then(async result => {
      if (result.value) {
        try {
          await axios.delete(`/api/collections/videos/elements/${id}`, config);
          Swal.fire('Deleted!', 'Videos have been removed.', 'success');
          this.setState({
            data: await this.loadCollections()
          });
        } catch (error) {
github video-annotation-project / video-annotation-tool / client / src / components / CreateUser.jsx View on Github external
const { username, password, admin } = this.state;
    event.preventDefault();
    const config = {
      headers: {
        Authorization: `Bearer ${localStorage.getItem('token')}`
      }
    };
    const body = {
      username,
      password,
      admin
    };
    try {
      const newUserInfo = await axios.post('/api/users', body, config);
      console.log(newUserInfo);
      Swal.fire(
        `Created a new user: ${newUserInfo.data.user.username}`,
        '',
        'success'
      );
      history.push('/');
    } catch (error) {
      console.log(error);
      if (error.response) {
        Swal.fire(error.response.data.detail, '', 'error');
      }
    }
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / ConceptCollection.jsx View on Github external
};
    try {
      axios
        .post(`/api/collections/concepts/${id}`, body, config)
        .then(() => {
          Swal.fire({
            title: 'Saved!',
            confirmButtonText: 'Lovely!'
          });
          this.loadCollections();
        })
        .catch(() => {
          Swal.fire('Could not insert', '', 'error');
        });
    } catch (error) {
      Swal.fire('', error, error);
    }
  };
github video-annotation-project / video-annotation-tool / client / src / components / Model / ViewModels.jsx View on Github external
}).then(async result => {
      if (result.value) {
        try {
          await axios.delete('/api/models', config);
          Swal.fire('Deleted!', 'Video has been deleted.', 'success');
          this.loadExistingModels();
        } catch (error) {
          Swal.fire(error, '', 'error');
        }
      }
    });
  };
github video-annotation-project / video-annotation-tool / client / src / components / Model / Models.jsx View on Github external
}).then(async result => {
      if (result.value) {
        try {
          await axios.delete('/api/models', config);
          Swal.fire('Deleted!', 'Model has been deleted.', 'success');
          this.loadExistingModels();
        } catch (error) {
          Swal.fire(error, '', 'error');
        }
      }
    });
  };
github video-annotation-project / video-annotation-tool / client / src / components / Collections / VideoCollection.jsx View on Github external
deleteVideoCollection = async id => {
    const config = {
      headers: {
        Authorization: `Bearer ${localStorage.getItem('token')}`
      }
    };
    Swal.fire({
      title: 'Are you sure?',
      text: "You won't be able to revert this!",
      type: 'warning',
      showCancelButton: true,
      confirmButtonColor: '#3085d6',
      cancelButtonColor: '#d33',
      confirmButtonText: 'Yes, delete it!'
    }).then(async result => {
      if (result.value) {
        try {
          const response = await axios.delete(
            `/api/collections/videos/${id}`,
            config
          );
          if (response.status === 200) {
            Swal.fire('Deleted!', 'Collection has been deleted.', 'success');