fix: sidebar accordion + koja slug + support ticket LINQ crash
CI/CD / CI · API (dotnet build + test) (push) Successful in 5m50s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 32s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m3s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 48s
CI/CD / Deploy · all services (push) Has been cancelled
CI/CD / CI · API (dotnet build + test) (push) Successful in 5m50s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 32s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m3s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 48s
CI/CD / Deploy · all services (push) Has been cancelled
Sidebar:
- All groups start collapsed on first load (v4 storage key resets old state)
- Opening one group closes all others (accordion)
- Navigating to a section opens only that section's group
Koja slug:
- SlugHelper: Persian->Latin transliteration, slug validation
- Registration accepts optional custom slug; auto-derives from cafe name
- Slug can be updated from dashboard Settings -> Profile
- Settings PATCH validates uniqueness (SLUG_TAKEN) and format (INVALID_SLUG)
- koja.meezi.ir/{slug} now redirects to /fa/cafe/{slug} (short URL support)
Bug fix:
- SupportTicketService: cafeId/status filters applied before Select() projection
to fix EF "could not be translated" crash on the support tickets page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Meezi.API.Models.Cafes;
|
using Meezi.API.Models.Cafes;
|
||||||
using Meezi.API.Services;
|
using Meezi.API.Services;
|
||||||
using Meezi.Core.Interfaces;
|
using Meezi.Core.Interfaces;
|
||||||
|
using Meezi.Core.Utilities;
|
||||||
using Meezi.Infrastructure.Branding;
|
using Meezi.Infrastructure.Branding;
|
||||||
using Meezi.Infrastructure.Data;
|
using Meezi.Infrastructure.Data;
|
||||||
using Meezi.Shared;
|
using Meezi.Shared;
|
||||||
@@ -57,6 +58,21 @@ public class CafeSettingsController : CafeApiControllerBase
|
|||||||
if (cafe is null) return NotFoundError();
|
if (cafe is null) return NotFoundError();
|
||||||
|
|
||||||
if (request.Name is not null) cafe.Name = request.Name.Trim();
|
if (request.Name is not null) cafe.Name = request.Name.Trim();
|
||||||
|
|
||||||
|
if (request.Slug is not null)
|
||||||
|
{
|
||||||
|
var newSlug = request.Slug.Trim().ToLowerInvariant();
|
||||||
|
if (!SlugHelper.IsValidSlug(newSlug))
|
||||||
|
return BadRequest(new ApiResponse<object>(false, null,
|
||||||
|
new ApiError("INVALID_SLUG", "Slug must be 2-80 lowercase letters, digits, or hyphens.")));
|
||||||
|
|
||||||
|
var taken = await _db.Cafes.AnyAsync(c => c.Slug == newSlug && c.Id != cafeId, ct);
|
||||||
|
if (taken)
|
||||||
|
return Conflict(new ApiResponse<object>(false, null,
|
||||||
|
new ApiError("SLUG_TAKEN", "This Koja profile address is already in use. Please choose another.")));
|
||||||
|
|
||||||
|
cafe.Slug = newSlug;
|
||||||
|
}
|
||||||
if (request.Phone is not null) cafe.Phone = request.Phone.Trim();
|
if (request.Phone is not null) cafe.Phone = request.Phone.Trim();
|
||||||
if (request.Address is not null) cafe.Address = request.Address.Trim();
|
if (request.Address is not null) cafe.Address = request.Address.Trim();
|
||||||
if (request.City is not null) cafe.City = request.City.Trim();
|
if (request.City is not null) cafe.City = request.City.Trim();
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public record SwitchCafeRequest(string CafeId);
|
|||||||
public record SwitchBranchRequest(string? BranchId);
|
public record SwitchBranchRequest(string? BranchId);
|
||||||
|
|
||||||
/// <summary>Step 1 of self-registration: send OTP to a new phone number.</summary>
|
/// <summary>Step 1 of self-registration: send OTP to a new phone number.</summary>
|
||||||
public record RegisterRequest(string Phone, string CafeName);
|
/// <param name="Slug">Optional custom Koja slug (e.g. "lamiz-enghelab"). Auto-derived from CafeName if omitted.</param>
|
||||||
|
public record RegisterRequest(string Phone, string CafeName, string? Slug = null);
|
||||||
|
|
||||||
/// <summary>Step 2 of self-registration: verify OTP and create the cafe account.</summary>
|
/// <summary>Step 2 of self-registration: verify OTP and create the cafe account.</summary>
|
||||||
public record VerifyRegisterRequest(string Phone, string Code);
|
public record VerifyRegisterRequest(string Phone, string Code);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public record CafeSettingsDto(
|
|||||||
|
|
||||||
public record PatchCafeSettingsRequest(
|
public record PatchCafeSettingsRequest(
|
||||||
string? Name,
|
string? Name,
|
||||||
|
/// <summary>Custom Koja profile slug (e.g. "lamiz-enghelab"). Must be unique across all cafés.</summary>
|
||||||
|
string? Slug,
|
||||||
string? Phone,
|
string? Phone,
|
||||||
string? Address,
|
string? Address,
|
||||||
string? City,
|
string? City,
|
||||||
|
|||||||
@@ -303,8 +303,15 @@ public class AuthService : IAuthService
|
|||||||
|
|
||||||
var otp = Random.Shared.Next(100000, 999999).ToString();
|
var otp = Random.Shared.Next(100000, 999999).ToString();
|
||||||
await redis.StringSetAsync($"otp:{phone}", otp, TimeSpan.FromSeconds(OtpTtlSeconds));
|
await redis.StringSetAsync($"otp:{phone}", otp, TimeSpan.FromSeconds(OtpTtlSeconds));
|
||||||
// Store the cafe name alongside the OTP so verify-register can create the cafe
|
|
||||||
await redis.StringSetAsync($"reg_meta:{phone}", cafeName, TimeSpan.FromSeconds(OtpTtlSeconds));
|
// Determine the requested slug: use provided slug, or auto-derive from café name.
|
||||||
|
// Format stored: "cafeName||slug" (double-pipe delimiter). Slug may be empty.
|
||||||
|
var requestedSlug = string.IsNullOrWhiteSpace(request.Slug)
|
||||||
|
? Meezi.Core.Utilities.SlugHelper.Slugify(cafeName)
|
||||||
|
: request.Slug.Trim().ToLowerInvariant();
|
||||||
|
|
||||||
|
var regMeta = $"{cafeName}||{requestedSlug}";
|
||||||
|
await redis.StringSetAsync($"reg_meta:{phone}", regMeta, TimeSpan.FromSeconds(OtpTtlSeconds));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -342,10 +349,25 @@ public class AuthService : IAuthService
|
|||||||
if (storedOtp.IsNullOrEmpty || storedOtp.ToString() != code)
|
if (storedOtp.IsNullOrEmpty || storedOtp.ToString() != code)
|
||||||
return (false, null, "INVALID_OTP", "Invalid or expired verification code.");
|
return (false, null, "INVALID_OTP", "Invalid or expired verification code.");
|
||||||
|
|
||||||
var cafeName = (await redis.StringGetAsync($"reg_meta:{phone}")).ToString();
|
var regMetaRaw = (await redis.StringGetAsync($"reg_meta:{phone}")).ToString();
|
||||||
if (string.IsNullOrWhiteSpace(cafeName))
|
if (string.IsNullOrWhiteSpace(regMetaRaw))
|
||||||
return (false, null, "REGISTRATION_EXPIRED", "Registration session expired. Please start again.");
|
return (false, null, "REGISTRATION_EXPIRED", "Registration session expired. Please start again.");
|
||||||
|
|
||||||
|
// Parse "cafeName||slug" format (double-pipe delimiter)
|
||||||
|
string cafeName;
|
||||||
|
string? requestedSlug;
|
||||||
|
var sepIdx = regMetaRaw.IndexOf("||", StringComparison.Ordinal);
|
||||||
|
if (sepIdx >= 0)
|
||||||
|
{
|
||||||
|
cafeName = regMetaRaw[..sepIdx];
|
||||||
|
requestedSlug = regMetaRaw[(sepIdx + 2)..];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cafeName = regMetaRaw;
|
||||||
|
requestedSlug = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Double-check no owner was created in the meantime (race condition guard)
|
// Double-check no owner was created in the meantime (race condition guard)
|
||||||
var alreadyOwner = await _db.Employees
|
var alreadyOwner = await _db.Employees
|
||||||
.AnyAsync(e => e.Phone == phone && e.Role == EmployeeRole.Owner && e.DeletedAt == null, cancellationToken);
|
.AnyAsync(e => e.Phone == phone && e.Role == EmployeeRole.Owner && e.DeletedAt == null, cancellationToken);
|
||||||
@@ -356,8 +378,8 @@ public class AuthService : IAuthService
|
|||||||
return (false, null, "ALREADY_REGISTERED", "An account already exists for this phone number. Please sign in.");
|
return (false, null, "ALREADY_REGISTERED", "An account already exists for this phone number. Please sign in.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a unique slug
|
// Generate a unique slug (try requested slug first, fall back to random)
|
||||||
var slug = await GenerateUniqueSlugAsync(cancellationToken);
|
var slug = await GenerateUniqueSlugAsync(requestedSlug, cancellationToken);
|
||||||
|
|
||||||
var cafe = new Cafe
|
var cafe = new Cafe
|
||||||
{
|
{
|
||||||
@@ -402,12 +424,27 @@ public class AuthService : IAuthService
|
|||||||
return (true, tokens, null, null);
|
return (true, tokens, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> GenerateUniqueSlugAsync(CancellationToken ct)
|
private async Task<string> GenerateUniqueSlugAsync(string? preferred, CancellationToken ct)
|
||||||
{
|
{
|
||||||
|
// Try the preferred/derived slug first
|
||||||
|
if (Meezi.Core.Utilities.SlugHelper.IsValidSlug(preferred))
|
||||||
|
{
|
||||||
|
if (!await _db.Cafes.AnyAsync(c => c.Slug == preferred, ct))
|
||||||
|
return preferred!;
|
||||||
|
|
||||||
|
// Preferred slug is taken — append a short random suffix
|
||||||
|
for (var i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
var candidate = $"{preferred}-{Guid.NewGuid().ToString("N")[..4]}";
|
||||||
|
if (!await _db.Cafes.AnyAsync(c => c.Slug == candidate, ct))
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Full random fallback
|
||||||
string slug;
|
string slug;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// e.g. "cafe-a3f9b2c"
|
|
||||||
slug = "cafe-" + Guid.NewGuid().ToString("N")[..7];
|
slug = "cafe-" + Guid.NewGuid().ToString("N")[..7];
|
||||||
} while (await _db.Cafes.AnyAsync(c => c.Slug == slug, ct));
|
} while (await _db.Cafes.AnyAsync(c => c.Slug == slug, ct));
|
||||||
return slug;
|
return slug;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Meezi.API.Models.Auth;
|
using Meezi.API.Models.Auth;
|
||||||
using Meezi.Core.Utilities;
|
using Meezi.Core.Utilities;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Meezi.API.Validators;
|
namespace Meezi.API.Validators;
|
||||||
|
|
||||||
@@ -51,6 +52,10 @@ public class RegisterRequestValidator : AbstractValidator<RegisterRequest>
|
|||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.MaximumLength(100)
|
.MaximumLength(100)
|
||||||
.WithMessage("Cafe name must be between 1 and 100 characters.");
|
.WithMessage("Cafe name must be between 1 and 100 characters.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Slug)
|
||||||
|
.Must(s => s == null || SlugHelper.IsValidSlug(s))
|
||||||
|
.WithMessage("Slug must be 2-80 lowercase letters, digits, or hyphens (e.g. my-cafe).");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Meezi.API.Models.Cafes;
|
using Meezi.API.Models.Cafes;
|
||||||
|
using Meezi.Core.Utilities;
|
||||||
|
|
||||||
namespace Meezi.API.Validators;
|
namespace Meezi.API.Validators;
|
||||||
|
|
||||||
@@ -8,6 +9,10 @@ public class PatchCafeSettingsRequestValidator : AbstractValidator<PatchCafeSett
|
|||||||
public PatchCafeSettingsRequestValidator()
|
public PatchCafeSettingsRequestValidator()
|
||||||
{
|
{
|
||||||
RuleFor(x => x.Name).MaximumLength(200).When(x => x.Name is not null);
|
RuleFor(x => x.Name).MaximumLength(200).When(x => x.Name is not null);
|
||||||
|
RuleFor(x => x.Slug)
|
||||||
|
.Must(s => s == null || SlugHelper.IsValidSlug(s))
|
||||||
|
.WithMessage("Slug must be 2-80 lowercase letters, digits, or hyphens (e.g. my-cafe).")
|
||||||
|
.When(x => x.Slug is not null);
|
||||||
RuleFor(x => x.Phone).MaximumLength(20).When(x => x.Phone is not null);
|
RuleFor(x => x.Phone).MaximumLength(20).When(x => x.Phone is not null);
|
||||||
RuleFor(x => x.Address).MaximumLength(500).When(x => x.Address is not null);
|
RuleFor(x => x.Address).MaximumLength(500).When(x => x.Address is not null);
|
||||||
RuleFor(x => x.City).MaximumLength(100).When(x => x.City is not null);
|
RuleFor(x => x.City).MaximumLength(100).When(x => x.City is not null);
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace Meezi.Core.Utilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts Persian/Arabic café names to URL-safe Latin slugs.
|
||||||
|
/// Used for Koja profile URLs (koja.meezi.ir/fa/cafe/{slug}).
|
||||||
|
/// </summary>
|
||||||
|
public static partial class SlugHelper
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<char, string> PersianToLatin = new()
|
||||||
|
{
|
||||||
|
// Alef variants
|
||||||
|
{ 'آ', "a" }, { 'ا', "a" }, { 'أ', "a" }, { 'إ', "a" },
|
||||||
|
// Ba, Pa, Ta, Tha
|
||||||
|
{ 'ب', "b" }, { 'پ', "p" }, { 'ت', "t" }, { 'ث', "s" },
|
||||||
|
// Jim, Che, He, Khe
|
||||||
|
{ 'ج', "j" }, { 'چ', "ch" }, { 'ح', "h" }, { 'خ', "kh" },
|
||||||
|
// Dal, Zal, Re, Ze, Zhe
|
||||||
|
{ 'د', "d" }, { 'ذ', "z" }, { 'ر', "r" }, { 'ز', "z" }, { 'ژ', "zh" },
|
||||||
|
// Sin, Shin, Sad, Zad
|
||||||
|
{ 'س', "s" }, { 'ش', "sh" }, { 'ص', "s" }, { 'ض', "z" },
|
||||||
|
// Ta, Za, Ain, Ghain
|
||||||
|
{ 'ط', "t" }, { 'ظ', "z" }, { 'ع', "a" }, { 'غ', "gh" },
|
||||||
|
// Fa, Ghaf, Kaf (Arabic+Persian), Gaf
|
||||||
|
{ 'ف', "f" }, { 'ق', "gh" }, { 'ک', "k" }, { 'ك', "k" }, { 'گ', "g" },
|
||||||
|
// Lam, Mim, Nun, Vav, He, Ye
|
||||||
|
{ 'ل', "l" }, { 'م', "m" }, { 'ن', "n" }, { 'و', "v" },
|
||||||
|
{ 'ه', "h" }, { 'ی', "i" }, { 'ي', "i" },
|
||||||
|
// Special
|
||||||
|
{ 'ئ', "y" }, { 'ء', "" }, { 'ة', "t" }, { 'ى', "a" }, { 'ؤ', "o" },
|
||||||
|
// Persian digits
|
||||||
|
{ '۰', "0" }, { '۱', "1" }, { '۲', "2" }, { '۳', "3" }, { '۴', "4" },
|
||||||
|
{ '۵', "5" }, { '۶', "6" }, { '۷', "7" }, { '۸', "8" }, { '۹', "9" },
|
||||||
|
// Arabic-Indic digits
|
||||||
|
{ '٠', "0" }, { '١', "1" }, { '٢', "2" }, { '٣', "3" }, { '٤', "4" },
|
||||||
|
{ '٥', "5" }, { '٦', "6" }, { '٧', "7" }, { '٨', "8" }, { '٩', "9" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a café name (Persian or Latin) to a URL-safe lowercase slug.
|
||||||
|
/// Returns an empty string if no valid characters can be extracted.
|
||||||
|
/// </summary>
|
||||||
|
public static string Slugify(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(input)) return string.Empty;
|
||||||
|
|
||||||
|
var sb = new StringBuilder(input.Length * 2);
|
||||||
|
foreach (var ch in input)
|
||||||
|
{
|
||||||
|
if (PersianToLatin.TryGetValue(ch, out var latin))
|
||||||
|
{
|
||||||
|
sb.Append(latin);
|
||||||
|
}
|
||||||
|
else if (char.IsAsciiLetterOrDigit(ch))
|
||||||
|
{
|
||||||
|
sb.Append(char.ToLowerInvariant(ch));
|
||||||
|
}
|
||||||
|
else if (ch is ' ' or '-' or '_' or '\t')
|
||||||
|
{
|
||||||
|
sb.Append('-');
|
||||||
|
}
|
||||||
|
// else: skip punctuation/unsupported characters
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collapse consecutive hyphens and trim
|
||||||
|
return MultipleHyphen().Replace(sb.ToString(), "-").Trim('-');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the slug is a valid Koja URL slug:
|
||||||
|
/// 2–80 lowercase letters, digits, or internal hyphens. Must start and end with a letter/digit.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsValidSlug(string? slug)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(slug)) return false;
|
||||||
|
if (slug.Length < 2 || slug.Length > 80) return false;
|
||||||
|
return ValidSlugPattern().IsMatch(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex(@"-{2,}")]
|
||||||
|
private static partial Regex MultipleHyphen();
|
||||||
|
|
||||||
|
[GeneratedRegex(@"^[a-z0-9][a-z0-9\-]*[a-z0-9]$")]
|
||||||
|
private static partial Regex ValidSlugPattern();
|
||||||
|
}
|
||||||
@@ -50,8 +50,10 @@ public class SupportTicketService : ISupportTicketService
|
|||||||
string cafeId,
|
string cafeId,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return await QueryTickets()
|
// NOTE: The Where MUST be applied on the EF entity set BEFORE the Select projection.
|
||||||
.Where(t => t.CafeId == cafeId)
|
// Applying Where() after Select() onto a DTO record causes an EF translation error
|
||||||
|
// because EF can't translate "new SupportTicketDto(...).CafeId == x".
|
||||||
|
return await QueryTickets(cafeId)
|
||||||
.OrderByDescending(t => t.UpdatedAt)
|
.OrderByDescending(t => t.UpdatedAt)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
@@ -119,11 +121,10 @@ public class SupportTicketService : ISupportTicketService
|
|||||||
SupportTicketStatus? status,
|
SupportTicketStatus? status,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var q = QueryTickets();
|
// status filter is applied on the entity before projection — safe for EF translation.
|
||||||
if (status.HasValue)
|
return await QueryTickets(cafeId: null, status: status)
|
||||||
q = q.Where(t => t.Status == status.Value);
|
.OrderByDescending(t => t.UpdatedAt)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
return await q.OrderByDescending(t => t.UpdatedAt).ToListAsync(cancellationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SupportTicketDetailDto?> GetAdminAsync(
|
public async Task<SupportTicketDetailDto?> GetAdminAsync(
|
||||||
@@ -185,22 +186,36 @@ public class SupportTicketService : ISupportTicketService
|
|||||||
return await GetAdminAsync(ticketId, cancellationToken);
|
return await GetAdminAsync(ticketId, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IQueryable<SupportTicketDto> QueryTickets() =>
|
/// <summary>
|
||||||
_db.SupportTickets
|
/// Builds an EF-translatable query for support ticket list rows.
|
||||||
.AsNoTracking()
|
/// Filters are applied on the entity BEFORE the Select projection to avoid EF translation errors.
|
||||||
.Select(t => new SupportTicketDto(
|
/// </summary>
|
||||||
t.Id,
|
private IQueryable<SupportTicketDto> QueryTickets(
|
||||||
t.CafeId,
|
string? cafeId = null,
|
||||||
t.Cafe != null ? t.Cafe.Name : "",
|
SupportTicketStatus? status = null)
|
||||||
t.Subject,
|
{
|
||||||
t.Status,
|
var q = _db.SupportTickets.AsNoTracking().AsQueryable();
|
||||||
t.Priority,
|
|
||||||
t.CreatedByEmployeeId,
|
// Apply entity-level filters BEFORE Select so EF can translate them.
|
||||||
t.CreatedByEmployee != null ? t.CreatedByEmployee.Name : null,
|
if (cafeId is not null)
|
||||||
t.AssignedAdminId,
|
q = q.Where(t => t.CafeId == cafeId);
|
||||||
t.CreatedAt,
|
if (status.HasValue)
|
||||||
t.UpdatedAt,
|
q = q.Where(t => t.Status == status.Value);
|
||||||
t.Messages.Count));
|
|
||||||
|
return q.Select(t => new SupportTicketDto(
|
||||||
|
t.Id,
|
||||||
|
t.CafeId,
|
||||||
|
t.Cafe != null ? t.Cafe.Name : "",
|
||||||
|
t.Subject,
|
||||||
|
t.Status,
|
||||||
|
t.Priority,
|
||||||
|
t.CreatedByEmployeeId,
|
||||||
|
t.CreatedByEmployee != null ? t.CreatedByEmployee.Name : null,
|
||||||
|
t.AssignedAdminId,
|
||||||
|
t.CreatedAt,
|
||||||
|
t.UpdatedAt,
|
||||||
|
t.Messages.Count));
|
||||||
|
}
|
||||||
|
|
||||||
private static SupportTicketDto MapTicket(SupportTicket t) =>
|
private static SupportTicketDto MapTicket(SupportTicket t) =>
|
||||||
new(
|
new(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -52,7 +52,10 @@
|
|||||||
"usernamePlaceholder": "اسم المستخدم",
|
"usernamePlaceholder": "اسم المستخدم",
|
||||||
"password": "كلمة المرور",
|
"password": "كلمة المرور",
|
||||||
"passwordPlaceholder": "كلمة المرور",
|
"passwordPlaceholder": "كلمة المرور",
|
||||||
"invalidCredentials": "اسم المستخدم أو كلمة المرور غير صحيحة."
|
"invalidCredentials": "اسم المستخدم أو كلمة المرور غير صحيحة.",
|
||||||
|
"kojaSlug": "عنوان الملف الشخصي في كوجا",
|
||||||
|
"kojaSlugHint": "يجد الزوار مقهاكم على هذا العنوان",
|
||||||
|
"kojaSlugPlaceholder": "مثال: my-cafe"
|
||||||
},
|
},
|
||||||
"roles": {
|
"roles": {
|
||||||
"owner": "المالك",
|
"owner": "المالك",
|
||||||
@@ -1146,7 +1149,13 @@
|
|||||||
"uploadLogo": "رفع الشعار",
|
"uploadLogo": "رفع الشعار",
|
||||||
"uploadCover": "رفع الغلاف",
|
"uploadCover": "رفع الغلاف",
|
||||||
"saved": "تم حفظ الملف.",
|
"saved": "تم حفظ الملف.",
|
||||||
"reloginHint": "تم تحديث الخطة؛ سجّل الخروج والدخول إن لزم."
|
"reloginHint": "تم تحديث الخطة؛ سجّل الخروج والدخول إن لزم.",
|
||||||
|
"slug": "عنوان ملف كوجا",
|
||||||
|
"slugHint": "صفحة مقهاكم على كوجا — أحرف صغيرة وأرقام وشرطات فقط",
|
||||||
|
"slugPlaceholder": "my-cafe",
|
||||||
|
"slugTaken": "هذا العنوان مأخوذ. الرجاء اختيار عنوان آخر.",
|
||||||
|
"slugInvalid": "عنوان غير صالح. استخدم الأحرف الصغيرة والأرقام والشرطات فقط.",
|
||||||
|
"kojaUrl": "رابط كوجا"
|
||||||
},
|
},
|
||||||
"taraz": "تاراز (الضرائب)",
|
"taraz": "تاراز (الضرائب)",
|
||||||
"tarazHint": "إرسال فواتير الأمس إلى تاراز (وضع تجريبي).",
|
"tarazHint": "إرسال فواتير الأمس إلى تاراز (وضع تجريبي).",
|
||||||
@@ -1502,4 +1511,4 @@
|
|||||||
"premium": "پریمیوم"
|
"premium": "پریمیوم"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,10 @@
|
|||||||
"usernamePlaceholder": "Username",
|
"usernamePlaceholder": "Username",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"passwordPlaceholder": "Password",
|
"passwordPlaceholder": "Password",
|
||||||
"invalidCredentials": "Incorrect username or password."
|
"invalidCredentials": "Incorrect username or password.",
|
||||||
|
"kojaSlug": "Koja profile address",
|
||||||
|
"kojaSlugHint": "Customers will find your cafe at this address",
|
||||||
|
"kojaSlugPlaceholder": "e.g. my-cafe"
|
||||||
},
|
},
|
||||||
"roles": {
|
"roles": {
|
||||||
"owner": "Owner",
|
"owner": "Owner",
|
||||||
@@ -1228,7 +1231,13 @@
|
|||||||
"uploadLogo": "Upload logo",
|
"uploadLogo": "Upload logo",
|
||||||
"uploadCover": "Upload cover",
|
"uploadCover": "Upload cover",
|
||||||
"saved": "Profile saved.",
|
"saved": "Profile saved.",
|
||||||
"reloginHint": "Plan updated; sign out and in again if the badge looks wrong."
|
"reloginHint": "Plan updated; sign out and in again if the badge looks wrong.",
|
||||||
|
"slug": "Koja profile address",
|
||||||
|
"slugHint": "Your cafe page on Koja — lowercase letters, digits, hyphens only",
|
||||||
|
"slugPlaceholder": "my-cafe",
|
||||||
|
"slugTaken": "This address is already taken. Please choose another.",
|
||||||
|
"slugInvalid": "Invalid address. Use lowercase letters, digits, and hyphens only.",
|
||||||
|
"kojaUrl": "Koja URL"
|
||||||
},
|
},
|
||||||
"taraz": "Taraz (tax system)",
|
"taraz": "Taraz (tax system)",
|
||||||
"tarazHint": "Submit yesterday's invoices to Taraz (demo mode logs only).",
|
"tarazHint": "Submit yesterday's invoices to Taraz (demo mode logs only).",
|
||||||
@@ -1655,4 +1664,4 @@
|
|||||||
"premium": "Premium"
|
"premium": "Premium"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,10 @@
|
|||||||
"usernamePlaceholder": "نام کاربری",
|
"usernamePlaceholder": "نام کاربری",
|
||||||
"password": "رمز عبور",
|
"password": "رمز عبور",
|
||||||
"passwordPlaceholder": "رمز عبور",
|
"passwordPlaceholder": "رمز عبور",
|
||||||
"invalidCredentials": "نام کاربری یا رمز عبور اشتباه است."
|
"invalidCredentials": "نام کاربری یا رمز عبور اشتباه است.",
|
||||||
|
"kojaSlug": "آدرس پروفایل در کوجا",
|
||||||
|
"kojaSlugHint": "بازدیدکنندگان از این آدرس کافه شما را پیدا میکنند",
|
||||||
|
"kojaSlugPlaceholder": "مثال: cafe-roya"
|
||||||
},
|
},
|
||||||
"roles": {
|
"roles": {
|
||||||
"owner": "مالک",
|
"owner": "مالک",
|
||||||
@@ -1233,7 +1236,13 @@
|
|||||||
"uploadLogo": "بارگذاری لوگو",
|
"uploadLogo": "بارگذاری لوگو",
|
||||||
"uploadCover": "بارگذاری کاور",
|
"uploadCover": "بارگذاری کاور",
|
||||||
"saved": "پروفایل ذخیره شد.",
|
"saved": "پروفایل ذخیره شد.",
|
||||||
"reloginHint": "پلن بهروز شد؛ در صورت نیاز یکبار خارج و وارد شوید."
|
"reloginHint": "پلن بهروز شد؛ در صورت نیاز یکبار خارج و وارد شوید.",
|
||||||
|
"slug": "آدرس پروفایل کوجا",
|
||||||
|
"slugHint": "آدرس صفحه کافه شما در کوجا — فقط حروف انگلیسی، اعداد و خط تیره",
|
||||||
|
"slugPlaceholder": "cafe-roya",
|
||||||
|
"slugTaken": "این آدرس قبلاً گرفته شده. آدرس دیگری انتخاب کنید.",
|
||||||
|
"slugInvalid": "آدرس نامعتبر است. فقط حروف انگلیسی کوچک، اعداد و خط تیره مجاز است.",
|
||||||
|
"kojaUrl": "آدرس کوجا"
|
||||||
},
|
},
|
||||||
"plans": {
|
"plans": {
|
||||||
"compareLabel": "مقایسه پلنها",
|
"compareLabel": "مقایسه پلنها",
|
||||||
@@ -1656,4 +1665,4 @@
|
|||||||
"premium": "پریمیوم"
|
"premium": "پریمیوم"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useRouter, Link } from "@/i18n/routing";
|
import { useRouter, Link } from "@/i18n/routing";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
@@ -14,6 +14,46 @@ import { LabeledField } from "@/components/ui/labeled-field";
|
|||||||
import { OtpInput } from "@/components/ui/otp-input";
|
import { OtpInput } from "@/components/ui/otp-input";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
|
||||||
|
/** Client-side Persian-to-Latin slugifier — mirrors SlugHelper.Slugify on the backend */
|
||||||
|
const PERSIAN_MAP: Record<string, string> = {
|
||||||
|
آ: "a", ا: "a", أ: "a", إ: "a",
|
||||||
|
ب: "b", پ: "p", ت: "t", ث: "s",
|
||||||
|
ج: "j", چ: "ch", ح: "h", خ: "kh",
|
||||||
|
د: "d", ذ: "z", ر: "r", ز: "z", ژ: "zh",
|
||||||
|
س: "s", ش: "sh", ص: "s", ض: "z",
|
||||||
|
ط: "t", ظ: "z", ع: "a", غ: "gh",
|
||||||
|
ف: "f", ق: "gh", ک: "k", ك: "k", گ: "g",
|
||||||
|
ل: "l", م: "m", ن: "n", و: "v",
|
||||||
|
ه: "h", ی: "i", ي: "i",
|
||||||
|
ئ: "y", ء: "", ة: "t", ى: "a", ؤ: "o",
|
||||||
|
"۰": "0", "۱": "1", "۲": "2", "۳": "3", "۴": "4",
|
||||||
|
"۵": "5", "۶": "6", "۷": "7", "۸": "8", "۹": "9",
|
||||||
|
};
|
||||||
|
|
||||||
|
function slugify(input: string): string {
|
||||||
|
let s = "";
|
||||||
|
for (const ch of input) {
|
||||||
|
if (ch in PERSIAN_MAP) {
|
||||||
|
s += PERSIAN_MAP[ch];
|
||||||
|
} else if (/[a-zA-Z0-9]/.test(ch)) {
|
||||||
|
s += ch.toLowerCase();
|
||||||
|
} else if (/[\s\-_]/.test(ch)) {
|
||||||
|
s += "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidSlug(slug: string): boolean {
|
||||||
|
if (!slug || slug.length < 2 || slug.length > 80) return false;
|
||||||
|
return /^[a-z0-9][a-z0-9\-]*[a-z0-9]$/.test(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
const KOJA_BASE =
|
||||||
|
typeof window !== "undefined" && window.location.hostname.includes("meezi.ir")
|
||||||
|
? "koja.meezi.ir"
|
||||||
|
: "koja.meezi.ir";
|
||||||
|
|
||||||
function RegisterForm() {
|
function RegisterForm() {
|
||||||
const t = useTranslations("auth");
|
const t = useTranslations("auth");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -22,20 +62,31 @@ function RegisterForm() {
|
|||||||
|
|
||||||
const [phone, setPhone] = useState(searchParams.get("phone") ?? "");
|
const [phone, setPhone] = useState(searchParams.get("phone") ?? "");
|
||||||
const [cafeName, setCafeName] = useState("");
|
const [cafeName, setCafeName] = useState("");
|
||||||
|
const [slug, setSlug] = useState("");
|
||||||
|
const [slugEdited, setSlugEdited] = useState(false);
|
||||||
const [code, setCode] = useState("");
|
const [code, setCode] = useState("");
|
||||||
const [step, setStep] = useState<"info" | "otp">("info");
|
const [step, setStep] = useState<"info" | "otp">("info");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Auto-derive slug from café name unless the user has manually edited it
|
||||||
|
useEffect(() => {
|
||||||
|
if (!slugEdited) {
|
||||||
|
setSlug(slugify(cafeName));
|
||||||
|
}
|
||||||
|
}, [cafeName, slugEdited]);
|
||||||
|
|
||||||
|
const slugValid = isValidSlug(slug);
|
||||||
|
|
||||||
const errorMessage = (err: unknown) => {
|
const errorMessage = (err: unknown) => {
|
||||||
if (err instanceof ApiClientError) {
|
if (err instanceof ApiClientError) {
|
||||||
switch (err.code) {
|
switch (err.code) {
|
||||||
case "RATE_LIMITED": return t("rateLimited");
|
case "RATE_LIMITED": return t("rateLimited");
|
||||||
case "ALREADY_REGISTERED": return t("alreadyRegistered");
|
case "ALREADY_REGISTERED": return t("alreadyRegistered");
|
||||||
case "SMS_FAILED": return t("smsFailed");
|
case "SMS_FAILED": return t("smsFailed");
|
||||||
case "INVALID_OTP": return t("invalidOtp");
|
case "INVALID_OTP": return t("invalidOtp");
|
||||||
case "REGISTRATION_EXPIRED": return t("registrationExpired");
|
case "REGISTRATION_EXPIRED": return t("registrationExpired");
|
||||||
default: return err.message;
|
default: return err.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err instanceof Error ? err.message : String(err);
|
return err instanceof Error ? err.message : String(err);
|
||||||
@@ -45,7 +96,11 @@ function RegisterForm() {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
await apiPost("/api/auth/register", { phone, cafeName });
|
await apiPost("/api/auth/register", {
|
||||||
|
phone,
|
||||||
|
cafeName,
|
||||||
|
slug: slugValid ? slug : undefined,
|
||||||
|
});
|
||||||
setStep("otp");
|
setStep("otp");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(errorMessage(e));
|
setError(errorMessage(e));
|
||||||
@@ -94,6 +149,31 @@ function RegisterForm() {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</LabeledField>
|
</LabeledField>
|
||||||
|
|
||||||
|
{/* Koja slug / profile URL */}
|
||||||
|
<LabeledField
|
||||||
|
label={t("kojaSlug")}
|
||||||
|
htmlFor="reg-slug"
|
||||||
|
hint={t("kojaSlugHint")}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
id="reg-slug"
|
||||||
|
value={slug}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSlugEdited(true);
|
||||||
|
setSlug(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""));
|
||||||
|
}}
|
||||||
|
placeholder={t("kojaSlugPlaceholder")}
|
||||||
|
dir="ltr"
|
||||||
|
className="text-start font-mono text-sm"
|
||||||
|
/>
|
||||||
|
{slug && (
|
||||||
|
<p className={`mt-1 text-xs font-mono ${slugValid ? "text-muted-foreground" : "text-destructive"}`}>
|
||||||
|
{KOJA_BASE}/{slug}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</LabeledField>
|
||||||
|
|
||||||
<LabeledField label={t("phone")} htmlFor="reg-phone">
|
<LabeledField label={t("phone")} htmlFor="reg-phone">
|
||||||
<Input
|
<Input
|
||||||
id="reg-phone"
|
id="reg-phone"
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ function buildDefaultOpenGroups(): OpenGroupsState {
|
|||||||
const stored = readStoredOpenGroups();
|
const stored = readStoredOpenGroups();
|
||||||
const defaults: OpenGroupsState = {};
|
const defaults: OpenGroupsState = {};
|
||||||
for (const g of NAV_GROUPS) {
|
for (const g of NAV_GROUPS) {
|
||||||
defaults[g.id] = stored[g.id] ?? g.defaultOpen;
|
// Default ALL groups closed on first visit; only restore if user explicitly saved state.
|
||||||
|
defaults[g.id] = stored[g.id] ?? false;
|
||||||
}
|
}
|
||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
@@ -238,20 +239,31 @@ export function Sidebar({ side }: { side: "left" | "right" }) {
|
|||||||
[role, branchId, permissions]
|
[role, branchId, permissions]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** Accordion: opening a group collapses all others. */
|
||||||
const setGroupOpen = useCallback((groupId: NavGroupId, open: boolean) => {
|
const setGroupOpen = useCallback((groupId: NavGroupId, open: boolean) => {
|
||||||
setOpenGroups((prev) => {
|
setOpenGroups((_prev) => {
|
||||||
const next = { ...prev, [groupId]: open };
|
const next: OpenGroupsState = {};
|
||||||
|
for (const g of NAV_GROUPS) {
|
||||||
|
// If opening: only the clicked group becomes true; everything else closes.
|
||||||
|
// If closing: just close the clicked group, leave others as-is.
|
||||||
|
next[g.id] = open ? g.id === groupId : g.id === groupId ? false : (_prev[g.id] ?? false);
|
||||||
|
}
|
||||||
persistOpenGroups(next);
|
persistOpenGroups(next);
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// When navigating to a new path, open only the group that contains that path (accordion).
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const activeGroup = findNavGroupForPath(pathname);
|
const activeGroup = findNavGroupForPath(pathname);
|
||||||
if (!activeGroup) return;
|
if (!activeGroup) return;
|
||||||
setOpenGroups((prev) => {
|
setOpenGroups((prev) => {
|
||||||
if (prev[activeGroup]) return prev;
|
if (prev[activeGroup]) return prev; // already open, nothing to do
|
||||||
const next = { ...prev, [activeGroup]: true };
|
// Accordion: open active group, close all others
|
||||||
|
const next: OpenGroupsState = {};
|
||||||
|
for (const g of NAV_GROUPS) {
|
||||||
|
next[g.id] = g.id === activeGroup;
|
||||||
|
}
|
||||||
persistOpenGroups(next);
|
persistOpenGroups(next);
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
|
const [slug, setSlug] = useState("");
|
||||||
|
const [slugError, setSlugError] = useState<string | null>(null);
|
||||||
const [city, setCity] = useState("");
|
const [city, setCity] = useState("");
|
||||||
const [phone, setPhone] = useState("");
|
const [phone, setPhone] = useState("");
|
||||||
const [address, setAddress] = useState("");
|
const [address, setAddress] = useState("");
|
||||||
@@ -37,6 +39,7 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!cafeSettings) return;
|
if (!cafeSettings) return;
|
||||||
setName(cafeSettings.name ?? "");
|
setName(cafeSettings.name ?? "");
|
||||||
|
setSlug(cafeSettings.slug ?? "");
|
||||||
setCity(cafeSettings.city ?? "");
|
setCity(cafeSettings.city ?? "");
|
||||||
setPhone(cafeSettings.phone ?? "");
|
setPhone(cafeSettings.phone ?? "");
|
||||||
setAddress(cafeSettings.address ?? "");
|
setAddress(cafeSettings.address ?? "");
|
||||||
@@ -47,9 +50,16 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
|||||||
}, [cafeSettings]);
|
}, [cafeSettings]);
|
||||||
|
|
||||||
const saveProfile = useMutation({
|
const saveProfile = useMutation({
|
||||||
mutationFn: () =>
|
mutationFn: () => {
|
||||||
apiPatch<CafeSettings>(`/api/cafes/${cafeId}/settings`, {
|
setSlugError(null);
|
||||||
|
const slugTrimmed = slug.trim();
|
||||||
|
const isValidSlug = !slugTrimmed || /^[a-z0-9][a-z0-9\-]*[a-z0-9]$/.test(slugTrimmed);
|
||||||
|
if (slugTrimmed && !isValidSlug) {
|
||||||
|
throw new Error("INVALID_SLUG");
|
||||||
|
}
|
||||||
|
return apiPatch<CafeSettings>(`/api/cafes/${cafeId}/settings`, {
|
||||||
name,
|
name,
|
||||||
|
slug: slugTrimmed || undefined,
|
||||||
city,
|
city,
|
||||||
phone,
|
phone,
|
||||||
address,
|
address,
|
||||||
@@ -57,11 +67,20 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
|||||||
logoUrl: logoUrl || null,
|
logoUrl: logoUrl || null,
|
||||||
coverImageUrl: coverImageUrl || null,
|
coverImageUrl: coverImageUrl || null,
|
||||||
snappfoodVendorId,
|
snappfoodVendorId,
|
||||||
}),
|
});
|
||||||
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
queryClient.setQueryData(cafeSettingsQueryKey(cafeId), data);
|
queryClient.setQueryData(cafeSettingsQueryKey(cafeId), data);
|
||||||
notify.success(t("profile.saved"));
|
notify.success(t("profile.saved"));
|
||||||
},
|
},
|
||||||
|
onError: (err: unknown) => {
|
||||||
|
const msg = err instanceof Error ? err.message : String(err);
|
||||||
|
if (msg === "INVALID_SLUG") {
|
||||||
|
setSlugError(t("profile.slugInvalid"));
|
||||||
|
} else if (msg.includes("SLUG_TAKEN")) {
|
||||||
|
setSlugError(t("profile.slugTaken"));
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const uploadLogo = useMutation({
|
const uploadLogo = useMutation({
|
||||||
@@ -129,6 +148,33 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Koja slug */}
|
||||||
|
<LabeledField
|
||||||
|
label={t("profile.slug")}
|
||||||
|
htmlFor="cafe-slug"
|
||||||
|
hint={t("profile.slugHint")}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
id="cafe-slug"
|
||||||
|
value={slug}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSlugError(null);
|
||||||
|
setSlug(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ""));
|
||||||
|
}}
|
||||||
|
placeholder={t("profile.slugPlaceholder")}
|
||||||
|
dir="ltr"
|
||||||
|
className="font-mono text-sm"
|
||||||
|
/>
|
||||||
|
{slug && (
|
||||||
|
<p className={`text-xs font-mono ${slugError ? "text-destructive" : "text-muted-foreground"}`}>
|
||||||
|
koja.meezi.ir/{slug}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{slugError && (
|
||||||
|
<p className="text-xs text-destructive">{slugError}</p>
|
||||||
|
)}
|
||||||
|
</LabeledField>
|
||||||
|
|
||||||
<div className="grid gap-4 sm:grid-cols-2">
|
<div className="grid gap-4 sm:grid-cols-2">
|
||||||
<LabeledField label={t("profile.name")} htmlFor="cafe-name">
|
<LabeledField label={t("profile.name")} htmlFor="cafe-name">
|
||||||
<Input id="cafe-name" value={name} onChange={(e) => setName(e.target.value)} />
|
<Input id="cafe-name" value={name} onChange={(e) => setName(e.target.value)} />
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ export const NAV_GROUPS: NavGroupDef[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const NAV_GROUPS_STORAGE_KEY = "meezi:nav-groups:v3";
|
export const NAV_GROUPS_STORAGE_KEY = "meezi:nav-groups:v4";
|
||||||
|
|
||||||
/** Branch-scoped staff only see daily operations. */
|
/** Branch-scoped staff only see daily operations. */
|
||||||
export const BRANCH_ONLY_NAV_GROUP: NavGroupId = "operations";
|
export const BRANCH_ONLY_NAV_GROUP: NavGroupId = "operations";
|
||||||
|
|||||||
@@ -50,6 +50,16 @@ const nextConfig: NextConfig = {
|
|||||||
{ protocol: "http", hostname: "**" },
|
{ protocol: "http", hostname: "**" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
async redirects() {
|
||||||
|
return [
|
||||||
|
// Short URL: koja.meezi.ir/my-cafe → koja.meezi.ir/fa/cafe/my-cafe
|
||||||
|
{
|
||||||
|
source: "/:slug([a-z0-9][a-z0-9-]*[a-z0-9])",
|
||||||
|
destination: "/fa/cafe/:slug",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withPWA(withNextIntl(nextConfig));
|
export default withPWA(withNextIntl(nextConfig));
|
||||||
|
|||||||
Reference in New Issue
Block a user