{% extends "templates/web.html" %}

{% block page_content %}

{% macro chapter_button() %}
	<p><a href="/{{ chapter.route }}" class='btn btn-primary'>
		Go to Chapter Page</a></p>
{% endmacro %}
{% if frappe.session.user=='Guest' %}
	<p>Please signup and login to join this chapter</p>
	<p><a href="/login?redirect-to=/{{ chapter.route }}" class='btn btn-primary'>Login</a></p>
{% else %}
	{% if already_member %}
		<p>You are already a member of {{ chapter.name }}!</p>
		{{ chapter_button() }}
		<p><a href="">Leave Chapter</a></p>
	{% else %}
		{% if request.method=='POST' %}
			<p>Welcome to chapter {{ chapter.name }}!</p>
			{{ chapter_button() }}
		{% else %}
			<div style="padding: 20px 0;">
				<div class="row">
					<div class="col-lg-8 col-md-8">
						<form name="user-intro" action="/non_profit/join-chapter" method='POST'>
							<div class="form-group">
								<input name="name" class="hidden form-control" type="text"
									value="{{chapter.name}}">
								<input name="csrf_token" class="hidden  form-control" type="text"
									value="{{frappe.session.csrf_token}}">
							</div>
							<div class="form-group">
								<label for="user" class="">User Name</label>
								<input name="user" class="form-control" type="text" value="{{ frappe.session.user }}">
							</div>
							<div class="form-group">
								<label for="website_url" class="">Website URL</label>
								<input name="website_url" required class="form-control" type="text"
									placeholder="https://example.com" />
							</div>
							<div class="form-group">
								<label for="introduction" class="">Introduction</label>
								<textarea name="introduction" required class="form-control"
									placeholder="Your profession and how you are associated with ERPNext"></textarea>
							</div>
							<div class="form-group">
								<button type="Submit" id="update_member" class="btn btn-primary">
									Submit</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		{% endif %}
	{% endif %}

{% endif %}

{% endblock %}
