feat: moznost zmazat aj predvolene cenovky (uloha 10)
Stare predvolene sablony (badge-preset-*) ostali ulozene v localStorage a nedali sa zmazat. Tlacidlo kosa je teraz pri kazdej sablone; pri predvolenych sa preskoci mazanie v databaze, kde nie su. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48d071d48e
commit
2c3f09f18f
1 file changed
+4
-2
@@ -403,9 +403,12 @@ export const BadgeEditorModal: React.FC<BadgeEditorModalProps> = ({
|
|||||||
|
|
||||||
const deleteBadgeTemplate = async (badgeId: string) => {
|
const deleteBadgeTemplate = async (badgeId: string) => {
|
||||||
if (confirm('Naozaj chcete zmazať túto šablónu cenovky?')) {
|
if (confirm('Naozaj chcete zmazať túto šablónu cenovky?')) {
|
||||||
|
// Predvolené šablóny existujú len v prehliadači (localStorage), v databáze nie sú
|
||||||
|
if (!badgeId.startsWith('badge-preset-')) {
|
||||||
try {
|
try {
|
||||||
await supabase.from('badges').delete().eq('id', badgeId);
|
await supabase.from('badges').delete().eq('id', badgeId);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
}
|
||||||
const remaining = badges.filter((b) => b.id !== badgeId);
|
const remaining = badges.filter((b) => b.id !== badgeId);
|
||||||
setBadges(remaining);
|
setBadges(remaining);
|
||||||
setActiveBadge(remaining[0] || null);
|
setActiveBadge(remaining[0] || null);
|
||||||
@@ -643,7 +646,7 @@ export const BadgeEditorModal: React.FC<BadgeEditorModalProps> = ({
|
|||||||
>
|
>
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<p className="text-xs font-bold text-gray-800 truncate">{b.name}</p>
|
<p className="text-xs font-bold text-gray-800 truncate">{b.name}</p>
|
||||||
{!b.id.startsWith('badge-preset-') && (
|
{/* Zmazať sa dá každá šablóna, aj staršie predvolené (badge-preset-*) uložené v prehliadači */}
|
||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -654,7 +657,6 @@ export const BadgeEditorModal: React.FC<BadgeEditorModalProps> = ({
|
|||||||
>
|
>
|
||||||
<Trash2 className="w-3.5 h-3.5" />
|
<Trash2 className="w-3.5 h-3.5" />
|
||||||
</button>
|
</button>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="w-full h-12 flex items-center justify-center transform scale-75 origin-center overflow-hidden pointer-events-none"
|
className="w-full h-12 flex items-center justify-center transform scale-75 origin-center overflow-hidden pointer-events-none"
|
||||||
|
|||||||
Reference in new issue
Block a user