Skip to content

Commit 5249993

Browse files
authored
Merge pull request #410 from HiEventsDev/develop
main <- develop
2 parents 347e049 + cfcc06f commit 5249993

File tree

7 files changed

+80
-70
lines changed

7 files changed

+80
-70
lines changed

.github/workflows/deploy.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ on:
55
branches:
66
- main
77
- develop
8-
pull_request:
9-
types: [closed]
10-
branches:
11-
- main
12-
- develop
138
workflow_dispatch:
149
inputs:
1510
environment:
@@ -30,8 +25,6 @@ jobs:
3025
backend:
3126
name: Deploy Backend
3227
runs-on: ubuntu-latest
33-
# Only run this job when a PR is merged (not when closed without merging)
34-
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true
3528

3629
steps:
3730
- uses: actions/checkout@v3
@@ -67,7 +60,7 @@ jobs:
6760
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
6861
echo "VAPOR_ENV=${{ github.event.inputs.environment }}" >> "$GITHUB_ENV"
6962
echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
70-
elif [[ "${{ github.base_ref }}" == "develop" || "${{ github.ref_name }}" == "develop" ]]; then
63+
elif [[ "${{ github.ref_name }}" == "develop" ]]; then
7164
echo "VAPOR_ENV=staging" >> "$GITHUB_ENV"
7265
echo "TEST_MODE=false" >> "$GITHUB_ENV"
7366
else
@@ -99,8 +92,6 @@ jobs:
9992
name: Deploy Frontend
10093
runs-on: ubuntu-latest
10194
needs: backend
102-
# Only run this job when a PR is merged (not when closed without merging)
103-
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true
10495

10596
steps:
10697
- uses: actions/checkout@v3
@@ -114,7 +105,7 @@ jobs:
114105
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
115106
fi
116107
echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
117-
elif [[ "${{ github.base_ref }}" == "develop" || "${{ github.ref_name }}" == "develop" ]]; then
108+
elif [[ "${{ github.ref_name }}" == "develop" ]]; then
118109
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_STAGING_APP_ID }}" >> "$GITHUB_ENV"
119110
echo "TEST_MODE=false" >> "$GITHUB_ENV"
120111
else

backend/app/Exports/OrdersExport.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function headings(): array
5858
__('Currency'),
5959
__('Created At'),
6060
__('Public ID'),
61-
__('Payment Gateway'),
61+
__('Payment Provider'),
6262
__('Is Partially Refunded'),
6363
__('Is Fully Refunded'),
6464
__('Is Free Order'),
@@ -101,7 +101,7 @@ public function map($order): array
101101
$order->getCurrency(),
102102
Carbon::parse($order->getCreatedAt())->format('Y-m-d H:i:s'),
103103
$order->getPublicId(),
104-
$order->getPaymentGateway(),
104+
$order->getPaymentProvider(),
105105
$order->isPartiallyRefunded(),
106106
$order->isFullyRefunded(),
107107
$order->isFreeOrder(),

backend/app/Http/Kernel.php

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use HiEvents\Http\Middleware\TrimStrings;
1313
use HiEvents\Http\Middleware\TrustProxies;
1414
use HiEvents\Http\Middleware\ValidateSignature;
15+
use HiEvents\Http\Middleware\VaporBinaryResponseMiddleware;
1516
use HiEvents\Http\Middleware\VerifyCsrfToken;
1617
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
1718
use Illuminate\Auth\Middleware\Authorize;
@@ -47,6 +48,7 @@ class Kernel extends HttpKernel
4748
TrimStrings::class,
4849
ConvertEmptyStringsToNull::class,
4950
HandleDeprecatedTimezones::class,
51+
VaporBinaryResponseMiddleware::class,
5052
];
5153

5254
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace HiEvents\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Http\Request;
7+
use Symfony\Component\HttpFoundation\BinaryFileResponse;
8+
use Symfony\Component\HttpFoundation\StreamedResponse;
9+
10+
class VaporBinaryResponseMiddleware
11+
{
12+
public function handle(Request $request, Closure $next): mixed
13+
{
14+
$response = $next($request);
15+
16+
if ($response instanceof BinaryFileResponse || $response instanceof StreamedResponse) {
17+
$response->headers->set('X-Vapor-Base64-Encode', 'True');
18+
}
19+
20+
return $response;
21+
}
22+
}

