diff --git a/frontend/src/components/views/PendingRequests.vue b/frontend/src/components/views/PendingRequests.vue index 59c2f6a..0b6aa34 100644 --- a/frontend/src/components/views/PendingRequests.vue +++ b/frontend/src/components/views/PendingRequests.vue @@ -2,22 +2,120 @@ // @ts-ignore import { useStore } from "vuex"; import { ref, onBeforeMount } from "vue"; +import { Tabs } from "@/components/ui/tabs"; +import DualColumnLayout from "@/components/layouts/DualColumnLayout.vue"; +import { Button } from "@/components/ui/button"; +import { Check, X } from "lucide-vue-next"; +import SquircleAvatar from "@/components/elements/SquircleAvatar.vue"; + +interface RelationData { + idRelacion: string; + idActor: string; + avatar: string; + name: string; + alias: string; + routeType: string; +} const store = useStore(); const pendings = ref(); +const idSelf = ref(); +const relationDataList = ref([]); + +onBeforeMount(async () => { + idSelf.value = store.getters["USERS/getSelected"]._id; + pendings.value = await store.dispatch("NOTIFICATIONS/GET_PENDINGS", idSelf.value); -onBeforeMount(() => { - pendings.value = store.dispatch( - "NOTIFICATIONS/GET_PENDINGS", - store.getters["USERS/getSelected"]._id - ); + const tag = store.getters["USERS/getTypeSelected"]; + + for (const pending of pendings.value) { + const idOther = pending.id1 == idSelf.value ? pending.id2 : pending.id1; + let actor = await getActorInfo(idOther, tag); + relationDataList.value.push({ + idRelacion: pending._id, + idActor: idOther, + avatar: actor.avatar, + name: tag == "user" ? actor.username : actor.nickname, + alias: tag == "user" ? actor.nickname : actor.pjname, + routeType: tag == "user" ? "user" : "pj", + }); + } }); + +const getActorInfo = async (id: string, type: string) => { + return type === "user" + ? await store.dispatch("USERS/GET_USER_BY_ID", id) + : await store.dispatch("CHARACTERS/GET_CHARACTER_BY_ID", id); +}; + +const accept = () => {}; +const deny = () => {};