<commit_before>// @flow

import type { Action } from './types';
import type { Question } from '../types';

import axios from 'axios';
import RichTextEditor from 'react-rte';

export const fetchLessons = ():Action => {
  return {
    type: 'FETCH_LESSONS',
    payload: axios.get('https://127.0.0.1:4343/api/topics')
  }
}

export const updateNewLesson = (title:string, background:RichTextEditor):Action => {
  return {
    type: 'UPDATE_NEW_LESSON',
    payload: {
      title,
      background
    }
  }
}

export const saveNewLesson = (title:string, background:string):Action => {
  return {
    type: 'SAVE_NEW_LESSON',
    payload: axios.post('https://127.0.0.1:4343/api/topics', {
      title,
      background
    })
  }
}

export const saveLesson = (id:string, title:string, background:string):Action => {
  return {
    type: 'SAVE_LESSON',
    payload: axios.put('https://127.0.0.1:4343/api/topics/' + id, {
      title,
      background
    })
  }
}

export const logIn = ():Action => {
  return {
    type: 'LOGIN'
  }
}

export const toggleNavBar = ():Action => {
  return {
    type: 'TOGGLE_NAVBAR'
  }
}

export const fetchUsers = ():Action => {
  return {
    type: 'FETCH_USERS',
    payload: axios.get('https://127.0.0.1:4343/api/users')
  }
}

export const deleteUser = (id:string):Action => {
  return {
    type: 'DELETE_USER',
    payload: axios.delete('https://127.0.0.1:4343/api/users/'+id)
  }
}

export const fetchQuestions = ():Action => {
  return {
    type: 'FETCH_QUESTIONS',
    payload: axios.get('https://127.0.0.1:4343/api/questions')
  }
}

export const saveQuestion = (question:Question):Action => {
  return {
    type: 'SAVE_QUESTION',
    payload: axios.post('https://127.0.0.1:4343/api/questions/'+question.id, question)
  }
}
<commit_msg>Fix save question HTTP method<commit_after>// @flow

import type { Action } from './types';
import type { Question } from '../types';

import axios from 'axios';
import RichTextEditor from 'react-rte';

export const fetchLessons = ():Action => {
  return {
    type: 'FETCH_LESSONS',
    payload: axios.get('https://127.0.0.1:4343/api/topics')
  }
}

export const updateNewLesson = (title:string, background:RichTextEditor):Action => {
  return {
    type: 'UPDATE_NEW_LESSON',
    payload: {
      title,
      background
    }
  }
}

export const saveNewLesson = (title:string, background:string):Action => {
  return {
    type: 'SAVE_NEW_LESSON',
    payload: axios.post('https://127.0.0.1:4343/api/topics', {
      title,
      background
    })
  }
}

export const saveLesson = (id:string, title:string, background:string):Action => {
  return {
    type: 'SAVE_LESSON',
    payload: axios.put('https://127.0.0.1:4343/api/topics/' + id, {
      title,
      background
    })
  }
}

export const logIn = ():Action => {
  return {
    type: 'LOGIN'
  }
}

export const toggleNavBar = ():Action => {
  return {
    type: 'TOGGLE_NAVBAR'
  }
}

export const fetchUsers = ():Action => {
  return {
    type: 'FETCH_USERS',
    payload: axios.get('https://127.0.0.1:4343/api/users')
  }
}

export const deleteUser = (id:string):Action => {
  return {
    type: 'DELETE_USER',
    payload: axios.delete('https://127.0.0.1:4343/api/users/'+id)
  }
}

export const fetchQuestions = ():Action => {
  return {
    type: 'FETCH_QUESTIONS',
    payload: axios.get('https://1192.168.127.12:4343/api/questions')
  }
}

export const saveQuestion = (question:Question):Action => {
  return {
    type: 'SAVE_QUESTION',
    payload: axios.patch('https://127.0.0.1:4343/api/questions/'+question.id, question)
  }
}

{'fraction_non_alphanumeric': 0.16969020373988278, 'fraction_numerical': 0.040747976555958694, 'mean_word_length': 3.16260162601626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 14, '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': '5195983', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1311, 'n_words': 238}