Skip to content
Snippets Groups Projects
Commit 20984a7c authored by henrikburmann's avatar henrikburmann
Browse files

Merge branch 'main' into rentTesting

parents 66dd170a 45fc23d8
No related branches found
No related tags found
1 merge request!154Rent testing
...@@ -58,12 +58,18 @@ export default { ...@@ -58,12 +58,18 @@ export default {
calculateTime() { calculateTime() {
var time = this?.message.timestamp; var time = this?.message.timestamp;
var date = new Date(time); var date = new Date(time);
//Todo add timing for mm and hh and week of message
var mmOfMessage = String(date.getMinutes()); var mmOfMessage = String(date.getMinutes());
var hhOfMessage = String(date.getHours()); var hhOfMessage = String(date.getHours());
if (mmOfMessage <= 9) {
mmOfMessage = "0" + mmOfMessage;
}
if (hhOfMessage <= 9) {
hhOfMessage = "0" + hhOfMessage;
}
var ddOfMessage = String(date.getDate()).padStart(2, "0"); var ddOfMessage = String(date.getDate()).padStart(2, "0");
var dayOfMessage = date.toLocaleString("default", { weekday: "short" }); var dayOfMessage = date.toLocaleString("default", { weekday: "short" });
var monthOfMessage = String(date.getMonth() + 1).padStart(2, "0"); //January is 0! var monthOfMessage = String(date.getMonth() + 1).padStart(2, "0");
const shortMonthOfMessage = date.toLocaleString("default", { const shortMonthOfMessage = date.toLocaleString("default", {
month: "short", month: "short",
}); });
...@@ -71,7 +77,7 @@ export default { ...@@ -71,7 +77,7 @@ export default {
var today = new Date(); var today = new Date();
var dd = String(today.getDate()).padStart(2, "0"); var dd = String(today.getDate()).padStart(2, "0");
var mm = String(today.getMonth() + 1).padStart(2, "0"); //January is 0! var mm = String(today.getMonth() + 1).padStart(2, "0");
var yyyy = today.getFullYear(); var yyyy = today.getFullYear();
if (ddOfMessage == dd) { if (ddOfMessage == dd) {
return "" + hhOfMessage + ":" + mmOfMessage + ""; return "" + hhOfMessage + ":" + mmOfMessage + "";
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<p>Pris: {{ price }}kr</p> <p>Pris: {{ price }}kr</p>
</div> </div>
<div class="img-container"> <div class="img-container">
<img class="img" :src="img" alt="Produkt Bilde" /> <img class="img" :src="image" alt="Produkt Bilde" />
</div> </div>
</div> </div>
<div> <div>
...@@ -19,11 +19,21 @@ ...@@ -19,11 +19,21 @@
</p> </p>
</div> </div>
</div> </div>
<div class="buttons" v-if="(!rent.isAccepted && !rent.deleted && this.rent.renterId != this.userID)"> <div
class="buttons"
v-if="
!rent.isAccepted && !rent.deleted && this.rent.renterId != this.userID
"
>
<button class="button green" @click="accept">Godta</button> <button class="button green" @click="accept">Godta</button>
<button class="button red" @click="reject">Avslå</button> <button class="button red" @click="reject">Avslå</button>
</div> </div>
<div class="waiting" v-if="!rent.isAccepted && !rent.deleted && this.rent.renterId == this.userID"> <div
class="waiting"
v-if="
!rent.isAccepted && !rent.deleted && this.rent.renterId == this.userID
"
>
Waiting for owner to accept Waiting for owner to accept
</div> </div>
<div class="" v-if="rent.isAccepted"> <div class="" v-if="rent.isAccepted">
...@@ -38,8 +48,8 @@ ...@@ -38,8 +48,8 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import { tokenHeader } from "@/utils/token-utils"; import { tokenHeader, parseCurrentUser } from "@/utils/token-utils";
import { parseCurrentUser } from "@/utils/token-utils"; import { getItemPictures, } from "@/utils/apiutil";
export default { export default {
props: { props: {
...@@ -48,6 +58,11 @@ export default { ...@@ -48,6 +58,11 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
image: null,
}
},
computed: { computed: {
userID() { userID() {
return parseCurrentUser().accountId; return parseCurrentUser().accountId;
...@@ -75,9 +90,8 @@ export default { ...@@ -75,9 +90,8 @@ export default {
return this.rent.message || "Ingen Melding"; return this.rent.message || "Ingen Melding";
}, },
side() { side() {
return this.rent.renterId == this.userID return this.rent.renterId == this.userID ? "flex-end" : "flex-start";
? "flex-end" : "flex-start"; },
}
}, },
methods: { methods: {
async accept() { async accept() {
...@@ -93,6 +107,19 @@ export default { ...@@ -93,6 +107,19 @@ export default {
{ headers: tokenHeader() } { headers: tokenHeader() }
); );
}, },
async getImage() {
let images = await getItemPictures(this.rent.listingId);
if (images.length > 0) {
this.image = images[0].picture;
} else {
this.image = "https://images.unsplash.com/photo-1453728013993-6d66e9c9123a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dmlld3xlbnwwfHwwfHw%3D&w=1000&q=80";
}
},
},
async beforeMount() {
await this.getImage();
}, },
}; };
</script> </script>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</template> </template>
<script> <script>
// import CommunityAdminService from "@/services/community-admin.service"; import CommunityAdminService from "@/services/community-admin.service";
import IconButton from "@/components/BaseComponents/IconButton.vue"; import IconButton from "@/components/BaseComponents/IconButton.vue";
//TODO: OPEN CONFIRMATION DIALOG WHEN DELETING //TODO: OPEN CONFIRMATION DIALOG WHEN DELETING
...@@ -19,9 +19,12 @@ export default { ...@@ -19,9 +19,12 @@ export default {
IconButton, IconButton,
}, },
methods: { methods: {
deleteCommunity() { async deleteCommunity() {
console.log("DELETED"); let response = await CommunityAdminService.deleteCommunity(
// CommunityAdminService.deleteCommunity(this.$route.params.communityID); this.$route.params.communityID
);
if (response.status === 200)
this.$router.push({ name: "home", replace: true });
}, },
}, },
}; };
......
...@@ -278,12 +278,13 @@ export default { ...@@ -278,12 +278,13 @@ export default {
location: this.group.place, location: this.group.place,
picture: this.group.image, picture: this.group.image,
}; };
console.log(this.group.image);
const respone = await postNewgroup(groupInfo); const respone = await postNewgroup(groupInfo);
if (respone.status === 200 || respone.status === 201) { if (respone.status === 200 || respone.status === 201) {
this.$router.push({ path: "/", replace: true }); this.$store.commit("addAdmin", respone.data);
this.$router.push({
path: "/community/" + respone.data,
replace: true,
});
} }
} }
}, },
......
...@@ -97,7 +97,10 @@ export default { ...@@ -97,7 +97,10 @@ export default {
getDateString(milliseconds) { getDateString(milliseconds) {
let today = new Date(); let today = new Date();
let date = new Date(milliseconds); let date = new Date(milliseconds);
let dateString = date.getDate() + "." + (date.getMonth() + 1); const shortMonthOfRentHistoryItem = date.toLocaleString("default", {
month: "short",
});
let dateString = date.getDate() + ". " + shortMonthOfRentHistoryItem;
if (date.getFullYear() != today.getFullYear()) { if (date.getFullYear() != today.getFullYear()) {
dateString += "." + date.getFullYear(); dateString += "." + date.getFullYear();
......
...@@ -98,7 +98,11 @@ ...@@ -98,7 +98,11 @@
<rating-component :rating="ownerRating" :ratingType="'Utleier'" /> <rating-component :rating="ownerRating" :ratingType="'Utleier'" />
</div> </div>
<div v-show="!isCurrentUser" class="flex mt-4 space-x-3 lg:mt-6"> <div
v-show="!isCurrentUser"
@click="$router.push('/messages?userID=' + id)"
class="flex mt-4 space-x-3 lg:mt-6"
>
<a <a
href="#" href="#"
class="inline-flex items-center py-2 px-4 text-sm font-medium text-center text-gray-900 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-700" class="inline-flex items-center py-2 px-4 text-sm font-medium text-center text-gray-900 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-700"
......
...@@ -60,7 +60,7 @@ class CommunityAdminService { ...@@ -60,7 +60,7 @@ class CommunityAdminService {
* @returns TODO * @returns TODO
*/ */
async deleteCommunity(communityID) { async deleteCommunity(communityID) {
return await axios.post( return await axios.delete(
API_URL + "communities/" + communityID + "/remove", API_URL + "communities/" + communityID + "/remove",
{ {
headers: tokenHeader(), headers: tokenHeader(),
......
...@@ -6,6 +6,7 @@ const state = { ...@@ -6,6 +6,7 @@ const state = {
const mutations = { const mutations = {
logout(state) { logout(state) {
state.token = null; state.token = null;
state.adminList = [];
}, },
saveToken(state, token) { saveToken(state, token) {
state.token = token; state.token = token;
...@@ -18,6 +19,10 @@ const mutations = { ...@@ -18,6 +19,10 @@ const mutations = {
state.adminList.push(communityIDArray[i]); state.adminList.push(communityIDArray[i]);
} }
}, },
addAdmin(state, communityID) {
if (!Number(communityID)) return;
state.adminList.push(communityID);
},
}; };
export default { export default {
......
...@@ -13,6 +13,15 @@ jest.mock("@/utils/token-utils", () => { ...@@ -13,6 +13,15 @@ jest.mock("@/utils/token-utils", () => {
}; };
}); });
jest.mock("@/utils/apiutil", () => {
return {
getItemPictures: () => {
return new Promise((resolve) => {
resolve([]);
});
},
};
});
jest.mock("axios"); jest.mock("axios");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment