add item image
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="#" method="POST">
|
||||
<form class="space-y-6" action="#" method="POST" enctype="multipart/form-data">
|
||||
<div>
|
||||
<label for="name" class="block text-sm/6 font-medium text-gray-900">Name</label>
|
||||
<div class="mt-2">
|
||||
@@ -73,9 +73,9 @@
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<label for="image-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span class="">Upload a file</span>
|
||||
<input id="file-upload" name="file-upload" type="file" class="sr-only">
|
||||
<input id="image-upload" name="image" type="file" accept="image/*" class="sr-only">
|
||||
</label>
|
||||
<p class="pl-1 text-gray-900">or drag and drop</p>
|
||||
</div>
|
||||
|
||||
38
views/deleteitem.html
Normal file
38
views/deleteitem.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div class="bg-gray-200 rounded m-4 p-4">
|
||||
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
|
||||
<i class="text-xs">{{ .data.shopItem.Description }}</i>
|
||||
<p class="">Price: {{ .data.shopItem.Price }}</p>
|
||||
{{ if .loggedIn }}
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
Do you really want to delete this item??
|
||||
</p>
|
||||
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
|
||||
<div>
|
||||
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .data.success }}
|
||||
</p>
|
||||
|
||||
<form class="space-y-6" action="#" method="POST">
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Delete</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<a href="/shopitems/{{ .data.shopItem.ID }}" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Cancel</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{ template "footer.html" . }}
|
||||
105
views/edititem.html
Normal file
105
views/edititem.html
Normal file
@@ -0,0 +1,105 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Edit Item</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="#" method="POST">
|
||||
<div>
|
||||
<label for="name" class="block text-sm/6 font-medium text-gray-900">Name</label>
|
||||
<div class="mt-2">
|
||||
<input type="text" name="name" id="name" value="{{ .data.shopItem.Name }}" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="abstract" class="block text-sm/6 font-medium text-gray-900">Abstract</label>
|
||||
<div class="mt-2">
|
||||
<input type="text" name="abstract" id="abstract" value="{{ .data.shopItem.Abstract }}" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="description" class="block text-sm/6 font-medium text-gray-900">Description</label>
|
||||
<textarea id="description" name="description" type="textarea" class="block w-full px-4 py-2 mt-2 text-gray-900 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:text-gray-900 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring">{{ .data.shopItem.Description}}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm/6 text-gray-900">Select Categories</label>
|
||||
<div class="space-y-2">
|
||||
{{ range .data.tags }}
|
||||
<label class="flex text-sm/6 items-center">
|
||||
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="tags[]">
|
||||
<span class="ml-2 text-sm/6 text-gray-900">{{ .Name }}</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="mb-4">
|
||||
<label for="tags" class="block text-gray-700">Select Tags</label>
|
||||
<select id="tags" name="tags" multiple class="mt-1 block w-full border border-gray-300 rounded-md p-2 focus:outline-none focus:ring focus:ring-blue-500">
|
||||
<option value="tag1">Tag 1</option>
|
||||
<option value="tag2">Tag 2</option>
|
||||
<option value="tag3">Tag 3</option>
|
||||
<option value="tag4">Tag 4</option>
|
||||
<option value="tag5">Tag 5</option>
|
||||
</select>
|
||||
<p class="mt-1 text-gray-500 text-sm">Hold down the Ctrl (Windows) or Command (Mac) button to select multiple options.</p>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="price" class="block text-sm/6 font-medium text-gray-900">Price</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="price" id="price" value="{{ .data.shopItem.Price }}" step="0.01" min="0.00" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-900">
|
||||
Image
|
||||
</label>
|
||||
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||
<div class="space-y-1 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-900" stroke="currentColor" fill="none" viewBox="0 0 48 48" aria-hidden="true">
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span class="">Upload a file</span>
|
||||
<input id="file-upload" name="file-upload" type="file" class="sr-only">
|
||||
</label>
|
||||
<p class="pl-1 text-gray-900">or drag and drop</p>
|
||||
</div>
|
||||
<p class="text-xs text-gray-900">
|
||||
PNG, JPG, GIF up to 10MB
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .data.success }}
|
||||
</p>
|
||||
|
||||
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Update Item</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{ template "footer.html" . }}
|
||||
@@ -27,13 +27,13 @@
|
||||
</div>
|
||||
{{ if .loggedIn }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="additem" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Add Item</a>
|
||||
<a href="logout" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Logout</a>
|
||||
<a href="/additem" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Add Item</a>
|
||||
<a href="/logout" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Logout</a>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="login" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Login</a>
|
||||
<a href="register" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Register</a>
|
||||
<a href="/login" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Login</a>
|
||||
<a href="/register" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Register</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
@@ -2,10 +2,22 @@
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<div class="bg-gray-200 rounded m-4 p-4">
|
||||
<div class="relative w-full md:w-48 mb-4 flex rounded-lg justify-center items-center">
|
||||
<img src="/{{ .data.shopItem.Image }}" alt="shopping image"
|
||||
class="object-cover w-full h-48 md:h-full rounded">
|
||||
</div>
|
||||
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
|
||||
<i class="text-xs">{{ .data.shopItem.Description }}</i>
|
||||
<i class="text-xs">{{ .data.shopItem.Abstract }}</i>
|
||||
<p class="text-xs">{{ .data.shopItem.Description }}</p>
|
||||
<p class="">Price: {{ .data.shopItem.Price }}</p>
|
||||
{{ if .loggedIn }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="{{ .data.shopItem.ID }}/edit" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Edit</a>
|
||||
<a href="{{ .data.shopItem.ID }}/delete" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Delete</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{ template "footer.html" . }}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
{{ range .data.shopItems }}
|
||||
<a href="shopitems/{{ .ID }}">
|
||||
<a href="/shopitems/{{ .ID }}">
|
||||
<div class="bg-gray-200 rounded m-4 p-4">
|
||||
|
||||
<div class="relative w-full md:w-48 mb-4 flex rounded-lg justify-center items-center">
|
||||
<img src="/{{ .Image }}" alt="shopping image"
|
||||
class="object-cover w-full h-48 md:h-full rounded">
|
||||
</div>
|
||||
<h3 class="text-lg">{{ .Name }}</h3>
|
||||
<i class="text-xs">{{ .Description }}</i>
|
||||
<p class="">Price: {{ .Price }}</p>
|
||||
<i class="text-xs">{{ .Abstract }}</i>
|
||||
<p class="">Price: {{ .Price }}</pÖ>
|
||||
</div>
|
||||
</a>
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user