Skip to content

Commit

Permalink
realese first plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
iietmoon committed Jun 26, 2023
1 parent a57225e commit 2dedc4c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion admin/src/pages/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { template_1 } from '../../../../services/templates/custom';

type IsVisible = boolean;
type IsReady = boolean;
type IsOnSending = boolean;
type SendButton = string;
type Expanded = boolean;
type CurrentStep = number;
type NextStepActive = boolean;
Expand All @@ -22,6 +24,8 @@ const Homepage: React.FC = () => {
const [emailingTraces, setEmailingTraces]: any = useState([])
const [isVisible, setIsVisible] = useState<IsVisible>(false);
const [isReady, setIsReady] = useState<IsReady>(false);
const [isOnSending, setIsOnSending] = useState<IsOnSending>(false);
const [sendButton, setSendButton] = useState<SendButton>('Envoyer maintenant')
const [expanded, setExpanded] = useState<Expanded>(false)
const [currentStep, setCurrentStep] = useState<CurrentStep>(1);
const [nextStepActive, setNextStepActive] = useState<NextStepActive>(false)
Expand Down Expand Up @@ -106,10 +110,13 @@ const Homepage: React.FC = () => {
// Logic to send a new email campaign goes here
// You can use the Strapi API to create and send emails
// Make sure to handle any necessary form inputs and validation
setIsOnSending(true)

if (currentOptionTemplate == 1) {
for (let i = 0; i < emailsList.length; i++) {
sendEmail(emailsList[i], template.template.subject, template.template.html)
.then(res => {

postEmailingTraces(emailsList[i], true)
.then(response => console.log(response))
.catch(error => console.error(error))
Expand All @@ -119,7 +126,15 @@ const Homepage: React.FC = () => {
.then(response => console.log(response))
.catch(error => console.error(error))
})
if(i+1 >= emailsList.length){
setSendButton('Campagne envoyée')
setTimeout(function(){
window.location.reload()
}, 2000)
}
}


}
else {
for (let i = 0; i < emailsList.length; i++) {
Expand All @@ -134,6 +149,12 @@ const Homepage: React.FC = () => {
.then(response => console.log(response))
.catch(error => console.error(error))
})
if(i+1 >= emailsList.length){
setSendButton('Campagne envoyée')
setTimeout(function(){
window.location.reload()
}, 2000)
}
}
}
};
Expand Down Expand Up @@ -275,7 +296,7 @@ const Homepage: React.FC = () => {
</Button>} endActions={<>
<Button disabled={currentStep == 1 ? true : false} variant="secondary" onClick={() => stepHandler(currentStep - 1)}>Étape précédente</Button>
<Button disabled={!nextStepActive} variant="secondary" onClick={() => stepHandler(currentStep + 1)}>L'étape suivante</Button>
<Button disabled={!isReady} onClick={() => handleSendEmailCampaign()}>Envoyer maintenant</Button>
<Button loading={isOnSending} disabled={!isReady} onClick={() => handleSendEmailCampaign()}>{sendButton}</Button>
</>} />
</ModalLayout>}
</>
Expand Down

0 comments on commit 2dedc4c

Please sign in to comment.