-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: share qr code with tenant logo, retrieve tenant data and config…
… from api
- Loading branch information
Showing
9 changed files
with
221 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Tenant } from '@memori.ai/memori-api-client/dist/types'; | ||
|
||
const defaultTenant: Tenant = { | ||
id: 'app.twincreator.com', | ||
theme: 'twincreator', | ||
config: { | ||
name: 'Memori', | ||
showNewUser: false, | ||
requirePosition: false, | ||
}, | ||
}; | ||
|
||
export const getTenant = async ( | ||
tenantID: string, | ||
baseURL?: string | ||
): Promise<Tenant> => { | ||
const apiBaseUrl = baseURL | ||
? new URL( | ||
`${ | ||
baseURL.startsWith('http') | ||
? '' | ||
: baseURL.includes('localhost') | ||
? 'http://' | ||
: 'https://' | ||
}${baseURL}` | ||
).host | ||
: 'https://app.twincreator.com'; | ||
|
||
try { | ||
const response = await fetch(`${apiBaseUrl}/api/tenant/${tenantID}`); | ||
const { tenant } = await response.json(); | ||
|
||
if (!tenant) { | ||
return { | ||
...defaultTenant, | ||
tenantID, | ||
}; | ||
} | ||
|
||
return tenant; | ||
} catch (error) { | ||
return { | ||
...defaultTenant, | ||
tenantID, | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters