﻿file = r'resources\views\test-sessions\fill.blade.php'
with open(file, 'r', encoding='utf-8') as f:
    c = f.read()

# Hapus duplikat @if
old = "            @if(auth()->user()->unit_type === 'marketing')\n            @if(auth()->user()->unit_type === 'marketing')"
new = "            @if(auth()->user()->unit_type === 'marketing')"

# Hapus duplikat @endif
old2 = "            @endif\n            @endif\n            @if(!("
new2 = "            @endif\n            @if(!("

if old in c:
    c = c.replace(old, new)
    print("@if duplikat: OK")
else:
    print("@if: tidak ada duplikat")

if old2 in c:
    c = c.replace(old2, new2)
    print("@endif duplikat: OK")
else:
    print("@endif: tidak ada duplikat")

with open(file, 'w', encoding='utf-8') as f:
    f.write(c)
