Update handleProfileSubmit
This commit is contained in:
parent
8636d37d29
commit
e6b9f58cea
44
src/App.tsx
44
src/App.tsx
@ -11,7 +11,7 @@ import UserStore from './sdk/UserStrore';
|
||||
import Iframe from './sdk/Iframe'
|
||||
import BlockchainViewer from './components/ProcessesViewer';
|
||||
import FolderModal from './components/FolderModal';
|
||||
import type { ProfileCreated, ProfileData } from './sdk/models/ProfileData'
|
||||
import { ProfilePrivateFields, setDefaultProfileRoles, type ProfileCreated, type ProfileData } from './sdk/models/ProfileData'
|
||||
import { FolderPrivateFields, setDefaultFolderRoles, type FolderCreated, type FolderData } from './sdk/models/FolderData'
|
||||
|
||||
const iframeUrl = 'https://dev3.4nkweb.com'
|
||||
@ -66,7 +66,7 @@ function App() {
|
||||
})
|
||||
});
|
||||
}
|
||||
}, [isConnected, userPairingId]);
|
||||
}, [isConnected, userPairingId, processes]);
|
||||
|
||||
// Gestionnaire pour afficher la modale de connexion
|
||||
const handleLogin = useCallback(() => {
|
||||
@ -108,21 +108,33 @@ function App() {
|
||||
}, []);
|
||||
|
||||
// Gestionnaire pour soumettre les données du profil
|
||||
const handleProfileSubmit = useCallback((profileData: ProfileData) => {
|
||||
// Ajouter le validator fixe aux données du profil
|
||||
const completeProfileData = {
|
||||
...profileData,
|
||||
validator: '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0'
|
||||
};
|
||||
|
||||
MessageBus.getInstance(iframeUrl).createProfile(completeProfileData).then((_profileCreated: ProfileCreated) => {
|
||||
MessageBus.getInstance(iframeUrl).getProcesses().then((processes: any) => {
|
||||
setProcesses(processes);
|
||||
const handleProfileSubmit = useCallback((profileData: ProfileData, validatorId: string | null, ownerId: string | null) => {
|
||||
if (userPairingId !== null) {
|
||||
if (validatorId === null && ownerId === null) {
|
||||
console.error("No validator or owner ID provided");
|
||||
return;
|
||||
}
|
||||
const messageBus = MessageBus.getInstance(iframeUrl);
|
||||
if (validatorId === null) {
|
||||
validatorId = userPairingId;
|
||||
} else if (ownerId === null) {
|
||||
ownerId = userPairingId;
|
||||
}
|
||||
const roles = setDefaultProfileRoles([ownerId!], validatorId!);
|
||||
const profilePrivateFields = ProfilePrivateFields;
|
||||
messageBus.createProfile(profileData, profilePrivateFields, roles).then((_profileCreated: ProfileCreated) => {
|
||||
messageBus.notifyProcessUpdate(_profileCreated.processId, _profileCreated.process.states[0].state_id).then(() => {
|
||||
messageBus.validateState(_profileCreated.processId, _profileCreated.process.states[0].state_id).then((_updatedProcess: any) => {
|
||||
messageBus.getProcesses().then((processes: any) => {
|
||||
setProcesses(processes);
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
setShowProfileModal(false);
|
||||
}, []);
|
||||
setShowProfileModal(false);
|
||||
}
|
||||
}, [userPairingId]);
|
||||
|
||||
// Gestionnaire pour soumettre les données du dossier
|
||||
const handleFolderSubmit = useCallback((folderData: FolderData) => {
|
||||
@ -197,7 +209,7 @@ function App() {
|
||||
<ProfileModal
|
||||
isOpen={showProfileModal}
|
||||
onClose={handleCloseProfileModal}
|
||||
onSubmit={handleProfileSubmit}
|
||||
onSubmit={(profileData: ProfileData, validatorId: string | null, ownerId: string | null) => handleProfileSubmit(profileData, validatorId, ownerId)}
|
||||
/>
|
||||
)}
|
||||
{showFolderModal && (
|
||||
|
Loading…
x
Reference in New Issue
Block a user