Skip to content
Snippets Groups Projects
Commit 2337c5aa authored by fz2907's avatar fz2907
Browse files

Merge remote-tracking branch 'origin/agreement_next' into sprint_3

# Conflicts:
#	BackendFolder/SwitchRoom/src/main/java/vt/CS5934/SwitchRoom/repositories/MatchedWishlistRecordRepository.java
#	BackendFolder/SwitchRoom/src/main/java/vt/CS5934/SwitchRoom/services/MatchedWishlistRecordService.java
parents 90611eb7 d332d558
No related branches found
No related tags found
1 merge request!37Start AgreedMatchPage to show the ongoing matches and history matches for user...
Showing
with 634 additions and 46 deletions
package vt.CS5934.SwitchRoom.controllers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import vt.CS5934.SwitchRoom.models.InteractionModel;
import vt.CS5934.SwitchRoom.models.MatchedWishlistRecordModel;
import vt.CS5934.SwitchRoom.models.ResponseModel;
import vt.CS5934.SwitchRoom.models.UserOfferModel;
import vt.CS5934.SwitchRoom.services.InteractionService;
import vt.CS5934.SwitchRoom.services.MatchedWishlistRecordService;
import vt.CS5934.SwitchRoom.utility.LookupTables;
import java.util.Map;
/**
* The "@RestController" made the class into rest handle class
* The "@RequestMapping("example")" on the class level make it only react to url ".../example/..."
*/
@CrossOrigin(
allowCredentials = "true",
origins = {"http://localhost:8080/"}
)
@RestController
@RequestMapping("interactive")
public class InteractiveController {
/**
* You can use logger.[trace,debug,info,warn,error]("messages") to log into file
*/
private final Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
InteractionService interactionService;
@Autowired
MatchedWishlistRecordService matchedWishlistRecordService;
/**
* This function will handle the post function and change the JSON body into data class
* @param newData the JSON input in the request body
*/
@PostMapping("/newData")
public ResponseModel handlePost(@RequestBody Map<String, Object> newData) {
logger.info("You reached the handlePost() functions.");
System.out.println(newData);
ResponseModel response = new ResponseModel();
InteractionModel back = null;
try{
InteractionModel result = interactionService.searchBothIdFromDB(newData.get("offerId").toString(), newData.get("wishlistId").toString());
if(result == null) {
back = interactionService.addDataToDB(Integer.parseInt(newData.get("userId").toString()), null, newData.get("phone").toString(), null, false, newData.get("offerId").toString(), newData.get("wishlistId").toString());
if(newData.get("see").toString() == "offer") {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setOfferResult(LookupTables.MATCHING_RECORD_USER_RESULT.Accepted);
matchedWishlistRecordService.updateToDB(history);
} else {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setWishlistResult(LookupTables.MATCHING_RECORD_USER_RESULT.Accepted);
matchedWishlistRecordService.updateToDB(history);
}
} else {
if(result.getPhone1() == null) {
result.setUserId2(Integer.parseInt(newData.get("userId").toString()));
result.setPhone2(newData.get("phone").toString());
result.setJudgement(false);
InteractionModel resultAfterUpdate = interactionService.updateToDB(result);
back = resultAfterUpdate;
} else {
result.setPhone2(newData.get("phone").toString());
result.setJudgement(true);
result.setUserId2(Integer.parseInt(newData.get("userId").toString()));
InteractionModel resultAfterUpdate = interactionService.updateToDB(result);
back = resultAfterUpdate;
System.out.println("what is that?");
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
System.out.println("why this happened " + history.toString());
}
if(newData.get("see").toString() == "offer") {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setOfferResult(LookupTables.MATCHING_RECORD_USER_RESULT.Accepted);
matchedWishlistRecordService.updateToDB(history);
} else {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setWishlistResult(LookupTables.MATCHING_RECORD_USER_RESULT.Accepted);
matchedWishlistRecordService.updateToDB(history);
}
}
response.setMessage("Saved successfully");
response.setStatus(HttpStatus.OK);
response.setData(back);
return response;
}catch (Exception e){
return new ResponseModel(
"Error happen",
HttpStatus.OK,
null);
}
}
/**
* This function will handle the post function and change the JSON body into data class
*/
@GetMapping("/{userId}")
public ResponseModel getInteraction(@PathVariable Integer userId) {
logger.info("You reached the getInteraction() function.");
try{
InteractionModel[] tranBack = interactionService.findAllInteractionsFromDB(userId);
return new ResponseModel(
"This is a Interaction array response",
HttpStatus.OK,
tranBack);
}catch (Exception e){
return new ResponseModel(
"Error occur on get All ExampleModels, Error info is: " + e,
HttpStatus.OK,
null);
}
}
/**
* This function will handle the post function and change the JSON body into data class
* @param newData the JSON input in the request body
*/
@PostMapping("/disagree")
public ResponseModel disagreePost(@RequestBody Map<String, Object> newData) {
logger.info("You reached the disagreePost() functions.");
ResponseModel response = new ResponseModel();
InteractionModel back;
try{
InteractionModel result = interactionService.searchBothIdFromDB(newData.get("offerId").toString(), newData.get("wishlistId").toString());
System.out.println(result);
if(result == null) {
back = interactionService.addDataToDB(Integer.parseInt(newData.get("userId").toString()), null, null, null, false, newData.get("offerId").toString(), newData.get("wishlistId").toString());
if(newData.get("see").toString() == "offer") {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setOfferResult(LookupTables.MATCHING_RECORD_USER_RESULT.Declined);
matchedWishlistRecordService.updateToDB(history);
} else {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setWishlistResult(LookupTables.MATCHING_RECORD_USER_RESULT.Declined);
matchedWishlistRecordService.updateToDB(history);
}
} else {
if(result.getPhone1() == null) {
result.setUserId2(Integer.parseInt(newData.get("userId").toString()));
InteractionModel resultAfterUpdate = interactionService.updateToDB(result);
back = resultAfterUpdate;
} else {
result.setUserId2(Integer.parseInt(newData.get("userId").toString()));
InteractionModel resultAfterUpdate = interactionService.updateToDB(result);
back = resultAfterUpdate;
}
if(newData.get("see").toString() == "offer") {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setOfferResult(LookupTables.MATCHING_RECORD_USER_RESULT.Declined);
matchedWishlistRecordService.updateToDB(history);
} else {
MatchedWishlistRecordModel history = matchedWishlistRecordService.getHistoryFromDB(Long.parseLong(newData.get("offerId").toString()), Long.parseLong(newData.get("wishlistId").toString()));
history.setWishlistResult(LookupTables.MATCHING_RECORD_USER_RESULT.Declined);
matchedWishlistRecordService.updateToDB(history);
}
}
response.setMessage("Saved successfully");
response.setStatus(HttpStatus.OK);
response.setData(back);
return response;
}catch (Exception e){
return new ResponseModel(
"Error happen",
HttpStatus.OK,
null);
}
}
}
......@@ -40,7 +40,6 @@ public class MatchedOfferController {
@GetMapping("/{offerId}")
public ResponseModel getOffer(@PathVariable long offerId) {
logger.info("You reached the getOffer() function.");
System.out.println(offerId);
try{
UserOfferModel offer = offerPageService.getUserOfferInfo(offerId);
// List<MatchedWishlistRecordModel> offerNotifications = matchedWishlistRecordService.getOfferListWithIDFromDB(userId);
......
......@@ -40,7 +40,6 @@ public class MatchedWishListController {
@GetMapping("/{wishlistId}")
public ResponseModel getWishList(@PathVariable long wishlistId) {
logger.info("You reached the getWishList() function.");
System.out.println(wishlistId);
try{
WishlistItemModel wishlist = wishlistPageService.getWishlistItemInfo(wishlistId);
return new ResponseModel(
......
......@@ -87,7 +87,6 @@ public class NotificationController {
// System.out.println(userId);
try{
List<UserOfferWishlistLookUpModel> lookup = offerWishlistLookUpService.getOfferWishlistLookUpWithIDFromDB(userId);
System.out.println(lookup);
List<MatchedWishlistRecordModel> wishlists = dealWithWishlist.getMatchedWishlist(lookup);
// List<MatchedWishlistRecordModel> offerNotifications = matchedWishlistRecordService.getOfferListWithIDFromDB(userId);
// List<ExampleModel> exampleModels = exampleService.getAllExampleModelsFromDB();
......
package vt.CS5934.SwitchRoom.models;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* '@Data' tell spring this class can be map to JSON object if needed
* '@Entity' declare this class is a DB table
* '@Table(name=<table_name>)' declared which table stores its data
*/
@Data
@Entity
@Table(name = "Interaction")
@NoArgsConstructor
public class InteractionModel {
@Id
@Column(name="id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long userId;
@Column(name="user_id1")
private Integer userId1;
@Column(name="user_id2")
private Integer userId2;
@Column(name="phone1")
private String phone1;
@Column(name="phone2")
private String phone2;
@Column(name="judgement")
private Boolean judgement;
@Column(name="offerId")
private String offerId;
@Column(name="wishlistId")
private String wishlistId;
public InteractionModel(Integer userId1, Integer userId2, String phone1, String phone2, Boolean judgement, String offerId, String wishlistId) {
this.userId1 = userId1;
this.userId2 = userId2;
this.phone1 = phone1;
this.phone2 = phone2;
this.judgement = judgement;
this.offerId = offerId;
this.wishlistId = wishlistId;
}
@Override
public String toString() {
return "InteractionModel{" +
"userId1=" + userId1 +
", userId2=" + userId2 +
", phone1='" + phone1 + '\'' +
", phone2='" + phone2 + '\'' +
", judgement=" + judgement + '\'' +
", offerId=" + offerId + '\'' +
", wishlistId=" + wishlistId +
'}';
}
}
package vt.CS5934.SwitchRoom.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import vt.CS5934.SwitchRoom.models.InteractionModel;
public interface InteractionRepository extends JpaRepository<InteractionModel, Integer> {
/**
* The function name is the SQL query:
* findByIdAndName(long inputId, String inputName) == "SELETE * FROM table WHERE Id==inputId" AND name == inputName;
* This is an example of how to declare a SQL command, those will be use in service class
* @param userId the id in table you are looking for
* @return ExampleModel object
*/
InteractionModel findByUserId(long userId);
InteractionModel findInteractionModelByOfferIdAndWishlistId(String offerId, String wishlistId);
InteractionModel[] findInteractionModelsByUserId1(Integer userId);
InteractionModel[] findInteractionModelsByUserId2(Integer userId);
}
......@@ -3,6 +3,7 @@ package vt.CS5934.SwitchRoom.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import vt.CS5934.SwitchRoom.models.MatchedRecordIdModel;
import vt.CS5934.SwitchRoom.models.MatchedWishlistRecordModel;
import vt.CS5934.SwitchRoom.utility.LookupTables;
import java.util.Date;
import java.util.List;
......@@ -12,23 +13,38 @@ public interface MatchedWishlistRecordRepository extends JpaRepository<MatchedWi
* The function name is the SQL query:
* findByIdAndName(long inputId, String inputName) == "SELETE * FROM table WHERE Id==inputId" AND name == inputName;
* This is an example of how to declare a SQL command, those will be use in service class
*
* @param offerId the id in table you are looking for
* @return ExampleModel object
*/
List<MatchedWishlistRecordModel> findAllByOfferId(Long offerId);
/**
* The function name is the SQL query:
* findByIdAndName(long inputId, String inputName) == "SELETE * FROM table WHERE Id==inputId" AND name == inputName;
* findByIdAndName(long inputId, String inputName) == "SELETE * FROM table WHERE Id==inputId" AND name == inputName;
* This is an example of how to declare a SQL command, those will be use in service class
*
* @param wishlistItemId the id in table you are looking for
* @return ExampleModel object
*/
List<MatchedWishlistRecordModel> findAllByWishlistItemId(Long wishlistItemId);
void deleteAllByOfferId(Long offerId);
void deleteAllByWishlistItemId(Long wishlistItemId);
Long countByWishlistItemId(Long wishlistItemId);
MatchedWishlistRecordModel findByOfferIdAndWishlistItemId(Long offerId, Long wishlistId);
List<MatchedWishlistRecordModel> findAllByOfferIdAndAgreedRecordIdIsNotNull(Long offerId);
List<MatchedWishlistRecordModel> findAllByEndTimeBefore(Date todayDate);
MatchedWishlistRecordModel findMatchedWishlistRecordModelByOfferIdAndWishlistItemId(Long offerId, Long wishlistItemId);
void deleteByOfferIdAndWishlistItemId(Long offerId, Long wishlistItemId);
void deleteMatchedWishlistRecordModelByOfferIdAndWishlistItemId(Long offerId, Long wishlistItemId);
List<MatchedWishlistRecordModel> findAllByOfferIdAndOfferResultAndWishlistResult(Long offerId, LookupTables.MATCHING_RECORD_USER_RESULT offerResult, LookupTables.MATCHING_RECORD_USER_RESULT wishlistResult);
List<MatchedWishlistRecordModel> findAllByWishlistItemIdAndWishlistResultAndOfferResult(Long wishlistItemId, LookupTables.MATCHING_RECORD_USER_RESULT offerResult, LookupTables.MATCHING_RECORD_USER_RESULT wishlistResult);
}
......@@ -8,6 +8,7 @@ import vt.CS5934.SwitchRoom.models.MatchedWishlistRecordModel;
import vt.CS5934.SwitchRoom.models.UserOfferWishlistLookUpModel;
import vt.CS5934.SwitchRoom.repositories.MatchedWishlistRecordRepository;
import vt.CS5934.SwitchRoom.repositories.UserOfferWishlistLookUpRepository;
import vt.CS5934.SwitchRoom.utility.LookupTables;
import java.util.ArrayList;
import java.util.List;
......@@ -22,16 +23,27 @@ public class DealWithWishlist {
@Autowired
MatchedWishlistRecordRepository matchedWishlistRecordRepository;
public List<MatchedWishlistRecordModel> getMatchedWishlist(List<UserOfferWishlistLookUpModel> list) {
logger.info("Reached get finalAns");
List<MatchedWishlistRecordModel> finalAns = new ArrayList<>();
for(int i = 0; i < list.size(); i++) {
System.out.println(list.get(i).getWishlistItemId());
List<MatchedWishlistRecordModel> ans = matchedWishlistRecordRepository.findAllByWishlistItemId(list.get(i).getWishlistItemId());
System.out.println(ans);
// System.out.println(list.get(i).getWishlistItemId() + " come on");
List<MatchedWishlistRecordModel> ans = matchedWishlistRecordRepository.findAllByWishlistItemIdAndWishlistResultAndOfferResult(list.get(i).getWishlistItemId(), LookupTables.MATCHING_RECORD_USER_RESULT.Waiting, LookupTables.MATCHING_RECORD_USER_RESULT.Waiting);
// System.out.println(ans);
finalAns.addAll(ans);
}
return finalAns;
}
// public List<MatchedWishlistRecordModel> getMatchedWishlist(List<UserOfferWishlistLookUpModel> list) {
// logger.info("Reached get finalAns");
// List<MatchedWishlistRecordModel> finalAns = new ArrayList<>();
// for(int i = 0; i < list.size(); i++) {
// System.out.println(list.get(i).getWishlistItemId()+" come on");
// List<MatchedWishlistRecordModel> ans = matchedWishlistRecordRepository.findAllByWishlistItemId(list.get(i).getWishlistItemId());
// System.out.println(ans);
// finalAns.addAll(ans);
// }
// return finalAns;
// }
}
package vt.CS5934.SwitchRoom.services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vt.CS5934.SwitchRoom.models.InteractionModel;
import vt.CS5934.SwitchRoom.models.UserModel;
import vt.CS5934.SwitchRoom.repositories.InteractionRepository;
import vt.CS5934.SwitchRoom.repositories.UserRepository;
@Service
public class InteractionService {
/**
* You can use logger.[trace,debug,info,warn,error]("messages") to log into file
*/
private final Logger logger = LoggerFactory.getLogger(UserService.class);
/**
* Autowired is a Spring feature that it will create or looking for the existing object in memory.
* It usually uses on Repository class, Service class, or some globe object in the class.
*/
@Autowired
InteractionRepository interactionRepository;
public InteractionModel addDataToDB(Integer userId1, Integer userId2, String phone1, String phone2, Boolean judgement, String offerId, String wishlistId){
logger.info("Reached addNewExampleModelToDB()");
InteractionModel data = new InteractionModel(userId1, userId2, phone1, phone2, judgement, offerId, wishlistId);
interactionRepository.save(data);
return data;
}
public InteractionModel searchBothIdFromDB(String offerId, String wishlistId) {
logger.info("Reached searchBothIdFromDB()");
InteractionModel result = interactionRepository.findInteractionModelByOfferIdAndWishlistId(offerId, wishlistId);
return result;
}
public InteractionModel updateToDB(InteractionModel updateData) {
interactionRepository.save(updateData);
return updateData;
}
public InteractionModel[] findAllInteractionsFromDB(Integer userId) {
InteractionModel[] res1 = interactionRepository.findInteractionModelsByUserId1(userId);
InteractionModel[] res2 = interactionRepository.findInteractionModelsByUserId2(userId);
int fal = res1.length;
int sal = res2.length;
InteractionModel[] res = new InteractionModel[fal + sal];
System.arraycopy(res1, 0, res, 0, fal);
System.arraycopy(res2, 0, res, fal, sal);
return res;
}
}
......@@ -7,6 +7,9 @@ import org.slf4j.LoggerFactory;
import vt.CS5934.SwitchRoom.models.*;
import vt.CS5934.SwitchRoom.repositories.*;
import vt.CS5934.SwitchRoom.utility.LookupTables;
import vt.CS5934.SwitchRoom.models.MatchedWishlistRecordModel;
import vt.CS5934.SwitchRoom.repositories.MatchedWishlistRecordRepository;
import vt.CS5934.SwitchRoom.utility.LookupTables;
import java.util.Date;
import java.util.List;
......@@ -37,9 +40,26 @@ public class MatchedWishlistRecordService {
@Autowired
WishlistItemRepository wishlistItemRepository;
public List<MatchedWishlistRecordModel> getOfferListWithIDFromDB(long id){
logger.info("Reached getOfferListIDFromDB()");
return matchedWishlistRecordRepository.findAllByOfferId(id);
return matchedWishlistRecordRepository.findAllByOfferIdAndOfferResultAndWishlistResult(id, LookupTables.MATCHING_RECORD_USER_RESULT.Waiting, LookupTables.MATCHING_RECORD_USER_RESULT.Waiting);
}
public MatchedWishlistRecordModel getHistoryFromDB(Long offerId, Long wishlistItemId) {
logger.info("Reached getHistoryFromDB()");
return matchedWishlistRecordRepository.findMatchedWishlistRecordModelByOfferIdAndWishlistItemId(offerId, wishlistItemId);
}
public void deleteFromDB(Long offerId, Long wishlistItemId) {
logger.info("Reached deleteFromDB()");
matchedWishlistRecordRepository.deleteByOfferIdAndWishlistItemId(offerId, wishlistItemId);
}
public MatchedWishlistRecordModel updateToDB(MatchedWishlistRecordModel updateData) {
matchedWishlistRecordRepository.save(updateData);
return updateData;
}
public void hostAcceptedOrUpdate(Long offerId, Long wishlistId, Date startTime, Date endTime){
......
......@@ -27,6 +27,9 @@
<el-menu-item index="6" v-on:click="redirect('/profile')"
>Profile</el-menu-item
>
<el-menu-item index="6" v-on:click="redirect('/results')"
>Results</el-menu-item
>
<notification class="position"></notification>
<el-menu-item index="7" class="dock-right" @click="hanldeLogOut()"
>Log Out</el-menu-item
......
......@@ -12,18 +12,23 @@
<el-dropdown-menu>
<el-dropdown-item v-for="offer in offers" :key="offer.offerId">
<a>
<router-link
:to="
'/matched-result/' + offer.offerId + '/' + offer.wishlistItemId
<!-- <router-link-->
<!-- :to="-->
<!-- '/matched-result/' + offer.offerId + '/' + offer.wishlistItemId-->
<!-- "-->
<!-- style="color: blue"-->
<!-- >-->
<div
@click="
nextPageOffer('offer', offer.offerId, offer.wishlistItemId)
"
style="color: blue"
class="offer-match"
>
<div class="offer-match">
<div class="offer-text"></div>
<font-awesome-icon icon="fa-solid fa-circle-info" />
Offer Matched
</div>
</router-link>
<div class="offer-text"></div>
<font-awesome-icon icon="fa-solid fa-circle-info" />
Offer Matched
</div>
<!-- </router-link>-->
</a>
</el-dropdown-item>
<el-dropdown-item
......@@ -31,18 +36,23 @@
v-for="offer in offers2"
:key="offer.offerId"
>
<a
><router-link
:to="
'/matched-result/' + offer.offerId + '/' + offer.wishlistItemId
<a>
<!-- <router-link-->
<!-- :to="-->
<!-- '/matched-result/' + offer.offerId + '/' + offer.wishlistItemId-->
<!-- "-->
<!-- style="color: blue"-->
<!-- >-->
<div
@click="
nextPageWish('wishlist', offer.offerId, offer.wishlistItemId)
"
style="color: blue"
class="offer-match"
>
<div class="offer-match">
<font-awesome-icon icon="fa-solid fa-circle-info" />
WishList Matched
</div>
</router-link>
<font-awesome-icon icon="fa-solid fa-circle-info" />
WishList Matched
</div>
<!-- </router-link>-->
</a>
</el-dropdown-item>
</el-dropdown-menu>
......@@ -55,10 +65,15 @@ import { ref, watch } from "vue";
import { OfferNotification } from "@/models/OfferNotification";
import * as NotificationService from "@/services/NotificationService";
import { useRoute } from "vue-router";
import { useRouter } from "vue-router";
import { onMounted } from "vue";
import { Message } from "@element-plus/icons-vue";
import { useJudgementStore } from "@/store/judgementStore";
const judgementStore = useJudgementStore();
const route = useRoute();
const router = useRouter();
function getCookie(userId: string) {
const value = `; ${document.cookie}`;
......@@ -66,6 +81,22 @@ function getCookie(userId: string) {
if (parts.length === 2) return parts?.pop()?.split(";").shift();
}
function nextPageWish(input: string, oId: number, wId: number) {
judgementStore.markJudgement(input);
router.push({
name: "MatchResultPage",
params: { offerId: oId, wishlistId: wId },
});
}
function nextPageOffer(input: string, oId: number, wId: number) {
judgementStore.markJudgement(input);
router.push({
name: "MatchResultPage",
params: { offerId: oId, wishlistId: wId },
});
}
const offers = ref([] as OfferNotification[]);
const offers2 = ref([] as OfferNotification[]);
......
<template>
<div class="card">
<div class="container">
<h3>Please use the phone number here to contact with another resident</h3>
<div v-if="interaction.judgement">
<p>Phone Number 1: {{ interaction.phone1 }}</p>
<p>Phone Number 2: {{ interaction.phone2 }}</p>
</div>
<div v-else>
<p>Another resident don't want to switch with you.</p>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { defineProps } from "vue";
import { InteractionModel } from "@/models/InteractionModel";
const props = defineProps<{
interaction: InteractionModel;
}>();
</script>
<style scoped>
.card {
/* Add shadows to create the "card" effect */
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s;
}
/* On mouse-over, add a deeper shadow */
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}
/* Add some padding inside the card container */
.container {
padding: 2px 16px;
}
</style>
export class InteractionModel {
public userId1: number;
public userId2: number;
public phone1: string;
public phone2: string;
public judgement: boolean;
public offerId: string;
public wishlistId: string;
constructor(
userId1 = -1,
userId2 = -1,
phone1 = "",
phone2 = "",
judgement = false,
offerId = "",
wishlistId = ""
) {
this.userId1 = userId1;
this.userId2 = userId2;
this.phone1 = phone1;
this.phone2 = phone2;
this.judgement = judgement;
this.offerId = offerId;
this.wishlistId = wishlistId;
}
}
......@@ -6,6 +6,11 @@ import ForgotPasswordFormView from "../views/ForgotPasswordFormView.vue";
import ResetPasswordView from "../views/ResetPasswordView.vue";
import ProfileView from "../views/ProfileView.vue";
import MatchedView from "../views/MatchedView.vue";
import AgreementView from "../views/AgreementView.vue";
import SendView from "../views/SendView.vue";
import ConfirmationView from "../views/ConfirmationView.vue";
import ResultsView from "../views/ResultsView.vue";
import ConfirmationFailView from "../views/ConfirmationFailView.vue";
const routes: Array<RouteRecordRaw> = [
{
......@@ -121,7 +126,53 @@ const routes: Array<RouteRecordRaw> = [
path: "/flight-ticket",
name: "TicketPage",
component: () =>
import(/* webpackChunkName: "about" */ "../views/FlightTicket.vue"),
import(/* webpackChunkName: "about" */ "../views/FlightTicket.vue"),
},
{
path: "/agree/:offerId/:wishlistId",
name: "AgreementPage",
meta: {
requiresAuth: true,
hideHeader: false,
},
component: AgreementView,
},
{
path: "/agree/send/:offerId/:wishlistId",
name: "sendPage",
meta: {
requiresAuth: true,
hideHeader: false,
},
component: SendView,
},
{
path: "/confirmation",
name: "confirmationPage",
meta: {
requiresAuth: true,
hideHeader: false,
},
component: ConfirmationView,
},
{
path: "/confirmationFail",
name: "confirmationFailPage",
meta: {
requiresAuth: true,
hideHeader: false,
},
component: ConfirmationFailView,
},
{
path: "/results",
name: "resultsPage",
meta: {
requiresAuth: true,
hideHeader: false,
},
component: ResultsView,
},
];
......
import * as serverHttpService from "./ServerHttpService";
const baseUrl = "interactive";
function postDisagreeToServer(data: any) {
const urlPath = "/disagree";
return serverHttpService.Post(baseUrl + urlPath, JSON.parse(data));
}
// function fetchFromServer(userId: any) {
// const urlPath = "/" + userId;
// return serverHttpService.Get(baseUrl + urlPath);
// }
export { postDisagreeToServer };
import * as serverHttpService from "./ServerHttpService";
const baseUrl = "interactive";
function postPhoneToServer(phoneNumber: any) {
const urlPath = "/newData";
return serverHttpService.Post(baseUrl + urlPath, JSON.parse(phoneNumber));
}
function fetchFromServer(userId: any) {
const urlPath = "/" + userId;
return serverHttpService.Get(baseUrl + urlPath);
}
export { postPhoneToServer, fetchFromServer };
......@@ -3,21 +3,21 @@ import { FlightResultModel } from "@/models/FlightResultModel";
import { FlightFormModel } from "@/models/FlightFormModel";
import * as FlightTicketService from "@/services/FlightTicketService";
export const useTicketStore = defineStore("TicketStore", {
//state
//options
//getters
state: () => ({
ticketList: [] as FlightResultModel[],
}),
actions: {
async fetchResultTicket(flightModel: FlightFormModel) {
await FlightTicketService.createNewFlight(flightModel).then((response) => {
console.log("Save search flight data: ", response.data);
this.ticketList = response.data;
});
},
//state
//options
//getters
state: () => ({
ticketList: [] as FlightResultModel[],
}),
actions: {
async fetchResultTicket(flightModel: FlightFormModel) {
await FlightTicketService.createNewFlight(flightModel).then(
(response) => {
console.log("Save search flight data: ", response.data);
this.ticketList = response.data;
}
);
},
});
\ No newline at end of file
},
});
import { defineStore } from "pinia";
import { InteractionModel } from "@/models/InteractionModel";
import * as PhoneService from "@/services/PhoneService";
export const useInteractionStore = defineStore("InteractionStore", {
//state
//options
//getters
state: () => ({
interactionList: [] as InteractionModel[],
}),
actions: {
async fetchInteractionData(data: any) {
await PhoneService.postPhoneToServer(data).then((response) => {
console.log("fetched interaction data", response.data);
this.interactionList = response.data;
console.log(this.interactionList);
});
},
},
});
import { defineStore } from "pinia";
import * as PhoneService from "@/services/PhoneService";
export const useJudgementStore = defineStore("JudgementStore", {
//state
//options
//getters
state: () => ({
judgement: String,
}),
actions: {
markJudgement(data: any) {
this.judgement = data;
},
},
});
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