Move friends flows to server-rendered Flask/Jinja routes
This commit is contained in:
+150
-45
@@ -1,48 +1,153 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Friends</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
{% extends "base_app.html" %} {% set active_page = 'friends' %} {% block title
|
||||
%}Friends{% endblock %} {% block content %}
|
||||
<h1>Friends</h1>
|
||||
|
||||
<section class="panel friends-search-panel">
|
||||
<h2>Find people</h2>
|
||||
<form method="GET" action="{{ url_for('main.friends') }}" class="search-form">
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
minlength="2"
|
||||
value="{{ search_query }}"
|
||||
placeholder="Search by username"
|
||||
/>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='app.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="site-shell">
|
||||
<header class="topbar">
|
||||
<a href="{{ url_for('main.home') }}" class="brand">Chess</a>
|
||||
<nav class="topnav">
|
||||
<a href="{{ url_for('main.home') }}">Home</a>
|
||||
<a href="{{ url_for('main.play') }}">Play</a>
|
||||
<a href="{{ url_for('main.friends') }}" class="active">Friends</a>
|
||||
</nav>
|
||||
<div class="profile-pill">{{ current_user.username }}</div>
|
||||
</header>
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
</form>
|
||||
|
||||
<h1>Friends</h1>
|
||||
|
||||
<section class="panel-grid">
|
||||
<article class="panel">
|
||||
<h2>Online now</h2>
|
||||
<ul class="friend-list">
|
||||
<li><span class="dot"></span>name1</li>
|
||||
<li><span class="dot"></span>friend2</li>
|
||||
<li><span class="dot"></span>bro has a lot of friends</li>
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
<article class="panel">
|
||||
<h2>Incoming invites</h2>
|
||||
<p>No pending invitations
|
||||
</p>
|
||||
</article>
|
||||
</section>
|
||||
</main>
|
||||
{% if search_query %}
|
||||
<div class="friends-list">
|
||||
{% if search_results %} {% for person in search_results %}
|
||||
<div class="friend-card">
|
||||
<div class="friend-main">
|
||||
<div class="friend-username">{{ person.username }}</div>
|
||||
<div class="friend-status">{{ person.relation|capitalize }}</div>
|
||||
</div>
|
||||
<div class="friend-actions">
|
||||
{% if person.relation == 'none' %}
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.request_page_action') }}"
|
||||
>
|
||||
<input type="hidden" name="addressee_id" value="{{ person.id }}" />
|
||||
<input type="hidden" name="q" value="{{ search_query }}" />
|
||||
<button class="btn btn-secondary" type="submit">Add Friend</button>
|
||||
</form>
|
||||
{% elif person.relation == 'incoming' %}
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.accept_page_action', requester_id=person.id) }}"
|
||||
>
|
||||
<input type="hidden" name="q" value="{{ search_query }}" />
|
||||
<button class="btn btn-primary" type="submit">Accept</button>
|
||||
</form>
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.decline_page_action', requester_id=person.id) }}"
|
||||
>
|
||||
<input type="hidden" name="q" value="{{ search_query }}" />
|
||||
<button class="btn btn-secondary" type="submit">Decline</button>
|
||||
</form>
|
||||
{% elif person.relation == 'outgoing' %}
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.cancel_page_action', addressee_id=person.id) }}"
|
||||
>
|
||||
<input type="hidden" name="q" value="{{ search_query }}" />
|
||||
<button class="btn btn-secondary" type="submit">
|
||||
Cancel Request
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<span class="friend-note">No action available</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endfor %} {% else %}
|
||||
<p class="muted">No users found for "{{ search_query }}".</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="panel friends-section">
|
||||
<!-- todo: update presence -->
|
||||
<h2>Your friends</h2>
|
||||
{% if friends %}
|
||||
<div class="friends-list">
|
||||
{% for friend in friends %}
|
||||
<div class="friend-card">
|
||||
<div class="friend-main">
|
||||
<div class="friend-username">{{ friend.username }}</div>
|
||||
<div
|
||||
class="friend-status {{ 'status-online' if friend.is_online else 'status-offline' }}"
|
||||
>
|
||||
{{ 'Online' if friend.is_online else 'Offline' }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- todo: implement button -->
|
||||
<button class="btn btn-secondary" type="button">Challenge</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="muted">No friends yet.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="panel friends-section">
|
||||
<h2>Requests</h2>
|
||||
|
||||
<h3>Incoming</h3>
|
||||
{% if incoming_requests %}
|
||||
<div class="friends-list">
|
||||
{% for req in incoming_requests %}
|
||||
<div class="friend-card">
|
||||
<div class="friend-main">
|
||||
<div class="friend-username">{{ req.username }}</div>
|
||||
<div class="friend-status">Pending</div>
|
||||
</div>
|
||||
<div class="friend-actions">
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.accept_page_action', requester_id=req.id) }}"
|
||||
>
|
||||
<button class="btn btn-primary" type="submit">Accept</button>
|
||||
</form>
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.decline_page_action', requester_id=req.id) }}"
|
||||
>
|
||||
<button class="btn btn-secondary" type="submit">Decline</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="muted">No incoming requests.</p>
|
||||
{% endif %}
|
||||
|
||||
<h3>Outgoing</h3>
|
||||
{% if outgoing_requests %}
|
||||
<div class="friends-list">
|
||||
{% for req in outgoing_requests %}
|
||||
<div class="friend-card">
|
||||
<div class="friend-main">
|
||||
<div class="friend-username">{{ req.username }}</div>
|
||||
<div class="friend-status">Pending</div>
|
||||
</div>
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('friends.cancel_page_action', addressee_id=req.id) }}"
|
||||
>
|
||||
<button class="btn btn-secondary" type="submit">Cancel Request</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="muted">No outgoing requests.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user