from django.template.loader import render_to_string
from django.urls import reverse


class UserBarEditProductItem:
    def __init__(self, pk):
        self.pk = pk
        self.url = reverse("dashboard:catalogue-product", kwargs={"pk": self.pk})
        self.text = "Edit this product"
        self.icon = "edit"

    def render(self, request):
        return render_to_string(
            "userbar/userbar_item.html",
            {"url": self.url, "text": self.text, "icon": self.icon},
        )


class UserBarEditCategoryItem:
    def __init__(self, pk):
        self.pk = pk
        self.url = reverse(
            "dashboard:catalogue-category-update", kwargs={"pk": self.pk}
        )
        self.text = "Edit this category"
        self.icon = "edit"

    def render(self, request):
        return render_to_string(
            "userbar/userbar_item.html",
            {"url": self.url, "text": self.text, "icon": self.icon},
        )
