Commit 49b45031 authored by okhin's avatar okhin 🚴

Updating the clla to POST feedbacks

parent 10bd8e26
Pipeline #845 passed with stage
in 1 second
......@@ -17,10 +17,19 @@ class Api {
// Generic post function for REST API
static function post($url, $data) {
$client = new Client(['base_uri' => API_BASE, 'defaults' => [ 'headers' => [ 'Content-type' => 'applications/json']]]);
$url = API_BASE . $url . "/?format=json";
$result = $client->request('POST', $url, array(), $data);
return $result->getBody();
try {
$client = new Client(['base_uri' => API_BASE, 'defaults' => [ 'headers' => [ 'Content-type' => 'applications/json']]]);
$url = API_BASE . $url . "/?format=json";
$result = $client->request('POST', $url, ['body' => json_encode($data), "headers" => ['Content-Type' => 'application/json']]);
return $result->getBody();
} catch (Exception $e) {
echo $e;
if ( $e->hasResponse()) {
echo $e->getResponse()->getBody();
} else {
echo $e;
}
}
}
// Asking for campaign informations
......@@ -74,9 +83,9 @@ class Api {
// Posting a feedback
static function post_feedback($contact_id, $comment, $feedback_category='') {
$data = array(
"contact_id"=>$contact_id,
"callee"=>$contact_id,
"comment"=>$comment,
"feedback_category"=>$feedback_category
"category"=>$feedback_category
);
$json = Api::post("campaigns/" . CAMPAIGN_ID . "/feedbacks", $data);
return json_decode($json, true);
......
<!-- Let's split this page in two -->
<div class="row">
<div class="col s6">
<include href="argumentation.html">
</div>
<div class="col s6">
<div class="card">
......@@ -35,12 +34,11 @@
<p class="small">{{ _("Please tell us what happened if you were able to talk to someone. Your feedback is important to us.") }}</p>
<form class="form" method="post" action="/feedback/" >
<input type="hidden" id="contact_id" name="contact_id" value="{{ @contact_id }}" />
<select name="feedback_category" id="feedback_category" class="input-field">
<repeat group="{{ @feedback_categories }}" value="{{ @feedback_category }}">
<span>
<input required type="radio" name="feedback_category" value="{{ @feedback_category.id }}" id="f{{ @feedback_category.id }}" />
<label for="f{{ @feedback_category.id }}">{{ @feedback_category.name }}</label>
</span>
<option value="{{ @feedback_category.id }}">{{ @feedback_category.name }}</option>
</repeat>
</select>
<div class="input-field">
<textarea class="materialize-textarea" id="feedback" name="feedback"></textarea>
</div>
......@@ -136,5 +134,6 @@
$(document).ready(function() {
update_call(call);
interval = window.setInterval(fetch, 3000);
$('select').material_select();
});
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment