My weekly template keeps breaking

What I’m trying to do

I’m building a habit tracker and my weekly template keeps braking I’ve tried debugging it with help for more than 10h

this is the complete template:

<%*
await new Promise(resolve => setTimeout(resolve, 1000)); // 1 сек затримка

const title = tp.file.title;
if (!title) {
throw new Error(“Still no title after wait!”);
}
let myDate = moment(title, “GGGG-[W]WW”);

if (!myDate.isValid()) {
throw new Error("Invalid date format in file name: " + title);
}

let start = myDate.clone().startOf(“isoWeek”).subtract(1, “day”).format(“MMM DD”);
let end = myDate.clone().endOf(“isoWeek”).subtract(1, “day”).format(“MMM DD”);

let prev = myDate.clone().subtract(1, “week”).format(“GGGG-[W]WW”);
let next = myDate.clone().add(1, “week”).format(“GGGG-[W]WW”);

tR += start + " - " + end + “\n\n[[Tracker/Weekly/” + prev + “|PrevWeek]] || [[Tracker/Weekly/” + next + “|NextWeek]]”;
%>

energy tracker:

\\tracker
searchType: dvField
searchTarget: Physical, Mental, Emotional
startDate: <% moment(tp.file.title,‘YYYY-[W]WW’).day(1).format(“DD-MM-YYYY”) %>
endDate: <% moment(tp.file.title,‘YYYY-[W]WW’).day(7).format(“DD-MM-YYYY”) %>

datasetName: Physical, Mental, Emotional

line:
title: Energy
yMax: 10
yAxisLabel: Rating
lineColor: red, green, blue
legendOrientation: vertical
fillGap: true
\
weight tracker:

\\tracker
searchType: frontmatter
searchTarget: Weight⚖️
startDate: <% moment(tp.file.title,‘YYYY-[W]W’).add(0,‘weeks’).day(1).format(“DD-MM-YYYY”) %>
endDate: <% moment(tp.file.title,‘YYYY-[W]W’).day(7).format(“DD-MM-YYYY”) %>

datasetName: Weight⚖️

line:
title: Energy
yMax: 130
yAxisLabel: Rating
lineColor: green
legendOrientation: vertical
fillGap: true
\
things im tryng to visualize:

///dataview
table without id
file.link AS “Day”,
weight AS “:chart_with_downwards_trend:”,
choice(:alarm_clock:6am,“:white_check_mark:”,“:x:”) AS “:alarm_clock:”,
choice(:toothbrush:Teeth,“:white_check_mark:”,“:x:”) AS “:toothbrush:”,
choice(:person_getting_massage:Face,“:white_check_mark:”,“:x:”) AS “:person_getting_massage:”,
choice(:tooth:Brush,“:white_check_mark:”,“:x:”) AS “:tooth:”,
choice(:keyboard:Practice,“:white_check_mark:”,“:x:”) AS “:keyboard:”,
choice(:computer:Coding,“:white_check_mark:”,“:x:”) AS “:computer:
from “Tracker/Daily”
where week = “<%let myDate = moment(tp.file.title)%>”
sort file.name ASC
\\

the fist 3 keep braking and start working together somehow for the last one i think my “where week” is wrong

disclaimer: i don’t know much of this programming languages i got help trying to debug it in the obsidian server since the way i did it fist stopped working somehow (it started working and stopped 4 times yesterday) I’m at a loss of what to do i started using obsidian just a few days ago so I’m not sure if there is some problems in the software settings and things are overriding each other or something completely different.