|
|
@@ -27,6 +27,7 @@ import {
|
|
|
import { supabase } from "@/lib/supabase";
|
|
|
import { useShop } from "@/components/context/ShopContext";
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
+import { Loader2 } from "lucide-react";
|
|
|
|
|
|
interface CustomContentListProps {
|
|
|
contentType?: "text_entry" | "pdf_upload";
|
|
|
@@ -57,7 +58,7 @@ export function CustomContentList({
|
|
|
const [viewContentId, setViewContentId] = useState<string | null>(null);
|
|
|
const [retryingId, setRetryingId] = useState<string | null>(null);
|
|
|
const { toast } = useToast();
|
|
|
- const { selectedShop } = useShop();
|
|
|
+ const { selectedShop, isLoading: isShopLoading } = useShop();
|
|
|
|
|
|
// Fetch content list
|
|
|
const { data, isLoading, refetch } = useQuery({
|
|
|
@@ -202,8 +203,23 @@ export function CustomContentList({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- if (isLoading) {
|
|
|
- return <div className="text-center py-8 text-slate-400">{t('customContent.list.loading')}</div>;
|
|
|
+ // Show loading state while shop is being determined from URL or while fetching content
|
|
|
+ if (isShopLoading || isLoading) {
|
|
|
+ return (
|
|
|
+ <div className="text-center py-8 text-slate-400 flex items-center justify-center gap-2">
|
|
|
+ <Loader2 className="h-4 w-4 animate-spin" />
|
|
|
+ {t('customContent.list.loading')}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // Only show "no content" if shop is loaded and data is empty
|
|
|
+ if (!selectedShop) {
|
|
|
+ return (
|
|
|
+ <div className="text-center py-8 text-slate-400">
|
|
|
+ {t('customContent.list.noShopSelected')}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
if (!data || data.length === 0) {
|