MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / defaultHtmlContent

Function defaultHtmlContent

pages/contacts.ts:82–126  ·  view source on GitHub ↗
({ addressBookId, userContacts, userAddressBooks, page, contactsCount, baseUrl, search }: {
  addressBookId: string;
  userContacts: Contact[];
  userAddressBooks: AddressBook[];
  page: number;
  contactsCount: number;
  baseUrl: string;
  search?: string;
})

Source from the content-addressed store, hash-verified

80}
81
82function defaultHtmlContent({ addressBookId, userContacts, userAddressBooks, page, contactsCount, baseUrl, search }: {
83 addressBookId: string;
84 userContacts: Contact[];
85 userAddressBooks: AddressBook[];
86 page: number;
87 contactsCount: number;
88 baseUrl: string;
89 search?: string;
90}) {
91 return html`
92 <main id="main">
93 <section id="contacts">
94 ${Loading()}
95 </section>
96 </main>
97
98 <script type="module">
99 import { h, render, Fragment } from 'preact';
100
101 // Imported files need some preact globals to work
102 window.h = h;
103 window.Fragment = Fragment;
104
105 import Contacts from '/public/components/contacts/Contacts.js';
106
107 const contactsElement = document.getElementById('contacts');
108
109 if (contactsElement) {
110 const contactsApp = h(Contacts, {
111 initialAddressBookId: ${JSON.stringify(addressBookId || [])},
112 initialContacts: ${JSON.stringify(userContacts || [])},
113 initialAddressBooks: ${JSON.stringify(userAddressBooks || [])},
114 baseUrl: ${JSON.stringify(baseUrl)},
115 page: ${JSON.stringify(page || 1)},
116 contactsCount: ${JSON.stringify(contactsCount || 0)},
117 search: ${JSON.stringify(search || '')},
118 });
119
120 render(contactsApp, contactsElement);
121
122 document.getElementById('loading')?.remove();
123 }
124 </script>
125 `;
126}
127
128export default page({
129 get,

Callers 1

getFunction · 0.70

Calls 1

LoadingFunction · 0.50

Tested by

no test coverage detected