@@ -2,27 +2,30 @@ import { type FC, useState } from 'react';
22
33import { c } from 'ttag' ;
44
5- import { patchOrganizationImporter } from '@proton/activation/src/api/api' ;
6- import { type ApiImporterOrganization , ApiImporterOrganizationState } from '@proton/activation/src/api/api.interface' ;
5+ import { ApiImporterOrganizationState } from '@proton/activation/src/api/api.interface' ;
76import { Banner } from '@proton/atoms/Banner/Banner' ;
87import { Button } from '@proton/atoms/Button/Button' ;
9- import Checkbox from '@proton/components/components/input/Checkbox' ;
10- import { useSilentApi } from '@proton/components/hooks/useSilentApi' ;
8+ import {
9+ BorderedContainer ,
10+ BorderedContainerItem ,
11+ } from '@proton/components/components/BorderedStackedGroup/BorderedContainer' ;
1112import useLoading from '@proton/hooks/useLoading' ;
1213import { IcExclamationCircleFilled } from '@proton/icons/icons/IcExclamationCircleFilled' ;
14+ import { useDispatch } from '@proton/redux-shared-store/sharedProvider' ;
1315import { BRAND_NAME } from '@proton/shared/lib/constants' ;
1416import { MX_STATE } from '@proton/shared/lib/interfaces' ;
1517
18+ import { completeMigration } from '../../thunk' ;
1619import type { MigrationModel } from '../../types' ;
1720import { useProviderUsers } from '../../useProviderUsers' ;
18- import { LazyLottie } from '../LazyLottie ' ;
21+ import MigratingModal from '../MigrationAssistant/MigratingModal ' ;
1922import DNSGroupRecords , { type DNSGroup } from './DNSGroupRecords' ;
2023import type { StepComponentProps } from './MigrationSetup' ;
2124
2225const StepFinal : FC < StepComponentProps > = ( { model : migrationConfiguration } ) => {
2326 const model = migrationConfiguration as MigrationModel ;
27+ const dispatch = useDispatch ( ) ;
2428
25- const api = useSilentApi ( ) ;
2629 const [ providerUsers ] = useProviderUsers ( model . domainName ) ;
2730 const [ loading , withLoading ] = useLoading ( ) ;
2831 const [ confirmed , setConfirmed ] = useState ( false ) ;
@@ -32,14 +35,14 @@ const StepFinal: FC<StepComponentProps> = ({ model: migrationConfiguration }) =>
3235 return ;
3336 }
3437
35- await api < ApiImporterOrganization > (
36- patchOrganizationImporter ( model . importerOrganizationId ! , {
37- State : ApiImporterOrganizationState . COMPLETED ,
38+ const { State : state } = await dispatch (
39+ completeMigration ( {
40+ importerOrganizationId : model . importerOrganizationId ,
41+ providerUsers : providerUsers ?? [ ] ,
3842 } )
39- )
40- . then ( ( { State } ) => State )
41- . catch ( ( ) => model . state )
42- . then ( ( state ) => model . update ( { state } ) ) ;
43+ ) . unwrap ( ) ;
44+
45+ model . update ( { state } ) ;
4346 } ;
4447
4548 const handleSaveAndExit = ( ) => withLoading ( handleFinalize ( ) ) ;
@@ -94,7 +97,7 @@ const StepFinal: FC<StepComponentProps> = ({ model: migrationConfiguration }) =>
9497 size = "medium"
9598 className = "rounded-lg"
9699 >
97- { c ( 'Action' ) . t `Save & exit ` }
100+ { c ( 'Action' ) . t `Save & finish ` }
98101 </ Button >
99102 </ div >
100103 </ div >
@@ -119,26 +122,30 @@ const StepFinal: FC<StepComponentProps> = ({ model: migrationConfiguration }) =>
119122 { c ( 'BOSS' )
120123 . t `You're almost done, you need to configure your domain to receive your emails directly on ${ BRAND_NAME } . Once confirmed, your team will stop receiving new emails on Gmail and the migration will be completed.` }
121124 </ p >
122- < LazyLottie
123- style = { { padding : '0 10rem' } }
124- autoPlay
125- getAnimationData = { ( ) => import ( '../../animations/providerSwitch.json' ) }
126- loop = { true }
127- />
128125 < p className = "color-weak" > { c ( 'BOSS' )
129126 . t `Copy the below code and paste it in the DNS section of your domain host.` } </ p >
130127 < DNSGroupRecords group = { group } />
131- < Checkbox
132- id = "confirm-mx-records"
133- className = "items-center text-normal"
134- checked = { confirmed }
135- onChange = { ( e ) => setConfirmed ( e . target . checked ) }
136- >
137- < div className = "px-2" >
138- < p className = "m-0" > { c ( 'Label' ) . t `Confirm MX records added` } </ p >
139- < span className = "color-weak text-sm" > { c ( 'Info' ) . t `Required to proceed to the next step` } </ span >
140- </ div >
141- </ Checkbox >
128+ < BorderedContainer className = "mb-4 mt-2" >
129+ < BorderedContainerItem
130+ className = "flex flex-row flex-nowrap items-center gap-2 justify-space-between"
131+ paddingClassName = "py-2 px-5"
132+ >
133+ < div >
134+ < p className = "m-0 text-semibold" > { c ( 'Label' ) . t `Confirm MX records added` } </ p >
135+ < span className = "color-weak text-sm" > { c ( 'Info' ) . t `Required to complete the migration` } </ span >
136+ </ div >
137+
138+ < Button
139+ disabled = { confirmed }
140+ color = "norm"
141+ className = "text-semibold rounded-lg"
142+ size = "medium"
143+ onClick = { ( ) => setConfirmed ( true ) }
144+ > { c ( 'BOSS' ) . t `Confirm` } </ Button >
145+ </ BorderedContainerItem >
146+ </ BorderedContainer >
147+
148+ { loading && < MigratingModal variant = "completing" /> }
142149 </ div >
143150 ) ;
144151} ;
0 commit comments