added default props util
This commit is contained in:
parent
ed5fe776fc
commit
3f8797d673
|
|
@ -5,6 +5,8 @@ import { ParticipantsProvider } from '@dailyjs/shared/contexts/ParticipantsProvi
|
||||||
import { TracksProvider } from '@dailyjs/shared/contexts/TracksProvider';
|
import { TracksProvider } from '@dailyjs/shared/contexts/TracksProvider';
|
||||||
import { UIStateProvider } from '@dailyjs/shared/contexts/UIStateProvider';
|
import { UIStateProvider } from '@dailyjs/shared/contexts/UIStateProvider';
|
||||||
import { WaitingRoomProvider } from '@dailyjs/shared/contexts/WaitingRoomProvider';
|
import { WaitingRoomProvider } from '@dailyjs/shared/contexts/WaitingRoomProvider';
|
||||||
|
import getDemoProps from '@dailyjs/shared/lib/demoProps';
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import App from '../components/App';
|
import App from '../components/App';
|
||||||
import { Intro, NotConfigured } from '../components/Intro';
|
import { Intro, NotConfigured } from '../components/Intro';
|
||||||
|
|
@ -20,12 +22,12 @@ import { Intro, NotConfigured } from '../components/Intro';
|
||||||
export default function Index({
|
export default function Index({
|
||||||
domain,
|
domain,
|
||||||
isConfigured = false,
|
isConfigured = false,
|
||||||
predefinedRoom = false,
|
predefinedRoom = '',
|
||||||
asides,
|
asides,
|
||||||
customTrayComponent,
|
customTrayComponent,
|
||||||
customAppComponent,
|
customAppComponent,
|
||||||
}) {
|
}) {
|
||||||
const [roomName, setRoomName] = useState(predefinedRoom || '');
|
const [roomName, setRoomName] = useState(predefinedRoom);
|
||||||
const [fetchingToken, setFetchingToken] = useState(false);
|
const [fetchingToken, setFetchingToken] = useState(false);
|
||||||
const [token, setToken] = useState();
|
const [token, setToken] = useState();
|
||||||
const [tokenError, setTokenError] = useState();
|
const [tokenError, setTokenError] = useState();
|
||||||
|
|
@ -117,7 +119,7 @@ export default function Index({
|
||||||
|
|
||||||
Index.propTypes = {
|
Index.propTypes = {
|
||||||
isConfigured: PropTypes.bool.isRequired,
|
isConfigured: PropTypes.bool.isRequired,
|
||||||
predefinedRoom: PropTypes.bool,
|
predefinedRoom: PropTypes.string,
|
||||||
domain: PropTypes.string,
|
domain: PropTypes.string,
|
||||||
asides: PropTypes.arrayOf(PropTypes.func),
|
asides: PropTypes.arrayOf(PropTypes.func),
|
||||||
customTrayComponent: PropTypes.node,
|
customTrayComponent: PropTypes.node,
|
||||||
|
|
@ -125,19 +127,9 @@ Index.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
// Check that both domain and key env vars are set
|
const defaultProps = getDemoProps();
|
||||||
const isConfigured =
|
|
||||||
!!process.env.DAILY_DOMAIN && !!process.env.DAILY_API_KEY;
|
|
||||||
|
|
||||||
// Have we predefined a room to use?
|
|
||||||
const predefinedRoom = process.env.DAILY_ROOM || false;
|
|
||||||
|
|
||||||
// Pass through domain as prop
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: defaultProps,
|
||||||
domain: process.env.DAILY_DOMAIN || null,
|
|
||||||
isConfigured,
|
|
||||||
predefinedRoom,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
export default function getDemoProps() {
|
||||||
|
return {
|
||||||
|
domain: process.env.DAILY_DOMAIN || null,
|
||||||
|
// Check that both domain and key env vars are set
|
||||||
|
isConfigured: !!process.env.DAILY_DOMAIN && !!process.env.DAILY_API_KEY,
|
||||||
|
// Have we predefined a room to use?
|
||||||
|
predefinedRoom: process.env.DAILY_ROOM || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import Index from '@dailyjs/basic-call/pages';
|
import Index from '@dailyjs/basic-call/pages';
|
||||||
|
import getDemoProps from '@dailyjs/shared/lib/demoProps';
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
// Check that both domain and key env vars are set
|
const defaultProps = getDemoProps();
|
||||||
const isConfigured =
|
|
||||||
!!process.env.DAILY_DOMAIN && !!process.env.DAILY_API_KEY;
|
|
||||||
|
|
||||||
// Pass through domain as prop
|
// Pass through domain as prop
|
||||||
return {
|
return {
|
||||||
props: {
|
props: defaultProps,
|
||||||
domain: process.env.DAILY_DOMAIN || null,
|
|
||||||
isConfigured,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue