From d99e47ecce38b04bca92397ea7e808259bfe20eb Mon Sep 17 00:00:00 2001 From: javad Date: Tue, 6 Oct 2026 12:08:16 +0330 Subject: [PATCH] fix UI UX --- static/css/customer-dock.css | 24 ++++++++++++ static/css/customer-profile.css | 36 ++++++++++++++++++ static/css/customer-tickets.css | 42 +++++++++++++++++++++ templates/accounts/profile.html | 45 ++++++++++++++++------- templates/base.html | 3 +- templates/tickets/_customer_dock.html | 14 +++++++ templates/tickets/customer_list.html | 44 +++++++++++++--------- tests/e2e/pages/customer_profile.py | 38 +++++++++++++++++++ tests/e2e/pages/customer_tickets.py | 39 ++++++++++++++++++++ tests/e2e/test_customer_profile_design.py | 38 +++++++++++++++++++ tests/e2e/test_customer_tickets_design.py | 42 +++++++++++++++++++++ 11 files changed, 333 insertions(+), 32 deletions(-) create mode 100644 static/css/customer-dock.css create mode 100644 static/css/customer-profile.css create mode 100644 static/css/customer-tickets.css create mode 100644 templates/tickets/_customer_dock.html create mode 100644 tests/e2e/pages/customer_profile.py create mode 100644 tests/e2e/pages/customer_tickets.py create mode 100644 tests/e2e/test_customer_profile_design.py create mode 100644 tests/e2e/test_customer_tickets_design.py diff --git a/static/css/customer-dock.css b/static/css/customer-dock.css new file mode 100644 index 0000000..0c50725 --- /dev/null +++ b/static/css/customer-dock.css @@ -0,0 +1,24 @@ +/* Shared Chaharsu navigation. Composer changes are confined to the dock. */ +.customer-mobile-dock.chaharsu-dock { + grid-template-columns: repeat(3, minmax(0, 1fr)); + bottom: calc(12px + env(safe-area-inset-bottom)); +} +.customer-mobile-dock.chaharsu-dock a { + min-height: 52px; + gap: 4px; + font-size: 12px; + color: #cadbea; +} +.customer-mobile-dock.chaharsu-dock svg { + width: 20px; + height: 20px; + flex-shrink: 0; +} +.customer-mobile-dock.chaharsu-dock a.active { + background: #0b4c8c; + color: #fff; +} +.customer-mobile-dock.chaharsu-dock a:focus-visible { + outline: 3px solid #fff; + outline-offset: -3px; +} diff --git a/static/css/customer-profile.css b/static/css/customer-profile.css new file mode 100644 index 0000000..34e8447 --- /dev/null +++ b/static/css/customer-profile.css @@ -0,0 +1,36 @@ +/* Chaharsu profile: scoped rules preserve the ticket composer and other forms. */ +.profile-breadcrumb { display: inline-flex; align-items: center; min-height: 44px; } +.profile-heading { display: flex; align-items: flex-start; gap: 16px; margin-top: 8px; } +.profile-heading .service-icon { flex-shrink: 0; } +.profile-heading h1 { margin: 0; } +.customer-profile .profile-heading p { margin: 6px 0 0; } +.customer-profile-form.pay-form { max-width: none; margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; } +.customer-profile-form .pay-card { margin: 0 0 20px; padding: 22px; border-radius: 22px; } +.customer-profile-form h2 { margin: 0 0 12px; } +.profile-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; } +.profile-card-heading h2 { margin: 0; } +.profile-mobile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: #526c86; font-size: .875rem; } +.profile-mobile bdi { color: #08376b; font-weight: 700; } +.profile-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; } +.customer-profile-form .pay-field { margin: 0; min-width: 0; } +.customer-profile-form .pay-field label { font-size: .875rem; } +.customer-profile-form input:not([type=hidden]),.customer-profile-form select { min-height: 48px; padding: 10px 12px; font-size: 1rem; box-shadow: none; } +.customer-profile-form input[type=password] { direction: ltr; text-align: right; } +.customer-profile .profile-guidance { margin: 8px 0 16px; color: #526c86; font-size: .875rem; line-height: 1.8; } +.customer-profile [data-location-hint] { margin: 12px 0 0; } +.customer-profile .is-error,.customer-profile .errorlist { color: #9f1f1f; font-size: .875rem; line-height: 1.8; } +.customer-profile .errorlist { list-style: none; padding: 0; margin: 6px 0 0; } +.customer-profile-form [aria-invalid=true] { border-color: #9f1f1f; } +.profile-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; } +.profile-actions .pay-button { min-width: 160px; } +@media (max-width: 639px) { + .profile-heading { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 8px 12px; align-items: center; } + .profile-heading > div { display: contents; } + .profile-heading h1 { grid-column: 1; grid-row: 1; } + .profile-heading .service-icon { grid-column: 2; grid-row: 1; width: 40px; height: 40px; border-radius: 12px; } + .customer-profile .profile-heading p { grid-column: 1 / -1; grid-row: 2; margin: 0; } + .customer-profile-form .pay-card { padding: 16px; border-radius: 20px; margin-bottom: 16px; } + .profile-field-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; } + .profile-actions { flex-direction: column; gap: 8px; margin-top: 20px; } + .profile-actions .pay-button { width: 100%; } +} diff --git a/static/css/customer-tickets.css b/static/css/customer-tickets.css new file mode 100644 index 0000000..bd8cdc9 --- /dev/null +++ b/static/css/customer-tickets.css @@ -0,0 +1,42 @@ +/* Ticket history follows the Chaharsu shell; no composer selectors. */ +.customer-tickets .chaharsu-heading h1 { margin: 4px 0 0; } +.customer-tickets .tickets-breadcrumb { display: inline-flex; align-items: center; min-height: 44px; } +.customer-tickets .tickets-intro { margin-bottom: 20px; } +.customer-tickets .tickets-intro-kicker { margin: 0 0 8px; font-size: 12px; color: #cadbea; } +.customer-tickets .tickets-intro .service-actions { padding-top: 16px; } +.customer-tickets .service-actions a { white-space: normal; text-align: center; } +.tickets-profile-note { display: flex; gap: 12px; padding: 16px; border: 1px solid #cde6f7; border-radius: 20px; background: #f6fbff; } +.tickets-profile-note > div { min-width: 0; } +.customer-tickets .tickets-profile-note h2 { font-size: 16px; margin: 0; } +.tickets-profile-note p { color: #526c86; font-size: 14px; line-height: 1.8; } +.tickets-profile-note .service-icon { width: 36px; height: 36px; flex-shrink: 0; } +.tickets-profile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; } +.customer-tickets .tickets-text-link { display: inline-flex; align-items: center; min-height: 44px; color: #08376b; text-decoration: underline; text-underline-offset: 4px; } +.customer-tickets .customer-list-heading { scroll-margin-top: 100px; flex-wrap: wrap; } +.tickets-list-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; } +.tickets-list-card { display: flex; flex-direction: column; min-width: 0; padding: 16px; border: 1px solid #dce5ed; border-radius: 20px; background: #fff; color: #08376b; transition: border-color .18s, transform .18s, box-shadow .18s; } +.tickets-card-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; } +.tickets-status { padding: 4px 12px; border-radius: 20px; background: #e5f4ff; color: #08376b; font-size: 12px; font-weight: 700; } +.tickets-number { color: #526c86; font-size: 12px; } +.customer-tickets .tickets-list-card h3 { margin: 16px 0; font-size: 18px; font-weight: 800; line-height: 1.7; } +.tickets-card-meta { display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding-top: 12px; border-top: 1px solid #e7edf2; color: #526c86; font-size: 14px; } +.tickets-card-meta time { font-size: 12px; margin-top: 4px; } +.tickets-card-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; font-size: 14px; font-weight: 700; } +.tickets-card-link svg { width: 18px; height: 18px; } +.tickets-list-card:hover { border-color: #91bfdd; transform: translateY(-3px); box-shadow: 0 15px 35px -25px #08376b70; } +.tickets-empty { grid-column: 1 / -1; margin: 0; } +.customer-tickets .tickets-empty h3 { font-size: 18px; margin: 12px 0 0; } +.tickets-empty .pay-button { margin-top: 12px; } +@media (min-width: 640px) { + .tickets-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } + .tickets-list-card { padding: 22px; border-radius: 22px; } +} +@media (max-width: 639px) { + .customer-tickets .tickets-intro .service-actions { padding-top: 10px; } + .tickets-profile-note { padding: 14px; } + .tickets-profile-note > .service-icon { display: none; } +} +@media (prefers-reduced-motion: reduce) { + .tickets-list-card { transition: none; } + .tickets-list-card:hover { transform: none; } +} diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html index 969edb2..6120a18 100644 --- a/templates/accounts/profile.html +++ b/templates/accounts/profile.html @@ -1,20 +1,37 @@ -{% extends 'base.html' %}{% load static %} +{% extends 'payments/base.html' %}{% load static %} {% block title %}{{ page_title }}{% endblock %} +{% block extra_head %}{{ block.super }}{% endblock %} {% block content %} -

تنظیمات حساب

پروفایل من

اطلاعات شما به کارشناس کمک می‌کند پاسخ دقیق‌تری ارائه کند.

بازگشت به تیکت‌ها
-
-
{{ user.mobile }}
-
{% csrf_token %}{{ form.non_field_errors }} -
{{ form.first_name.label_tag }}{{ form.first_name }}{{ form.first_name.errors }}
{{ form.last_name.label_tag }}{{ form.last_name }}{{ form.last_name.errors }}
-
{{ form.customer_type.label_tag }}{{ form.customer_type }}{{ form.customer_type.errors }}
-
-

موقعیت پیش‌فرض

اختیاری است؛ در تیکت‌های جدید به‌صورت خودکار پیشنهاد می‌شود.

اختیاری
-
{{ form.province.label_tag }}{{ form.province }}{{ form.province.errors }}
{{ form.city.label_tag }}{{ form.city }}{{ form.city.errors }}
-

نام استان را جست‌وجو و انتخاب کنید.

+
+
+ خدمات چهارسو +
{% include 'payments/_icon.html' with name='user' %}

پروفایل من

اطلاعات شما به کارشناس کمک می‌کند پاسخ دقیق‌تری ارائه کند.

+
+ {% csrf_token %} + {% if form.errors %}{% endif %} +
+

اطلاعات حساب

شماره همراه{{ user.mobile }}
+
+
{{ form.first_name.label_tag }}{{ form.first_name }}{{ form.first_name.errors }}
+
{{ form.last_name.label_tag }}{{ form.last_name }}{{ form.last_name.errors }}
+
{{ form.customer_type.label_tag }}{{ form.customer_type }}{{ form.customer_type.errors }}
+
-
{{ form.password.label_tag }}{{ form.password }}{% if form.password.help_text %}{{ form.password.help_text }}{% endif %}{{ form.password.errors }}
- +
+

موقعیت پیش‌فرض

+

اختیاری است؛ در درخواست‌های جدید به‌صورت خودکار پیشنهاد می‌شود.

+
+
{{ form.province.label_tag }}{{ form.province }}{{ form.province.errors }}
+
{{ form.city.label_tag }}{{ form.city }}{{ form.city.errors }}
+
+

نام استان را جست‌وجو و انتخاب کنید.

+
+
+

رمز عبور

+
{{ form.password.label_tag }}{{ form.password }}{% if form.password.help_text %}

{{ form.password.help_text }}

{% endif %}{{ form.password.errors }}
+
+
- {% endblock %} +{% block extra_scripts %}{% endblock %} diff --git a/templates/base.html b/templates/base.html index e2f5cc1..8b15f7f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,6 +12,7 @@ + {% if request.resolver_match.namespace == 'accounts' and request.resolver_match.url_name == 'profile' or financial_page or request.resolver_match.namespace == 'tickets' and request.resolver_match.url_name == 'list' or request.resolver_match.namespace == 'tickets' and request.resolver_match.url_name == 'new' %}{% endif %} {% block extra_head %}{% endblock %} @@ -65,7 +66,7 @@ {% endblock %} {% elif user.is_authenticated %} -{% if financial_page %}{% else %} {% endif %} +{% if request.resolver_match.namespace == 'accounts' and request.resolver_match.url_name == 'profile' or financial_page or request.resolver_match.namespace == 'tickets' and request.resolver_match.url_name == 'list' or request.resolver_match.namespace == 'tickets' and request.resolver_match.url_name == 'new' %}{% include 'tickets/_customer_dock.html' %}{% else %} {% endif %} {% endif %} {% block pwa_install_prompt %}{% endblock %} diff --git a/templates/tickets/_customer_dock.html b/templates/tickets/_customer_dock.html new file mode 100644 index 0000000..2c6dcae --- /dev/null +++ b/templates/tickets/_customer_dock.html @@ -0,0 +1,14 @@ + diff --git a/templates/tickets/customer_list.html b/templates/tickets/customer_list.html index 2bac4fc..7dc2910 100644 --- a/templates/tickets/customer_list.html +++ b/templates/tickets/customer_list.html @@ -1,29 +1,39 @@ -{% extends 'base.html' %}{% load jalali %} +{% extends 'payments/base.html' %}{% load static jalali %} {% block title %}{{ page_title }}{% endblock %} +{% block extra_head %}{{ block.super }}{% endblock %} {% block content %} -{% if site_branding.customer_tickets_hero_enabled %}
-

{{ site_branding.customer_tickets_hero_eyebrow }}

-

{{ site_branding.customer_tickets_hero_heading|linebreaksbr }}

-

{{ site_branding.customer_tickets_hero_body|linebreaksbr }}

-
- + ثبت درخواست جدید - درخواست‌های قبلی +
+
خدمات چهارسو

درخواست‌های من

درخواست‌ها و پاسخ کارشناسان را از اینجا پیگیری کنید.

+{% if site_branding.customer_tickets_hero_enabled %}
+ {% if site_branding.customer_tickets_hero_eyebrow %}

{{ site_branding.customer_tickets_hero_eyebrow }}

{% endif %} +
+ {% include 'payments/_icon.html' with name='chat' %} +

{{ site_branding.customer_tickets_hero_heading|linebreaksbr }}

+

{{ site_branding.customer_tickets_hero_body|linebreaksbr }}

+
+
{% endif %} -{% if missing_profile_fields %}{% endif %} -
-

پیگیری‌ها

درخواست‌های اخیر شما

- {{ tickets|length }} مورد +{% if missing_profile_fields %}{% endif %} +
+

درخواست‌های اخیر شما

+ {{ tickets|length }} مورد
-
{% endblock %} +{% block extra_scripts %}{% endblock %} {% block pwa_install_prompt %}{% endblock %} diff --git a/tests/e2e/pages/customer_profile.py b/tests/e2e/pages/customer_profile.py new file mode 100644 index 0000000..f503541 --- /dev/null +++ b/tests/e2e/pages/customer_profile.py @@ -0,0 +1,38 @@ +from playwright.sync_api import expect + +from .base import BasePage + + +class CustomerProfilePage(BasePage): + def open(self): + self.goto('/profile/') + expect(self.page.get_by_role('heading', name='پروفایل من', exact=True)).to_be_visible() + + def edit_details(self): + self.page.get_by_label('نام:', exact=True).fill('مریم') + self.page.get_by_label('نام خانوادگی:', exact=True).fill('رضایی') + self.page.get_by_label('نوع مشتری:', exact=True).select_option('PERSON') + expect(self.page.locator('#profile-province-options option')).not_to_have_count(0) + self.page.get_by_label('استان:', exact=True).fill('تهران') + expect(self.page.get_by_label('شهر:', exact=True)).to_be_enabled() + self.page.get_by_label('شهر:', exact=True).fill('تهران') + + def assert_validation_and_save(self): + self.page.get_by_label('رمز عبور جدید:', exact=True).fill('short') + self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click() + expect(self.page.get_by_label('رمز عبور جدید:', exact=True)).to_be_focused() + assert self.page.get_by_label('رمز عبور جدید:', exact=True).evaluate('(input) => input.validity.tooShort') + self.page.get_by_label('رمز عبور جدید:', exact=True).fill('') + self.page.get_by_label('شهر:', exact=True).fill('رشت') + self.page.get_by_label('شهر:', exact=True).press('Tab') + self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click() + expect(self.page.get_by_role('alert')).to_contain_text('اطلاعات مشخص‌شده را بررسی') + expect(self.page.get_by_label('نام:', exact=True)).to_have_value('مریم') + expect(self.page.get_by_label('شهر:', exact=True)).to_have_attribute('aria-invalid', 'true') + expect(self.page.locator('#profile-city-options option[value="تهران"]')).to_have_count(1) + self.page.get_by_label('شهر:', exact=True).fill('تهران') + self.page.get_by_label('شهر:', exact=True).press('Tab') + self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click() + expect(self.page.locator('.flash')).to_contain_text('پروفایل شما ذخیره شد.') + expect(self.page.get_by_label('نام:', exact=True)).to_have_value('مریم') + expect(self.page.get_by_label('شهر:', exact=True)).to_have_value('تهران') diff --git a/tests/e2e/pages/customer_tickets.py b/tests/e2e/pages/customer_tickets.py new file mode 100644 index 0000000..07a6787 --- /dev/null +++ b/tests/e2e/pages/customer_tickets.py @@ -0,0 +1,39 @@ +from django.urls import reverse +from playwright.sync_api import expect + +from .base import BasePage + + +class CustomerTicketsPage(BasePage): + def assert_dock(self, active): + dock = self.page.get_by_role('navigation', name='دسترسی سریع مشتری') + expect(dock.get_by_role('link')).to_have_count(3) + for name in ('خدمات', 'درخواست‌ها', 'پروفایل'): + expect(dock.get_by_role('link', name=name, exact=True)).to_be_visible() + expect(dock.locator('[aria-current]')).to_have_text(active) + for link in dock.get_by_role('link').all(): + box = link.bounding_box() + assert box['width'] >= 44 and box['height'] >= 44 + + def follow_dock(self, name, destination): + self.page.get_by_role('navigation', name='دسترسی سریع مشتری').get_by_role( + 'link', name=name, exact=True + ).click() + expect(self.page).to_have_url(self.url(reverse(destination))) + + def assert_history(self, subject=None): + expect(self.page.get_by_role('heading', name='درخواست‌های من', exact=True)).to_be_visible() + if subject: + card = self.page.locator('.tickets-list-card').filter(has_text=subject) + expect(card.get_by_role('heading', name=subject, exact=True)).to_be_visible() + expect(card).to_contain_text('مشاهده و پیگیری') + else: + expect(self.page.get_by_role('heading', name='هنوز درخواستی ثبت نشده')).to_be_visible() + expect(self.page.get_by_role('link', name='ثبت اولین درخواست')).to_be_visible() + assert self.page.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1') + + def start_request(self): + self.page.get_by_role('link', name='ثبت درخواست جدید', exact=True).click() + expect(self.page).to_have_url(self.url(reverse('tickets:new'))) + expect(self.page.locator('.ticket-wizard-page')).to_be_visible() + diff --git a/tests/e2e/test_customer_profile_design.py b/tests/e2e/test_customer_profile_design.py new file mode 100644 index 0000000..5b4c51f --- /dev/null +++ b/tests/e2e/test_customer_profile_design.py @@ -0,0 +1,38 @@ +import pytest + +from apps.accounts.models import User +from tests.e2e.pages.auth import AuthenticationPage +from tests.e2e.pages.customer_profile import CustomerProfilePage +from tests.e2e.pages.customer_tickets import CustomerTicketsPage + +pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)] + + +@pytest.mark.parametrize('width', [320, 393, 1440]) +def test_profile_design_navigation_validation_and_save(live_server, browser_page, width): + password = 'Profile-design-2026!' + customer = User.objects.create_user( + username='profile-design', mobile='09120008892', password=password, account_type='CUSTOMER' + ) + with browser_page() as page: + page.set_viewport_size({'width': width, 'height': 856}) + AuthenticationPage(page, live_server.url).login_customer(customer, password) + navigation = CustomerTicketsPage(page, live_server.url) + profile = CustomerProfilePage(page, live_server.url) + if width < 640: + navigation.follow_dock('پروفایل', 'accounts:profile') + navigation.assert_dock('پروفایل') + else: + profile.open() + profile.edit_details() + profile.assert_validation_and_save() + assert page.evaluate('document.documentElement.scrollWidth <= innerWidth + 1') + if width < 640: + navigation.assert_dock('پروفایل') + navigation.follow_dock('درخواست‌ها', 'tickets:list') + navigation.assert_dock('درخواست‌ها') + navigation.follow_dock('خدمات', 'payments:home') + navigation.assert_dock('خدمات') + customer.customer_profile.refresh_from_db() + assert customer.customer_profile.first_name == 'مریم' + assert customer.customer_profile.city == 'تهران' diff --git a/tests/e2e/test_customer_tickets_design.py b/tests/e2e/test_customer_tickets_design.py new file mode 100644 index 0000000..38eefa6 --- /dev/null +++ b/tests/e2e/test_customer_tickets_design.py @@ -0,0 +1,42 @@ +import pytest + +from apps.accounts.models import User +from apps.tickets.models import TicketCategory +from apps.tickets.services import create_ticket +from tests.e2e.pages.auth import AuthenticationPage +from tests.e2e.pages.customer_tickets import CustomerTicketsPage + +pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)] + + +@pytest.mark.parametrize('width', [320, 393, 1440]) +@pytest.mark.parametrize('has_ticket', [False, True], ids=['empty', 'history']) +def test_customer_history_and_composer_share_chaharsu_navigation(live_server, browser_page, width, has_ticket): + password = 'Design-test-2026!' + customer = User.objects.create_user( + username='customer-design', mobile='09120008891', password=password, account_type='CUSTOMER' + ) + subject = 'پیگیری سفارش و هماهنگی ارسال کالا با کارشناسان فروش برای تحویل در محل مشتری' + if has_ticket: + category = TicketCategory.objects.create(title='هماهنگی ارسال', slug='design-shipping') + create_ticket(customer=customer, category=category, subject=subject, body='شرح درخواست') + with browser_page() as page: + page.set_viewport_size({'width': width, 'height': 856}) + AuthenticationPage(page, live_server.url).login_customer(customer, password) + history = CustomerTicketsPage(page, live_server.url) + history.goto('/chaharsu/') + if width < 640: + history.assert_dock('خدمات') + history.follow_dock('درخواست‌ها', 'tickets:list') + else: + history.goto('/tickets/') + history.assert_history(subject if has_ticket else None) + if width < 640: + history.assert_dock('درخواست‌ها') + history.start_request() + if width < 640: + history.assert_dock('درخواست‌ها') + history.follow_dock('درخواست‌ها', 'tickets:list') + history.assert_history(subject if has_ticket else None) + history.follow_dock('خدمات', 'payments:home') + history.assert_dock('خدمات')