feat: delete actions for warehouse/reservations/coupons/customers + Koja listing toggle
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m10s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 52s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 45s
CI/CD / CI · Koja (tsc) (push) Successful in 55s
CI/CD / Deploy · all services (push) Successful in 3m29s
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m10s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 52s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m5s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 45s
CI/CD / CI · Koja (tsc) (push) Successful in 55s
CI/CD / Deploy · all services (push) Successful in 3m29s
Delete (every manageable entity that only had "add" now has delete):
- Ingredients (warehouse): new DELETE /inventory/ingredients/{id} (soft-delete via
the global DeletedAt filter — no FK trouble with recipes/movements) + NoOp stub +
trash button in the materials cards.
- Reservations: new DELETE /reservations/{id} (soft-delete) + per-card delete button.
- Coupons & Customers: backend DELETE already existed; wired delete buttons in the UI.
- Shared ConfirmDialog component used by all delete flows (RTL-aware).
- Audit result: tables/branches/taxes/kitchen-stations/expenses/menu/terminals already
had delete; HR has no "add" so no delete needed; shifts intentionally excluded
(financial open/close records, not add-style entities).
Koja visibility:
- New Cafe.ShowOnKoja flag, default TRUE (DB default true so existing cafés stay
listed). Discover query now filters IsVerified && !Deleted && ShowOnKoja.
- public-profile GET/PUT expose showOnKoja; dashboard public-profile panel has an
on-by-default toggle that persists immediately. Platform IsVerified gate unchanged.
- EF migration AddCafeShowOnKoja (defaultValue: true).
Also: added the missing errors.generic i18n key (fa/en/ar) so useApiError's fallback
resolves instead of rendering the literal "errors.generic". 81 API tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -57,7 +57,8 @@ public class CafePublicProfileController : CafeApiControllerBase
|
||||
gallery,
|
||||
cafe.InstagramHandle,
|
||||
cafe.WebsiteUrl,
|
||||
ToHoursDto(hours))));
|
||||
ToHoursDto(hours),
|
||||
cafe.ShowOnKoja)));
|
||||
}
|
||||
|
||||
// ── PUT (description / social / hours) ───────────────────────────────────
|
||||
@@ -91,6 +92,10 @@ public class CafePublicProfileController : CafeApiControllerBase
|
||||
if (request.WorkingHours is not null)
|
||||
cafe.WorkingHoursJson = JsonSerializer.Serialize(ToHoursSchedule(request.WorkingHours), _jsonOpts);
|
||||
|
||||
// Koja (public discovery) listing preference
|
||||
if (request.ShowOnKoja.HasValue)
|
||||
cafe.ShowOnKoja = request.ShowOnKoja.Value;
|
||||
|
||||
await _db.SaveChangesAsync(ct);
|
||||
|
||||
var gallery = Deserialize<List<string>>(cafe.GalleryJson) ?? [];
|
||||
@@ -101,7 +106,8 @@ public class CafePublicProfileController : CafeApiControllerBase
|
||||
gallery,
|
||||
cafe.InstagramHandle,
|
||||
cafe.WebsiteUrl,
|
||||
ToHoursDto(hours))));
|
||||
ToHoursDto(hours),
|
||||
cafe.ShowOnKoja)));
|
||||
}
|
||||
|
||||
// ── POST gallery/upload ───────────────────────────────────────────────────
|
||||
@@ -207,13 +213,15 @@ public record UpdateCafePublicProfileRequest(
|
||||
string? Description,
|
||||
string? InstagramHandle,
|
||||
string? WebsiteUrl,
|
||||
WorkingHoursPublicDto? WorkingHours);
|
||||
WorkingHoursPublicDto? WorkingHours,
|
||||
bool? ShowOnKoja = null);
|
||||
|
||||
public record CafeProfileEditDto(
|
||||
string? Description,
|
||||
IReadOnlyList<string> GalleryUrls,
|
||||
string? InstagramHandle,
|
||||
string? WebsiteUrl,
|
||||
WorkingHoursPublicDto? WorkingHours);
|
||||
WorkingHoursPublicDto? WorkingHours,
|
||||
bool ShowOnKoja);
|
||||
|
||||
public record GalleryDto(IReadOnlyList<string> GalleryUrls);
|
||||
|
||||
@@ -61,6 +61,19 @@ public class InventoryController : CafeApiControllerBase
|
||||
return Ok(new ApiResponse<object>(true, updated));
|
||||
}
|
||||
|
||||
[HttpDelete("ingredients/{ingredientId}")]
|
||||
public async Task<IActionResult> Delete(
|
||||
string cafeId,
|
||||
string ingredientId,
|
||||
ITenantContext tenant,
|
||||
CancellationToken ct)
|
||||
{
|
||||
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
||||
var deleted = await _inventory.DeleteAsync(cafeId, ingredientId, ct);
|
||||
if (!deleted) return NotFoundError();
|
||||
return Ok(new ApiResponse<object>(true, new { id = ingredientId }));
|
||||
}
|
||||
|
||||
[HttpPost("ingredients/{ingredientId}/adjust")]
|
||||
public async Task<IActionResult> Adjust(
|
||||
string cafeId,
|
||||
|
||||
@@ -66,6 +66,19 @@ public class ReservationsController : CafeApiControllerBase
|
||||
if (data is null) return NotFoundError();
|
||||
return Ok(new ApiResponse<ReservationDto>(true, data));
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> Delete(
|
||||
string cafeId,
|
||||
string id,
|
||||
ITenantContext tenant,
|
||||
CancellationToken ct)
|
||||
{
|
||||
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
||||
var deleted = await _reservations.DeleteAsync(cafeId, id, ct);
|
||||
if (!deleted) return NotFoundError();
|
||||
return Ok(new ApiResponse<object>(true, new { id }));
|
||||
}
|
||||
}
|
||||
|
||||
public record UpdateReservationStatusRequest(ReservationStatus Status);
|
||||
|
||||
@@ -89,6 +89,7 @@ public interface IInventoryService
|
||||
Task<IReadOnlyList<IngredientDto>> LowStockAsync(string cafeId, CancellationToken ct = default);
|
||||
Task<IngredientDto?> CreateAsync(string cafeId, CreateIngredientRequest request, CancellationToken ct = default);
|
||||
Task<IngredientDto?> UpdateAsync(string cafeId, string ingredientId, UpdateIngredientRequest request, CancellationToken ct = default);
|
||||
Task<bool> DeleteAsync(string cafeId, string ingredientId, CancellationToken ct = default);
|
||||
Task<IngredientDto?> AdjustAsync(
|
||||
string cafeId,
|
||||
string ingredientId,
|
||||
@@ -205,6 +206,18 @@ public class InventoryService : IInventoryService
|
||||
return ToDto(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(string cafeId, string ingredientId, CancellationToken ct = default)
|
||||
{
|
||||
var entity = await _db.Ingredients.FirstOrDefaultAsync(i => i.Id == ingredientId && i.CafeId == cafeId, ct);
|
||||
if (entity is null) return false;
|
||||
|
||||
// Soft delete: Ingredient has a global DeletedAt query filter, so it (and its
|
||||
// recipe lines / stock movements) drop out of every query without FK trouble.
|
||||
entity.DeletedAt = DateTime.UtcNow;
|
||||
await _db.SaveChangesAsync(ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<IngredientDto?> AdjustAsync(
|
||||
string cafeId,
|
||||
string ingredientId,
|
||||
|
||||
@@ -24,6 +24,11 @@ public interface IReservationService
|
||||
string reservationId,
|
||||
ReservationStatus status,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<bool> DeleteAsync(
|
||||
string cafeId,
|
||||
string reservationId,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public class ReservationService : IReservationService
|
||||
@@ -118,6 +123,25 @@ public class ReservationService : IReservationService
|
||||
return Map(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteAsync(
|
||||
string cafeId,
|
||||
string reservationId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var entity = await _db.TableReservations
|
||||
.FirstOrDefaultAsync(r => r.Id == reservationId && r.CafeId == cafeId, cancellationToken);
|
||||
if (entity is null) return false;
|
||||
|
||||
// Soft delete: TableReservation has a global DeletedAt query filter.
|
||||
entity.DeletedAt = DateTime.UtcNow;
|
||||
await _db.SaveChangesAsync(cancellationToken);
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.TableId))
|
||||
await _kdsNotifier.NotifyTableStatusChangedAsync(cafeId, cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static ReservationDto Map(TableReservation r) => new(
|
||||
r.Id,
|
||||
r.CafeId,
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ReviewService : IReviewService
|
||||
DiscoverFilterParams filters,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var query = _db.Cafes.Where(c => c.IsVerified && c.DeletedAt == null);
|
||||
var query = _db.Cafes.Where(c => c.IsVerified && c.DeletedAt == null && c.ShowOnKoja);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filters.City))
|
||||
query = query.Where(c => c.City != null && c.City.Contains(filters.City));
|
||||
|
||||
Reference in New Issue
Block a user