Skip to content

Commit

Permalink
adjust main label on transaction item; store user email on transaction;
Browse files Browse the repository at this point in the history
  • Loading branch information
andreciornavei committed Mar 8, 2024
1 parent adf1ff3 commit 8a58749
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 9 deletions.
6 changes: 6 additions & 0 deletions backend/app/Domain/Entities/TransactionEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class TransactionEntity
{
private string $_id;
private string $user_id;
private string $user_email;
private string $user_username;
private int $factor;
private float $amount;
Expand Down Expand Up @@ -40,6 +41,11 @@ public function getUserId()
return $this->user_id;
}

public function getUserEmail()
{
return $this->user_email;
}

public function getUserUsername()
{
return $this->user_username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

class ICreateTransactionDto
{
private string $user_id;
private string $user_username;
private string $status;
private string | null $document;
private string $description;
private int $factor;
private float $amount;
private $user_id;
private $user_email;
private $user_username;
private $status;
private $document;
private $description;
private $factor;
private $amount;

public function __construct(array $data)
{
Expand All @@ -27,6 +28,11 @@ public function getUserId()
return $this->user_id ?? null;
}

public function getUserEmail()
{
return $this->user_email ?? null;
}

public function getUserUsername()
{
return $this->user_username ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TransactionCreateDto
private $amount;
private $document;
private $userId;
private $userEmail;
private $userUsername;
private $userBalance;

Expand Down Expand Up @@ -51,6 +52,11 @@ public function getUserId()
return $this->userId ?? null;
}

public function getUserEmail()
{
return $this->userEmail ?? null;
}

public function getUserUsername()
{
return $this->userUsername ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function handler(TransactionCreateDto $dto): UserEntity | TransactionEnti
'document' => $dto->getDocument(),
'amount' => $dto->getAmount(),
'user_id' => $dto->getUserId(),
'user_email' => $dto->getUserEmail(),
'user_username' => $dto->getUserUsername(),
];

Expand All @@ -42,6 +43,7 @@ public function handler(TransactionCreateDto $dto): UserEntity | TransactionEnti
]),
[
'user_id' => 'required|string',
'user_email' => 'required|string|email',
'user_username' => 'required|string',
'balance' => 'required|numeric',
'factor' => 'required|numeric|in:-1,1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handler(Request $request)
"amount" => $request->input("amount"),
"document" => $request->input("document"),
"userId" => $user->_id,
"userEmail" => $user->email,
"userUsername" => $user->username,
"userBalance" => $user->balance,
]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class EloquentCreateTransactionRepository implements ICreateTransactionRepositor
{
public function handler(ICreateTransactionDto $dto): TransactionEntity
{

$transaction = TransactionModel::create([
'factor' => $dto->getFactor(),
'amount' => $dto->getAmount(),
'description' => $dto->getDescription(),
'user_id' => $dto->getUserId(),
'user_email' => $dto->getUserEmail(),
'user_username' => $dto->getUserUsername(),
'document' => $dto->getDocument(),
'status' => $dto->getStatus(),
Expand Down
1 change: 1 addition & 0 deletions backend/app/Models/TransactionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TransactionModel extends Model
'amount',
'description',
'user_id',
'user_email',
'user_username',
'document',
'status',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/item-transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const ItemTransaction = ({
data,
href,
onClick,
labelField,
}: ItemTransactionProps): JSX.Element => {
const { palette } = useTheme()
const navigate = useNavigate()
Expand Down Expand Up @@ -42,7 +43,7 @@ export const ItemTransaction = ({
: []
}
>
{data.description}
{data[labelField || 'description']}
</Typography>
<Typography
variant="caption"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/item-transaction/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export type ItemTransactionProps = {
prevData?: TransactionEntity
href?: string
onClick?: (transaction: TransactionEntity) => void
labelField?: keyof TransactionEntity
}
6 changes: 5 additions & 1 deletion frontend/src/pages/depopsits_control/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const DepositsControlPageView = (): JSX.Element => {
loadingMessage="Loading pending checks..."
itemKey={(item: TransactionEntity) => item._id}
renderItem={(item: TransactionEntity) => (
<ItemTransaction data={item} href={`/deposits/${item._id}`} />
<ItemTransaction
data={item}
href={`/deposits/${item._id}`}
labelField="user_username"
/>
)}
handleFetch={handleFindTransactions}
/>
Expand Down

0 comments on commit 8a58749

Please sign in to comment.