@@ -33829,6 +33829,7 @@ ${JSON.stringify(newTargetLocation, null, 2)}
33829
33829
server,
33830
33830
user: userData,
33831
33831
messages: void 0,
33832
+ message: void 0,
33832
33833
pkdata: void 0,
33833
33834
loading: false
33834
33835
};
@@ -33843,6 +33844,9 @@ ${JSON.stringify(newTargetLocation, null, 2)}
33843
33844
setMessages(state, data) {
33844
33845
state.messages = data;
33845
33846
},
33847
+ setMessage(state, data) {
33848
+ state.message = data;
33849
+ },
33846
33850
setServer(state, data) {
33847
33851
state.server = data;
33848
33852
}
@@ -33904,6 +33908,7 @@ ${JSON.stringify(newTargetLocation, null, 2)}
33904
33908
context.commit("setLoading", false);
33905
33909
context.commit("setUserData", void 0);
33906
33910
context.commit("setMessages", void 0);
33911
+ context.commit("setMessage", void 0);
33907
33912
resolve();
33908
33913
});
33909
33914
});
@@ -33914,12 +33919,12 @@ ${JSON.stringify(newTargetLocation, null, 2)}
33914
33919
}
33915
33920
});
33916
33921
},
33917
- fetchMessages (context) {
33922
+ fetchParticipantMessages (context) {
33918
33923
console.log("MESSAGEs ", context.state);
33919
33924
context.commit("setLoading", true);
33920
33925
console.log("Fetch messages");
33921
33926
return new Promise(async (resolve, reject) => {
33922
- await fetch(context.state.server + "/messages/api/messages /", {
33927
+ await fetch(context.state.server + "/messages/api/participants /", {
33923
33928
method: "GET",
33924
33929
headers: {
33925
33930
"Content-Type": "application/json",
@@ -33936,6 +33941,29 @@ ${JSON.stringify(newTargetLocation, null, 2)}
33936
33941
});
33937
33942
});
33938
33943
});
33944
+ },
33945
+ fetchMessage(context, { id }) {
33946
+ console.log("MESSAGE: ", context.state);
33947
+ context.commit("setLoading", true);
33948
+ console.log("Fetch message ", id);
33949
+ return new Promise(async (resolve, reject) => {
33950
+ await fetch(context.state.server + "/messages/api/messages/" + id + "/", {
33951
+ method: "GET",
33952
+ headers: {
33953
+ "Content-Type": "application/json",
33954
+ "Authorization": `Token ${context.state.user.token}`
33955
+ }
33956
+ }).then((res) => {
33957
+ console.log(res);
33958
+ if (res.status !== 200) {
33959
+ throw new Error("Error");
33960
+ }
33961
+ res.json().then((data) => {
33962
+ context.commit("setLoading", false);
33963
+ context.commit("setMessage", data);
33964
+ });
33965
+ });
33966
+ });
33939
33967
}
33940
33968
}
33941
33969
});
@@ -34083,7 +34111,7 @@ ${JSON.stringify(newTargetLocation, null, 2)}
34083
34111
]),
34084
34112
created() {
34085
34113
if (this.messages == void 0) {
34086
- this.$store.dispatch("fetchMessages ");
34114
+ this.$store.dispatch("fetchParticipantMessages ");
34087
34115
}
34088
34116
},
34089
34117
template: `
@@ -34117,16 +34145,19 @@ ${JSON.stringify(newTargetLocation, null, 2)}
34117
34145
// src/components/Message.js
34118
34146
var Message_default = {
34119
34147
computed: mapState([
34120
- "messages ",
34148
+ "message ",
34121
34149
"loading"
34122
34150
]),
34123
34151
created() {
34124
- if ( this.messages == void 0) {
34125
- this.$store.dispatch("fetchMessages");
34126
- }
34152
+ this.$store.dispatch("fetchMessage", {
34153
+ id: this.$route.params.id
34154
+ });
34127
34155
},
34128
34156
template: `
34129
34157
<div>Message {{ $route.params.id }}</div>
34158
+ <div>{{ message }}</div>
34159
+
34160
+
34130
34161
`
34131
34162
};
34132
34163
0 commit comments