({
currentCommunity,
api,
}: {
currentCommunity: SerializedAccount;
api: ApiClient;
})
| 14 | import ConfirmationModal from '@/ConfirmationModal'; |
| 15 | |
| 16 | export default function MatrixView({ |
| 17 | currentCommunity, |
| 18 | api, |
| 19 | }: { |
| 20 | currentCommunity: SerializedAccount; |
| 21 | api: ApiClient; |
| 22 | }) { |
| 23 | const [modal, setModal] = useState(false); |
| 24 | const [{ value: keys }, callback] = useAsyncFn(() => |
| 25 | api.getIntegrationMatrix({ accountId: currentCommunity.id }) |
| 26 | ); |
| 27 | |
| 28 | useEffect(() => { |
| 29 | callback(); |
| 30 | }, []); |
| 31 | |
| 32 | return ( |
| 33 | <div className={styles.container}> |
| 34 | <StickyHeader className={styles.header}> |
| 35 | <div className={styles.title}>Matrix integration</div> |
| 36 | </StickyHeader> |
| 37 | |
| 38 | <div className={styles.content}> |
| 39 | {!keys ? ( |
| 40 | <div className={styles.italic}>Loading...</div> |
| 41 | ) : keys?.length ? ( |
| 42 | <table className={styles.table}> |
| 43 | <tr className={styles.tr}> |
| 44 | <th>Server</th> |
| 45 | <th>Enabled</th> |
| 46 | <th>Created</th> |
| 47 | <th>Updated</th> |
| 48 | <th></th> |
| 49 | </tr> |
| 50 | <tbody className={styles.tbody}> |
| 51 | {keys.map((k) => { |
| 52 | return ( |
| 53 | <tr key={k.id}> |
| 54 | <td>{k.matrixUrl}</td> |
| 55 | <td> |
| 56 | <div className={styles.toggle}> |
| 57 | <Toggle |
| 58 | checked={k.enabled} |
| 59 | onChange={async (val) => { |
| 60 | try { |
| 61 | await api.updateIntegrationMatrix({ |
| 62 | accountId: currentCommunity.id, |
| 63 | enabled: val, |
| 64 | id: k.id, |
| 65 | }); |
| 66 | await callback(); |
| 67 | } catch (error) { |
| 68 | handleError(error); |
| 69 | } |
| 70 | }} |
| 71 | /> |
| 72 | </div> |
| 73 | </td> |
nothing calls this directly
no test coverage detected