with open("resources/js/components/AdminDashboard.tsx", "r", encoding="utf-8") as f:
    lines = f.readlines()

s = -1
for i, l in enumerate(lines):
    if "if (itemToSave.price !== undefined && itemToSave.name !== undefined) {" in l:
        s = i
        break

e = -1
if s != -1:
    for i in range(s+1, len(lines)):
        if "} else if (itemToSave.rating !== undefined) {" in lines[i]:
            e = i
            break

if s != -1 and e != -1:
    lines[e] = "      if (itemToSave.rating !== undefined) {\n"
    for i in range(s, e):
        lines[i] = ""

with open("resources/js/components/AdminDashboard.tsx", "w", encoding="utf-8") as f:
    f.writelines(lines)

print("Removed product save logic")
