<%page expression_filter="h"/>

<%!
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from openedx.core.djangolib.js_utils import js_escaped_string, dump_js_escaped_json
%>

<%inherit file="../main.html"/>
<%namespace file='../main.html' import="login_query"/>
<%namespace name='static' file='../static_content.html'/>

<%block name="title">
    <title>
        ${_("Contact {platform_name} Support").format(platform_name=platform_name)}
    </title>
</%block>

<%block name="head_extra">
    <link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</%block>

<%block name="body">

    <div id="root" class="container">
    </div>

    <%static:webpack entry="SingleSupportForm">
        var context = {
            'platformName': "${platform_name | n, js_escaped_string}",
            'marketingUrl': "${marketing_link('FAQ') | n, js_escaped_string}",
            'loginQuery': "${login_query() | n, js_escaped_string}",
            'dashboardUrl': "${reverse('dashboard') | n, js_escaped_string}",
            'homepageUrl': "${marketing_link('ROOT') | n, js_escaped_string}",
            'zendeskApiHost': "${zendesk_api_host | n, js_escaped_string}",
            'accessToken': "${access_token | n, js_escaped_string}",
            'customFields': ${custom_fields | n, dump_js_escaped_json},
            'zendeskTags': ${zendesk_tags | n, dump_js_escaped_json},
        }

        % if user.is_authenticated():
            context['user'] = {
                'username': "${user.username | n, js_escaped_string}",
                'email': "${user.email | n, js_escaped_string}"
            }

            % if user_enrollments:
                enrollments = []
                % for enrollment in user_enrollments:
                    enrollments.push({
                        'course_id': "${enrollment.course.id | n, js_escaped_string}",
                        'course_name': "${enrollment.course.display_name | n, js_escaped_string}",
                    })
                %endfor
                context['user']['enrollments'] = enrollments

            % endif

        % endif

        new SingleSupportForm(context);
    </%static:webpack>
</%block>
