メインコンテンツまでスキップ

💡 例

🎯 使用パターン

import {MatchingAppDomain} from '@nodeblocks/matching-app-domain'
import {SignInBlock} from '@nodeblocks/frontend-signin-block';
<MatchingAppDomain
applicationType={['admin']}
defaultWizardPage="base-info"
loggedInRedirectUrl="/users"
logoutRedirectUrl="/"
needsPaymentSetupRedirect="/payment-setup"
notLoggedInRedirect="/login"
organizationRegistrationNotCompleteRoute="/setup"
pageSize={{
productsList: 20,
ordersList: 15,
usersList: 25,
// ... すべてのリストページサイズをカスタマイズ
}}
refreshTokenIntervalInMilliseconds={300000} // 5分
sessionType="cookie" // または "token"
serviceEndpoints={{
auth: "/api/auth",
catalog: "/api/catalog",
// ... その他のAPIエンドポイント
}}
customRoutes={{
// カスタムルート定義
}}>
{({state, middleware, updateState}) => {
const onLogin = async (email: string, password: string) => {
try {
const res = await middleware.onActionLogin({email, password});
if (res.ok) {
middleware.onSuccessLogin(state.intendedUrl ? state.intendedUrl : '/home');
return;
}
console.error(res.error);
} catch (error) {
console.error(error);
}
};
let Page: React.ReactNode;
switch (state.currentPage) {
case 'login': {
Page = <SignInBlock onSignIn={onLogin} />;
break;
}
case 'home': {
Page = <div>ホームページ</div>;
break;
}
default:
Page = <div>見つかりません</div>
}
return <React.Fragment>{Page}</React.Fragment>;
}}
</MatchingAppDomain>