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 {
calculateTime() {
var time = this?.message.timestamp;
var date = new Date(time);
//Todo add timing for mm and hh and week of message
var mmOfMessage = String(date.getMinutes());
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 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", {
month: "short",
});
......@@ -71,7 +77,7 @@ export default {
var today = new Date();
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();
if (ddOfMessage == dd) {
return "" + hhOfMessage + ":" + mmOfMessage + "";
......
......@@ -8,7 +8,7 @@
<p>Pris: {{ price }}kr</p>
</div>
<div class="img-container">
<img class="img" :src="img" alt="Produkt Bilde" />
<img class="img" :src="image" alt="Produkt Bilde" />
</div>
</div>
<div>
......@@ -19,11 +19,21 @@
</p>
</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 red" @click="reject">Avslå</button>
</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
</div>
<div class="" v-if="rent.isAccepted">
......@@ -38,8 +48,8 @@
<script>
import axios from "axios";
import { tokenHeader } from "@/utils/token-utils";
import { parseCurrentUser } from "@/utils/token-utils";
import { tokenHeader, parseCurrentUser } from "@/utils/token-utils";
import { getItemPictures, } from "@/utils/apiutil";
export default {
props: {
......@@ -48,6 +58,11 @@ export default {
required: true,
},
},
data() {
return {
image: null,
}
},
computed: {
userID() {
return parseCurrentUser().accountId;
......@@ -75,9 +90,8 @@ export default {
return this.rent.message || "Ingen Melding";
},
side() {
return this.rent.renterId == this.userID
? "flex-end" : "flex-start";
}
return this.rent.renterId == this.userID ? "flex-end" : "flex-start";
},
},
methods: {
async accept() {
......@@ -93,6 +107,19 @@ export default {
{ 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>
......
......@@ -9,7 +9,7 @@
</template>
<script>
// import CommunityAdminService from "@/services/community-admin.service";
import CommunityAdminService from "@/services/community-admin.service";
import IconButton from "@/components/BaseComponents/IconButton.vue";
//TODO: OPEN CONFIRMATION DIALOG WHEN DELETING
......@@ -19,9 +19,12 @@ export default {
IconButton,
},
methods: {
deleteCommunity() {
console.log("DELETED");
// CommunityAdminService.deleteCommunity(this.$route.params.communityID);
async deleteCommunity() {
let response = await CommunityAdminService.deleteCommunity(
this.$route.params.communityID
);
if (response.status === 200)
this.$router.push({ name: "home", replace: true });
},
},
};
......
......@@ -278,12 +278,13 @@ export default {
location: this.group.place,
picture: this.group.image,
};
console.log(this.group.image);
const respone = await postNewgroup(groupInfo);
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 {
getDateString(milliseconds) {
let today = new Date();
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()) {
dateString += "." + date.getFullYear();
......
......@@ -98,7 +98,11 @@
<rating-component :rating="ownerRating" :ratingType="'Utleier'" />
</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
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"
......
......@@ -60,7 +60,7 @@ class CommunityAdminService {
* @returns TODO
*/
async deleteCommunity(communityID) {
return await axios.post(
return await axios.delete(
API_URL + "communities/" + communityID + "/remove",
{
headers: tokenHeader(),
......
......@@ -6,6 +6,7 @@ const state = {
const mutations = {
logout(state) {
state.token = null;
state.adminList = [];
},
saveToken(state, token) {
state.token = token;
......@@ -18,6 +19,10 @@ const mutations = {
state.adminList.push(communityIDArray[i]);
}
},
addAdmin(state, communityID) {
if (!Number(communityID)) return;
state.adminList.push(communityID);
},
};
export default {
......
......@@ -13,6 +13,15 @@ jest.mock("@/utils/token-utils", () => {
};
});
jest.mock("@/utils/apiutil", () => {
return {
getItemPictures: () => {
return new Promise((resolve) => {
resolve([]);
});
},
};
});
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