Skip to content

Commit 6ebdc64

Browse files
authored
Donor flow when we don't have educators (#467)
* Donor flow when we don't have educators * fix tests
1 parent fb6efe0 commit 6ebdc64

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/Controller/Donor/RequestController.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,16 @@ public function options(Request $request): Response
110110
]);
111111

112112
if (!$haveWaitingTransactions) {
113-
$this->createTransactionService->create($user, $userDonor->getAmount(), $userDonor->getSchoolType());
114-
}
113+
$isCreated = $this->createTransactionService->create($user, $userDonor->getAmount(), $userDonor->getSchoolType());
114+
115+
if ($isCreated) {
116+
$this->addFlash('success', 'Kreirane su ti instrukcije za uplatu, ostalo je samo da ih uplatiš i potvrdiš uplatu.');
115117

116-
return $this->redirectToRoute('donor_transaction_list');
118+
return $this->redirectToRoute('donor_transaction_list');
119+
}
120+
121+
$this->addFlash('info', 'Trenutno nema nastavnika kojima je potrebno uplatiti novac. Čim bude bilo potrebe biće ti napravljene instrukcije za uplatu i dobićeš obaveštenje na email.');
122+
}
117123
}
118124

119125
$this->addFlash('success', 'Uspesno ste promenili podatke');

src/Controller/Donor/TransactionController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,14 @@ public function create(Request $request)
198198
$amount = $form->get('amount')->getData();
199199
$schoolType = $form->get('schoolType')->getData();
200200

201-
$this->createTransactionService->create($user, $amount, $schoolType);
202-
$this->addFlash('success', 'Kreirane su ti instrukcije za uplatu, ostalo je samo da ih uplatiš i potvrdiš uplatu.');
201+
$isCreated = $this->createTransactionService->create($user, $amount, $schoolType);
202+
if ($isCreated) {
203+
$this->addFlash('success', 'Kreirane su ti instrukcije za uplatu, ostalo je samo da ih uplatiš i potvrdiš uplatu.');
203204

204-
return $this->redirectToRoute('donor_transaction_list');
205+
return $this->redirectToRoute('donor_transaction_list');
206+
}
207+
208+
$this->addFlash('info', 'Trenutno nema nastavnika kojima je potrebno uplatiti novac. Pokušaj kasnije kada se prijave novi nastavnici.');
205209
}
206210

207211
return $this->render('donor/transaction/create.html.twig', [

templates/flashes.html.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
</div>
2222
{% endfor %}
2323

24+
{% for message in app.flashes('info') %}
25+
<div role="alert" class="alert alert-info alert-soft mb-2">
26+
<span class="ti ti-exclamation-circle text-2xl"></span>
27+
<span>{{ message }}</span>
28+
</div>
29+
{% endfor %}
30+
2431
{% for email in app.flashes('unverified_user') %}
2532
<div role="alert" class="alert alert-warning mb-2">
2633
<span class="ti ti-exclamation-circle text-2xl"></span>

tests/Controller/Donor/RequestControllerTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,13 @@ public function testNewUserSubscribeAndRegistrationAndVerification(): void
176176
// Submit form
177177
$this->client->submit($form);
178178

179-
$this->client->followRedirect();
180179
$this->assertResponseIsSuccessful();
181180

182181
// Check are user donor saved
183182
$userDonor = $this->userDonorRepository->findOneBy(['user' => $user]);
184183
$this->assertEquals(10000, $userDonor->getAmount());
185184
$this->assertEquals(UserDonor::SCHOOL_TYPE_ALL, $userDonor->getSchoolType());
186185

187-
// Check are user redirected to right page
188-
$this->assertStringContainsString('/instrukcije-za-uplatu', $this->client->getRequest()->getUri());
189-
190186
// Try to unsubscribe
191187
$this->client->request('GET', '/mesecna-donacija');
192188
$crawler = new Crawler($this->client->getResponse()->getContent());
@@ -278,12 +274,6 @@ public function testNewUserOnetimeAndRegistrationAndVerification(): void
278274
// Submit form
279275
$this->client->submit($form);
280276

281-
$this->client->followRedirect();
282-
$this->assertResponseIsSuccessful();
283-
284-
// Check are user redirected to right page
285-
$this->assertStringContainsString('/instrukcije-za-uplatu', $this->client->getRequest()->getUri());
286-
287277
$userDonor = $this->userDonorRepository->findOneBy(['user' => $user]);
288278
$this->assertNull($userDonor);
289279
}

0 commit comments

Comments
 (0)