119119<script lang="ts">
120120/* es-lint disabled*/
121121
122- import { defineComponent , inject , ref } from " vue" ;
122+ import { defineComponent , inject , onBeforeMount , ref } from " vue" ;
123123import " @cometchat/uikit-elements" ;
124124import { fontHelper } from " @cometchat/uikit-resources" ;
125125import { CometChat } from " @cometchat/chat-sdk-javascript" ;
@@ -133,8 +133,15 @@ import {
133133} from " ../assets" ;
134134import { CometChatUIKit } from " @cometchat/chat-uikit-vue" ;
135135import { metaInfo } from " ../metaInfo" ;
136+ import { users } from " ../sampleApp/sampledata" ;
136137let buttonImage = " assets/button-opc.png" ;
137138
139+ type User = {
140+ name: string ;
141+ uid: string ;
142+ avatar: string ;
143+ };
144+
138145export default defineComponent ({
139146 name: " LoginComponent" ,
140147 components: {},
@@ -148,6 +155,7 @@ export default defineComponent({
148155 let enteredUid! : string ;
149156 let enteredName! : string ;
150157 let inProgress = ref (false );
158+ const usersArray = ref <User []>([]);
151159
152160 let avatarStyle: AvatarStyle = {
153161 height: " 32px" ,
@@ -236,36 +244,25 @@ export default defineComponent({
236244 router .push ({ path: " /signup" });
237245 };
238246
239- const usersArray = [
240- {
241- name: " Iron Man" ,
242- UID: " SUPERHERO1" ,
243- uid: " superhero1" ,
244- avatar:
245- " https://data-us.cometchat.io/assets/images/avatars/ironman.png" ,
246- },
247- {
248- name: " Captain America" ,
249- UID: " SUPERHERO2" ,
250- uid: " superhero2" ,
251- avatar:
252- " https://data-us.cometchat.io/assets/images/avatars/captainamerica.png" ,
253- },
254- {
255- name: " Spiderman" ,
256- UID: " SUPERHERO3" ,
257- uid: " superhero3" ,
258- avatar:
259- " https://data-us.cometchat.io/assets/images/avatars/spiderman.png" ,
260- },
261- {
262- name: " Wolvorine" ,
263- UID: " SUPERHERO4" ,
264- uid: " superhero4" ,
265- avatar:
266- " https://data-us.cometchat.io/assets/images/avatars/wolverine.png" ,
267- },
268- ];
247+ async function fetchDefaultUsers() {
248+ try {
249+ const response = await fetch (
250+ " https://assets.cometchat.io/sampleapp/sampledata.json"
251+ );
252+ const data = await response .json ();
253+ usersArray .value = data .users ;
254+ } catch (error ) {
255+ console .log (
256+ " fetching default users failed, using fallback data" ,
257+ error
258+ );
259+ usersArray .value = users .users ;
260+ }
261+ }
262+
263+ onBeforeMount (() => {
264+ fetchDefaultUsers ();
265+ });
269266
270267 const styles: any = {
271268 loginWrapperStyle : () => {
0 commit comments