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:
@@ -45,7 +45,8 @@ function buildDefaultOpenGroups(): OpenGroupsState {
|
||||
const stored = readStoredOpenGroups();
|
||||
const defaults: OpenGroupsState = {};
|
||||
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;
|
||||
}
|
||||
@@ -238,20 +239,31 @@ export function Sidebar({ side }: { side: "left" | "right" }) {
|
||||
[role, branchId, permissions]
|
||||
);
|
||||
|
||||
/** Accordion: opening a group collapses all others. */
|
||||
const setGroupOpen = useCallback((groupId: NavGroupId, open: boolean) => {
|
||||
setOpenGroups((prev) => {
|
||||
const next = { ...prev, [groupId]: open };
|
||||
setOpenGroups((_prev) => {
|
||||
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);
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
// When navigating to a new path, open only the group that contains that path (accordion).
|
||||
useEffect(() => {
|
||||
const activeGroup = findNavGroupForPath(pathname);
|
||||
if (!activeGroup) return;
|
||||
setOpenGroups((prev) => {
|
||||
if (prev[activeGroup]) return prev;
|
||||
const next = { ...prev, [activeGroup]: true };
|
||||
if (prev[activeGroup]) return prev; // already open, nothing to do
|
||||
// Accordion: open active group, close all others
|
||||
const next: OpenGroupsState = {};
|
||||
for (const g of NAV_GROUPS) {
|
||||
next[g.id] = g.id === activeGroup;
|
||||
}
|
||||
persistOpenGroups(next);
|
||||
return next;
|
||||
});
|
||||
|
||||
@@ -24,6 +24,8 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [name, setName] = useState("");
|
||||
const [slug, setSlug] = useState("");
|
||||
const [slugError, setSlugError] = useState<string | null>(null);
|
||||
const [city, setCity] = useState("");
|
||||
const [phone, setPhone] = useState("");
|
||||
const [address, setAddress] = useState("");
|
||||
@@ -37,6 +39,7 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
||||
useEffect(() => {
|
||||
if (!cafeSettings) return;
|
||||
setName(cafeSettings.name ?? "");
|
||||
setSlug(cafeSettings.slug ?? "");
|
||||
setCity(cafeSettings.city ?? "");
|
||||
setPhone(cafeSettings.phone ?? "");
|
||||
setAddress(cafeSettings.address ?? "");
|
||||
@@ -47,9 +50,16 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
||||
}, [cafeSettings]);
|
||||
|
||||
const saveProfile = useMutation({
|
||||
mutationFn: () =>
|
||||
apiPatch<CafeSettings>(`/api/cafes/${cafeId}/settings`, {
|
||||
mutationFn: () => {
|
||||
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,
|
||||
slug: slugTrimmed || undefined,
|
||||
city,
|
||||
phone,
|
||||
address,
|
||||
@@ -57,11 +67,20 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
||||
logoUrl: logoUrl || null,
|
||||
coverImageUrl: coverImageUrl || null,
|
||||
snappfoodVendorId,
|
||||
}),
|
||||
});
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(cafeSettingsQueryKey(cafeId), data);
|
||||
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({
|
||||
@@ -129,6 +148,33 @@ export function SettingsShopPanel({ cafeId }: SettingsShopPanelProps) {
|
||||
</label>
|
||||
</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">
|
||||
<LabeledField label={t("profile.name")} htmlFor="cafe-name">
|
||||
<Input id="cafe-name" value={name} onChange={(e) => setName(e.target.value)} />
|
||||
|
||||
Reference in New Issue
Block a user