backend/app/Services/Application/Handlers/Product/EditProductHandler.php

-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ private function updateProduct(UpsertProductDTO $productsData, array $where): Pr
9494
attributes: [
9595
'title' => $productsData->title,
9696
'type' => $productsData->type->name,
97-
'order' => $this->productOrderingService->getOrderForNewProduct(
98-
eventId: $productsData->event_id,
99-
productCategoryId: $productCategory->getId(),
100-
),
10197
'sale_start_date' => $productsData->sale_start_date
10298
? DateHelper::convertToUTC($productsData->sale_start_date, $event->getTimezone())
10399
: null,

frontend/src/components/routes/event/orders.tsx

+50-51
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
import React, {useEffect, useState} from "react";
2-
import { useParams } from "react-router";
3-
import { Button } from "@mantine/core";
4-
import { IconDownload } from "@tabler/icons-react";
5-
import { t } from "@lingui/macro";
6-
import { useGetEvent } from "../../../queries/useGetEvent";
7-
import { useGetEventOrders } from "../../../queries/useGetEventOrders";
8-
import { PageTitle } from "../../common/PageTitle";
9-
import { PageBody } from "../../common/PageBody";
10-
import { OrdersTable } from "../../common/OrdersTable";
11-
import { SearchBarWrapper } from "../../common/SearchBar";
12-
import { Pagination } from "../../common/Pagination";
13-
import { ToolBar } from "../../common/ToolBar";
14-
import { useFilterQueryParamSync } from "../../../hooks/useFilterQueryParamSync";
15-
import { IdParam, QueryFilters, QueryFilterOperator } from "../../../types";
16-
import { TableSkeleton } from "../../common/TableSkeleton";
17-
import { orderClient } from "../../../api/order.client";
18-
import { downloadBinary } from "../../../utilites/download";
19-
import { showError } from "../../../utilites/notifications";
1+
import React, {useState} from "react";
2+
import {useParams} from "react-router";
3+
import {Button} from "@mantine/core";
4+
import {IconDownload} from "@tabler/icons-react";
5+
import {t} from "@lingui/macro";
6+
import {useGetEvent} from "../../../queries/useGetEvent";
7+
import {useGetEventOrders} from "../../../queries/useGetEventOrders";
8+
import {PageTitle} from "../../common/PageTitle";
9+
import {PageBody} from "../../common/PageBody";
10+
import {OrdersTable} from "../../common/OrdersTable";
11+
import {SearchBarWrapper} from "../../common/SearchBar";
12+
import {Pagination} from "../../common/Pagination";
13+
import {ToolBar} from "../../common/ToolBar";
14+
import {useFilterQueryParamSync} from "../../../hooks/useFilterQueryParamSync";
15+
import {IdParam, QueryFilterOperator, QueryFilters} from "../../../types";
16+
import {TableSkeleton} from "../../common/TableSkeleton";
17+
import {orderClient} from "../../../api/order.client";
18+
import {downloadBinary} from "../../../utilites/download";
2019
import {FilterModal, FilterOption} from "../../common/FilterModal";
2120
import {withLoadingNotification} from "../../../utilites/withLoadingNotification.tsx";
2221

2322
const orderStatuses = [
24-
{ label: t`Completed`, value: 'COMPLETED' },
25-
{ label: t`Cancelled`, value: 'CANCELLED' },
26-
{ label: t`Awaiting Offline Payment`, value: 'AWAITING_OFFLINE_PAYMENT' },
23+
{label: t`Completed`, value: 'COMPLETED'},
24+
{label: t`Cancelled`, value: 'CANCELLED'},
25+
{label: t`Awaiting Offline Payment`, value: 'AWAITING_OFFLINE_PAYMENT'},
2726
];
2827

2928
const refundStatuses = [
30-
{ label: t`Refunded`, value: 'REFUNDED' },
31-
{ label: t`Partially Refunded`, value: 'PARTIALLY_REFUNDED' },
29+
{label: t`Refunded`, value: 'REFUNDED'},
30+
{label: t`Partially Refunded`, value: 'PARTIALLY_REFUNDED'},
3231
];
3332

3433
export const Orders: React.FC = () => {
35-
const { eventId } = useParams<{ eventId: string }>();
36-
const { data: event } = useGetEvent(eventId);
34+
const {eventId} = useParams<{ eventId: string }>();
35+
const {data: event} = useGetEvent(eventId);
3736
const [searchParams, setSearchParams] = useFilterQueryParamSync();
3837
const ordersQuery = useGetEventOrders(eventId, searchParams as QueryFilters);
3938
const orders = ordersQuery?.data?.data;
@@ -61,10 +60,10 @@ export const Orders: React.FC = () => {
6160
filterFields: {
6261
...(searchParams.filterFields || {}),
6362
status: values.status?.length > 0
64-
? { operator: QueryFilterOperator.In, value: values.status }
63+
? {operator: QueryFilterOperator.In, value: values.status}
6564
: undefined,
6665
refund_status: values.refund_status?.length > 0
67-
? { operator: QueryFilterOperator.In, value: values.refund_status }
66+
? {operator: QueryFilterOperator.In, value: values.refund_status}
6867
: undefined
6968
}
7069
};
@@ -82,26 +81,26 @@ export const Orders: React.FC = () => {
8281

8382
const handleExport = async (eventId: IdParam) => {
8483
await withLoadingNotification(async () => {
85-
setDownloadPending(true);
86-
const blob = await orderClient.exportOrders(eventId);
87-
downloadBinary(blob, 'orders.xlsx');
88-
},
89-
{
90-
loading: {
91-
title: t`Exporting Orders`,
92-
message: t`Please wait while we prepare your orders for export...`
93-
},
94-
success: {
95-
title: t`Orders Exported`,
96-
message: t`Your orders have been exported successfully.`,
97-
onRun: () => setDownloadPending(false)
84+
setDownloadPending(true);
85+
const blob = await orderClient.exportOrders(eventId);
86+
downloadBinary(blob, 'orders.xlsx');
9887
},
99-
error: {
100-
title: t`Failed to export orders`,
101-
message: t`Please try again.`,
102-
onRun: () => setDownloadPending(false)
103-
}
104-
});
88+
{
89+
loading: {
90+
title: t`Exporting Orders`,
91+
message: t`Please wait while we prepare your orders for export...`
92+
},
93+
success: {
94+
title: t`Orders Exported`,
95+
message: t`Your orders have been exported successfully.`,
96+
onRun: () => setDownloadPending(false)
97+
},
98+
error: {
99+
title: t`Failed to export orders`,
100+
message: t`Please try again.`,
101+
onRun: () => setDownloadPending(false)
102+
}
103+
});
105104
};
106105

107106
const currentFilters = {
@@ -133,7 +132,7 @@ export const Orders: React.FC = () => {
133132
>
134133
<Button
135134
onClick={() => handleExport(eventId)}
136-
rightSection={<IconDownload size={14} />}
135+
rightSection={<IconDownload size={14}/>}
137136
color="green"
138137
loading={downloadPending}
139138
size="sm"
@@ -142,16 +141,16 @@ export const Orders: React.FC = () => {
142141
</Button>
143142
</ToolBar>
144143

145-
<TableSkeleton isVisible={!orders || ordersQuery.isFetching} />
144+
<TableSkeleton isVisible={!orders || ordersQuery.isFetching}/>
146145

147146
{orders && event && (
148-
<OrdersTable event={event} orders={orders} />
147+
<OrdersTable event={event} orders={orders}/>
149148
)}
150149

151150
{!!orders?.length && (
152151
<Pagination
153152
value={searchParams.pageNumber}
154-
onChange={(value) => setSearchParams({ pageNumber: value })}
153+
onChange={(value) => setSearchParams({pageNumber: value})}
155154
total={Number(pagination?.last_page)}
156155
/>
157156
)}

misc/k6/event-hompage-load-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { check, sleep } from 'k6';
33

44
export let options = {
55
vus: 50,
6-
duration: '60s', // Using '60s' instead of '60000' for clarity
6+
duration: '5s',
77
};
88

99
export default function () {
10-
let res = http.get('https://api.hi.events/public/events/1', {
10+
let res = http.get('https://api.hi.events/public/events/2', {
1111
headers: {
1212
'Accept': 'application/json',
1313
},

0 commit comments

Comments
 (0)