Phase 1 - Sidebar Refactor: - Refactor sidebar to use collapsible sections with Alpine.js - Add localStorage persistence for section states - Reorganize navigation into logical groups Phase 2 - Core JS Files: - Add products.js: product CRUD, search, filtering, toggle active/featured - Add orders.js: order list, status management, filtering - Add inventory.js: stock tracking, adjust/set quantity modals - Add customers.js: customer list, order history, messaging - Add team.js: member invite, role management, remove members - Add profile.js: profile editing with form validation - Add settings.js: tabbed settings (general, marketplace, notifications) Templates updated from placeholders to full functional UIs. Vendor frontend now at ~90% parity with admin. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
280 lines
14 KiB
HTML
280 lines
14 KiB
HTML
{# app/templates/vendor/team.html #}
|
|
{% extends "vendor/base.html" %}
|
|
{% from 'shared/macros/headers.html' import page_header_flex, refresh_button %}
|
|
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
|
{% from 'shared/macros/modals.html' import modal_simple %}
|
|
|
|
{% block title %}Team{% endblock %}
|
|
|
|
{% block alpine_data %}vendorTeam(){% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Page Header -->
|
|
{% call page_header_flex(title='Team', subtitle='Manage your team members and roles') %}
|
|
<div class="flex items-center gap-4">
|
|
{{ refresh_button(loading_var='loading', onclick='loadMembers()', variant='secondary') }}
|
|
<button
|
|
@click="openInviteModal()"
|
|
class="flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
|
|
>
|
|
<span x-html="$icon('user-plus', 'w-4 h-4 mr-2')"></span>
|
|
Invite Member
|
|
</button>
|
|
</div>
|
|
{% endcall %}
|
|
|
|
{{ loading_state('Loading team...') }}
|
|
|
|
{{ error_state('Error loading team') }}
|
|
|
|
<!-- Stats Cards -->
|
|
<div x-show="!loading" class="grid gap-6 mb-8 md:grid-cols-3">
|
|
<!-- Total Members -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-purple-500 bg-purple-100 rounded-full dark:text-purple-100 dark:bg-purple-500">
|
|
<span x-html="$icon('users', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Total Members</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.total">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Active Members -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-green-500 bg-green-100 rounded-full dark:text-green-100 dark:bg-green-500">
|
|
<span x-html="$icon('check-circle', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Active</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.active_count">0</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pending Invitations -->
|
|
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
|
<div class="p-3 mr-4 text-yellow-500 bg-yellow-100 rounded-full dark:text-yellow-100 dark:bg-yellow-500">
|
|
<span x-html="$icon('clock', 'w-5 h-5')"></span>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">Pending Invitations</p>
|
|
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.pending_invitations">0</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Team Members Table -->
|
|
<div x-show="!loading && !error" class="w-full mb-8 overflow-hidden rounded-lg shadow-xs">
|
|
<div class="w-full overflow-x-auto">
|
|
<table class="w-full whitespace-no-wrap">
|
|
<thead>
|
|
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
|
<th class="px-4 py-3">Member</th>
|
|
<th class="px-4 py-3">Role</th>
|
|
<th class="px-4 py-3">Status</th>
|
|
<th class="px-4 py-3">Joined</th>
|
|
<th class="px-4 py-3">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
|
<template x-for="member in members" :key="member.user_id">
|
|
<tr class="text-gray-700 dark:text-gray-400">
|
|
<!-- Member Info -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center text-sm">
|
|
<div class="relative w-10 h-10 mr-3 rounded-full overflow-hidden bg-purple-100 dark:bg-purple-900 flex items-center justify-center">
|
|
<span class="text-sm font-semibold text-purple-600 dark:text-purple-300" x-text="getInitials(member)"></span>
|
|
</div>
|
|
<div>
|
|
<p class="font-semibold" x-text="`${member.first_name || ''} ${member.last_name || ''}`.trim() || member.email"></p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400" x-text="member.email"></p>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<!-- Role -->
|
|
<td class="px-4 py-3 text-sm">
|
|
<span
|
|
class="px-2 py-1 font-semibold leading-tight text-purple-700 bg-purple-100 rounded-full dark:bg-purple-700 dark:text-purple-100"
|
|
x-text="getRoleName(member)"
|
|
></span>
|
|
</td>
|
|
<!-- Status -->
|
|
<td class="px-4 py-3 text-xs">
|
|
<span
|
|
:class="{
|
|
'px-2 py-1 font-semibold leading-tight rounded-full': true,
|
|
'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100': member.is_active && !member.invitation_pending,
|
|
'text-yellow-700 bg-yellow-100 dark:bg-yellow-700 dark:text-yellow-100': member.invitation_pending,
|
|
'text-gray-700 bg-gray-100 dark:bg-gray-700 dark:text-gray-100': !member.is_active
|
|
}"
|
|
x-text="member.invitation_pending ? 'Pending' : (member.is_active ? 'Active' : 'Inactive')"
|
|
></span>
|
|
</td>
|
|
<!-- Joined -->
|
|
<td class="px-4 py-3 text-sm" x-text="formatDate(member.created_at)"></td>
|
|
<!-- Actions -->
|
|
<td class="px-4 py-3">
|
|
<div class="flex items-center space-x-2 text-sm">
|
|
<button
|
|
@click="openEditModal(member)"
|
|
class="p-1 text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-blue-400"
|
|
title="Edit"
|
|
>
|
|
<span x-html="$icon('pencil', 'w-5 h-5')"></span>
|
|
</button>
|
|
<button
|
|
@click="confirmRemove(member)"
|
|
class="p-1 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400"
|
|
title="Remove"
|
|
x-show="!member.is_owner"
|
|
>
|
|
<span x-html="$icon('trash', 'w-5 h-5')"></span>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
<!-- Empty State -->
|
|
<tr x-show="members.length === 0">
|
|
<td colspan="5" class="px-4 py-8 text-center text-gray-500 dark:text-gray-400">
|
|
<div class="flex flex-col items-center">
|
|
<span x-html="$icon('users', 'w-12 h-12 text-gray-300 dark:text-gray-600 mb-4')"></span>
|
|
<p class="text-lg font-medium">No team members yet</p>
|
|
<p class="text-sm">Invite your first team member to get started</p>
|
|
<button
|
|
@click="openInviteModal()"
|
|
class="mt-4 px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700"
|
|
>
|
|
Invite Member
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Invite Modal -->
|
|
<div x-show="showInviteModal" x-cloak class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black bg-opacity-50">
|
|
<div class="w-full max-w-md bg-white rounded-lg shadow-xl dark:bg-gray-800" @click.away="showInviteModal = false">
|
|
<div class="flex items-center justify-between p-4 border-b dark:border-gray-700">
|
|
<h3 class="text-lg font-semibold text-gray-800 dark:text-gray-200">Invite Team Member</h3>
|
|
<button @click="showInviteModal = false" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200">
|
|
<span x-html="$icon('x', 'w-5 h-5')"></span>
|
|
</button>
|
|
</div>
|
|
<div class="p-4">
|
|
<div class="mb-4">
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Email *</label>
|
|
<input
|
|
type="email"
|
|
x-model="inviteForm.email"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
placeholder="colleague@example.com"
|
|
/>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-4 mb-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">First Name</label>
|
|
<input
|
|
type="text"
|
|
x-model="inviteForm.first_name"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Last Name</label>
|
|
<input
|
|
type="text"
|
|
x-model="inviteForm.last_name"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Role</label>
|
|
<select
|
|
x-model="inviteForm.role_name"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
>
|
|
<template x-for="role in roleOptions" :key="role.value">
|
|
<option :value="role.value" x-text="role.label"></option>
|
|
</template>
|
|
</select>
|
|
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400" x-text="roleOptions.find(r => r.value === inviteForm.role_name)?.description"></p>
|
|
</div>
|
|
</div>
|
|
<div class="flex justify-end gap-2 p-4 border-t dark:border-gray-700">
|
|
<button @click="showInviteModal = false" class="px-4 py-2 text-sm text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200">
|
|
Cancel
|
|
</button>
|
|
<button
|
|
@click="sendInvitation()"
|
|
:disabled="saving || !inviteForm.email"
|
|
class="px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 disabled:opacity-50"
|
|
>
|
|
<span x-show="!saving">Send Invitation</span>
|
|
<span x-show="saving">Sending...</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit Modal -->
|
|
{{ modal_simple(
|
|
show_var='showEditModal',
|
|
title='Edit Team Member',
|
|
icon='pencil',
|
|
icon_color='blue',
|
|
confirm_text='Save',
|
|
confirm_class='bg-purple-600 hover:bg-purple-700 focus:shadow-outline-purple',
|
|
confirm_fn='updateMember()',
|
|
loading_var='saving'
|
|
) }}
|
|
<template x-if="showEditModal && selectedMember">
|
|
<div class="mb-4">
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
|
Edit <span class="font-semibold" x-text="selectedMember.email"></span>
|
|
</p>
|
|
<div class="mb-4">
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Role</label>
|
|
<select
|
|
x-model="editForm.role_id"
|
|
class="w-full px-4 py-2 text-sm text-gray-700 bg-gray-50 border border-gray-200 rounded-lg dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600 focus:border-purple-400 focus:outline-none focus:ring-1 focus:ring-purple-400"
|
|
>
|
|
<template x-for="role in roles" :key="role.id">
|
|
<option :value="role.id" x-text="role.name"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
<div class="flex items-center">
|
|
<input type="checkbox" x-model="editForm.is_active" id="is_active" class="w-4 h-4 text-purple-600 rounded focus:ring-purple-500" />
|
|
<label for="is_active" class="ml-2 text-sm text-gray-700 dark:text-gray-300">Active</label>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<!-- Remove Confirmation Modal -->
|
|
{{ modal_simple(
|
|
show_var='showRemoveModal',
|
|
title='Remove Team Member',
|
|
icon='exclamation-triangle',
|
|
icon_color='red',
|
|
confirm_text='Remove',
|
|
confirm_class='bg-red-600 hover:bg-red-700 focus:shadow-outline-red',
|
|
confirm_fn='removeMember()',
|
|
loading_var='saving'
|
|
) }}
|
|
<template x-if="showRemoveModal && selectedMember">
|
|
<p class="text-gray-600 dark:text-gray-400 mb-4">
|
|
Are you sure you want to remove <span class="font-semibold" x-text="selectedMember.email"></span> from the team?
|
|
They will lose access to this vendor.
|
|
</p>
|
|
</template>
|
|
{% endblock %}
|
|
|
|
{% block extra_scripts %}
|
|
<script src="{{ url_for('static', path='vendor/js/team.js') }}"></script>
|
|
{% endblock %}
|