{{define "head"}}
<title>Editing {{.Artist.Name}} - ari melody 💫</title>
<link rel="shortcut icon" href="{{.Artist.GetAvatar}}" type="image/x-icon">
<link rel="stylesheet" href="/admin/static/edit-artist.css">
{{end}}

{{define "content"}}
<main>
    <h1>Editing Artist</h1>
        
    <div id="artist" data-id="{{.Artist.ID}}">
        <div class="artist-avatar">
            <img src="{{.Artist.Avatar}}" alt="" width="256" loading="lazy" id="avatar">
            <input type="file" id="avatar-file" name="Artwork" accept=".png,.jpg,.jpeg" hidden>
            <button id="remove-avatar">Remove</button>
        </div>
        <div class="artist-info">
            <p class="attribute-header">Name</p>
            <h2 class="artist-name">
                <input type="text" id="name" name="artist-name" value="{{.Artist.Name}}">
            </h2>

            <p class="attribute-header">Website</p>
            <input type="text" id="website" name="website" value="{{.Artist.Website}}">

            <div class="artist-actions">
                <button type="submit" class="save" id="save" disabled>Save</button>
            </div>
        </div>
    </div>

    <div class="card-title">
        <h2>Featured in</h2>
    </div>
    <div class="card releases">
        {{if .Credits}}
        {{range .Credits}}
        <div class="credit">
            <img src="{{.Release.Artwork}}" alt="" width="64" loading="lazy" class="release-artwork">
            <div class="credit-info">
                <h3 class="credit-name"><a href="/admin/release/{{.Release.ID}}">{{.Release.Title}}</a></h3>
                <p class="credit-artists">{{.Release.PrintArtists true true}}</p>
                <p class="artist-role">
                Role: {{.Role}}
                {{if .Primary}}
                <small>(Primary)</small>
                {{end}}
                </p>
            </div>
        </div>
        {{end}}
        {{else}}
        <p>This artist has no credits.</p>
        {{end}}
    </div>

    <div class="card-title">
        <h2>Danger Zone</h2>
    </div>
    <div class="card danger">
        <p>
        Clicking the button below will delete this artist.
        This action is <strong>irreversible</strong>.
        You will be prompted to confirm this decision.
        </p>
        <button class="delete" id="delete">Delete Artist</button>
    </div>

</main>

<script type="module" src="/admin/static/edit-artist.js" defer></script>
{{end}}
