)
}
function BodyPersonalSpace({
allTactics,
teams,
user,
}: {
allTactics: Tactic[]
teams : Team[]
user : User
}) {
let data
if (allTactics.length == 0) {
data =
Aucune tactique créée !
} else {
data =
}
return (
{data}
)
}
function TeamList({ teams }: { teams: Team[] }) {
return (
)
}
function truncateString(name: string, limit: number): string {
if (name.length > limit) {
name = name.substring(0, limit) + "..."
}
return name
}
function onDropTactic(ref : DOMRect, tactic : Tactic, teams : Team[]) {
let shared = false;
for (const team of teams) {
if (contains(ref, document.getElementById(`button-team-${team.id}`)!.getBoundingClientRect())) {
if (!shared) {
shareTacticToTeam(tactic, team);
shared = true;
}
}
}
}
async function onShareTactic(email: string, tactic: Tactic) {
const canShareResponse = await fetchAPI(`tactic/${tactic.id}/can-share`, tactic);
if (canShareResponse.ok) {
const shareToAccountResponse = await fetchAPI(`tactic/${tactic.id}/share-to-account`, email);
if (!shareToAccountResponse.ok) {
alert("Une erreur s'est produite lors du partage de la tactique avec ce compte");
}
} else {
alert("Vous ne pouvez pas partager cette tactique");
}
}
async function shareTacticToTeam(tactic : Tactic, team : Team) {
const canShare = await fetchAPI(`tactic/${tactic.id}/can-share-to-team`, team).then((r) => r.ok)
if(canShare && confirm("Etes-vous sûr de vouloir partager la tactique " + tactic.name + " avec l'équipe " + team.name)) {
fetchAPI(`tactic/${tactic.id}/share-to-team`, team)
}
if(!canShare) {
alert("Vous ne pouvez pas partager cette tactique à cette équipe")
}
}