diff --git a/src/components/CommunityComponents/NewCommunityForm.vue b/src/components/CommunityComponents/NewCommunityForm.vue index f9a14f81b9925a9f1659c1532ce4c47f6dc1d2ea..888780d4609b3f7c206577259ed100981409fce1 100644 --- a/src/components/CommunityComponents/NewCommunityForm.vue +++ b/src/components/CommunityComponents/NewCommunityForm.vue @@ -1,10 +1,28 @@ <template> <div - class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" + class=" + md:ring-1 + ring-gray-300 + rounded-xl + overflow-hidden + mx-auto + mb-auto + max-w-md + w-full + p-4 + " > <!-- Component heading --> <div - class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-10" + class=" + text-xl + md:text-2xl + font-medium + text-center text-gray-600 + dark:text-gray-200 + mt-4 + mb-10 + " > Opprett ny gruppe </div> @@ -18,7 +36,25 @@ > <div class="form-check"> <input - class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + class=" + form-check-input + appearance-none + rounded-full + h-4 + w-4 + border border-gray-300 + bg-white + checked:bg-primary-medium checked:border-primary-medium + focus:outline-none + transition + duration-200 + mt-1 + align-top + bg-no-repeat bg-center bg-contain + float-left + mr-2 + cursor-pointer + " type="radio" name="flexRadioDefault" id="flexRadioOpen" @@ -36,7 +72,25 @@ </div> <div class="form-check"> <input - class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + class=" + form-check-input + appearance-none + rounded-full + h-4 + w-4 + border border-gray-300 + bg-white + checked:bg-primary-medium checked:border-primary-medium + focus:outline-none + transition + duration-200 + mt-1 + align-top + bg-no-repeat bg-center bg-contain + float-left + mr-2 + cursor-pointer + " type="radio" name="flexRadioDefault" id="flexRadioPrivate" @@ -63,7 +117,25 @@ <input type="text" id="title" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + class=" + block + w-full + px-4 + py-2 + mt-2 + text-gray-700 + placeholder-gray-500 + bg-white + border + rounded-md + dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 + focus:border-primary-light + dark:focus:border-primary-light + focus:ring-opacity-40 + focus:outline-none + focus:ring + focus:ring-primary-light + " v-model="v$.group.name.$model" required /> @@ -89,7 +161,25 @@ > <input type="text" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + class=" + block + w-full + px-4 + py-2 + mt-2 + text-gray-700 + placeholder-gray-500 + bg-white + border + rounded-md + dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 + focus:border-primary-light + dark:focus:border-primary-light + focus:ring-opacity-40 + focus:outline-none + focus:ring + focus:ring-primary-light + " v-model="v$.group.place.$model" required /> @@ -117,7 +207,25 @@ id="description" rows="4" v-model="v$.group.description.$model" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + class=" + block + w-full + px-4 + py-2 + mt-2 + text-gray-700 + placeholder-gray-500 + bg-white + border + rounded-md + dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 + focus:border-primary-light + dark:focus:border-primary-light + focus:ring-opacity-40 + focus:outline-none + focus:ring + focus:ring-primary-light + " required ></textarea> @@ -156,7 +264,21 @@ <!--<div class="text-error uppercase text-center">Midlertidig fjernet</div> --> <button @click="$refs.file.click()" - class="text-black bg-gray-200 hover:bg-grey-800 focus:ring-4 focus:outline-none focus:ring-grey-300 font-medium rounded-lg text-sm sm:w-auto px-5 py-2.5 text-center dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 disabled:opacity-50" + class=" + text-black + bg-gray-200 + hover:bg-grey-800 + focus:ring-4 focus:outline-none focus:ring-grey-300 + font-medium + rounded-lg + text-sm + sm:w-auto + px-5 + py-2.5 + text-center + dark:bg-grey-600 dark:hover:bg-grey-700 dark:focus:ring-grey-800 + disabled:opacity-50 + " :disabled="imageAdded" > Velg bilde @@ -300,20 +422,18 @@ export default { this.group.images.push(URL.createObjectURL(event.target.files[0])); let image = event.target.files[0]; - console.log(image); - /**const buffer = await image.arrayBuffer(); - let byteArray = new Int8Array(buffer); - console.log(byteArray)*/ - - - await postNewImageCommunity(image); - this.imageThere = true; + let fileReader = new FileReader(); + fileReader.onloadend = async function () { + const res = fileReader.result; + await postNewImageCommunity(res); + this.imageThere = true; + }; + fileReader.readAsArrayBuffer(image); }, }, async beforeMount() { this.group.image = await GetImage(42); //console.log(array); - - } + }, }; </script> diff --git a/src/utils/apiutil.js b/src/utils/apiutil.js index a3b10787871aa892961b673c0f3d5718f6e860ec..cbd1218356979473523a926f5e049d2ccae82e62 100644 --- a/src/utils/apiutil.js +++ b/src/utils/apiutil.js @@ -324,7 +324,7 @@ export function postNewRating(ratingInfo) { export function postNewImageCommunity(image) { return axios - .post(API_URL + "images", {body: image}, { + .post(API_URL + "images", image, { headers: {...tokenHeader(), "Content-Type": "image/png"}, }) .then((response) => {