Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ on:
branches:
- main
- develop
pull_request:
types: [closed]
branches:
- main
- develop
workflow_dispatch:
inputs:
environment:
Expand All @@ -30,8 +25,6 @@ jobs:
backend:
name: Deploy Backend
runs-on: ubuntu-latest
# Only run this job when a PR is merged (not when closed without merging)
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true

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

steps:
- uses: actions/checkout@v3
Expand All @@ -114,7 +105,7 @@ jobs:
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
fi
echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
elif [[ "${{ github.base_ref }}" == "develop" || "${{ github.ref_name }}" == "develop" ]]; then
elif [[ "${{ github.ref_name }}" == "develop" ]]; then
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_STAGING_APP_ID }}" >> "$GITHUB_ENV"
echo "TEST_MODE=false" >> "$GITHUB_ENV"
else
Expand Down
4 changes: 2 additions & 2 deletions backend/app/Exports/OrdersExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function headings(): array
__('Currency'),
__('Created At'),
__('Public ID'),
__('Payment Gateway'),
__('Payment Provider'),
__('Is Partially Refunded'),
__('Is Fully Refunded'),
__('Is Free Order'),
Expand Down Expand Up @@ -101,7 +101,7 @@ public function map($order): array
$order->getCurrency(),
Carbon::parse($order->getCreatedAt())->format('Y-m-d H:i:s'),
$order->getPublicId(),
$order->getPaymentGateway(),
$order->getPaymentProvider(),
$order->isPartiallyRefunded(),
$order->isFullyRefunded(),
$order->isFreeOrder(),
Expand Down
2 changes: 2 additions & 0 deletions backend/app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use HiEvents\Http\Middleware\TrimStrings;
use HiEvents\Http\Middleware\TrustProxies;
use HiEvents\Http\Middleware\ValidateSignature;
use HiEvents\Http\Middleware\VaporBinaryResponseMiddleware;
use HiEvents\Http\Middleware\VerifyCsrfToken;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Auth\Middleware\Authorize;
Expand Down Expand Up @@ -47,6 +48,7 @@ class Kernel extends HttpKernel
TrimStrings::class,
ConvertEmptyStringsToNull::class,
HandleDeprecatedTimezones::class,
VaporBinaryResponseMiddleware::class,
];

/**
Expand Down
22 changes: 22 additions & 0 deletions backend/app/Http/Middleware/VaporBinaryResponseMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace HiEvents\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;

class VaporBinaryResponseMiddleware
{
public function handle(Request $request, Closure $next): mixed
{
$response = $next($request);

if ($response instanceof BinaryFileResponse || $response instanceof StreamedResponse) {
$response->headers->set('X-Vapor-Base64-Encode', 'True');
}

return $response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ private function updateProduct(UpsertProductDTO $productsData, array $where): Pr
attributes: [
'title' => $productsData->title,
'type' => $productsData->type->name,
'order' => $this->productOrderingService->getOrderForNewProduct(
eventId: $productsData->event_id,
productCategoryId: $productCategory->getId(),
),
'sale_start_date' => $productsData->sale_start_date
? DateHelper::convertToUTC($productsData->sale_start_date, $event->getTimezone())
: null,
Expand Down
101 changes: 50 additions & 51 deletions frontend/src/components/routes/event/orders.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
import React, {useEffect, useState} from "react";
import { useParams } from "react-router";
import { Button } from "@mantine/core";
import { IconDownload } from "@tabler/icons-react";
import { t } from "@lingui/macro";
import { useGetEvent } from "../../../queries/useGetEvent";
import { useGetEventOrders } from "../../../queries/useGetEventOrders";
import { PageTitle } from "../../common/PageTitle";
import { PageBody } from "../../common/PageBody";
import { OrdersTable } from "../../common/OrdersTable";
import { SearchBarWrapper } from "../../common/SearchBar";
import { Pagination } from "../../common/Pagination";
import { ToolBar } from "../../common/ToolBar";
import { useFilterQueryParamSync } from "../../../hooks/useFilterQueryParamSync";
import { IdParam, QueryFilters, QueryFilterOperator } from "../../../types";
import { TableSkeleton } from "../../common/TableSkeleton";
import { orderClient } from "../../../api/order.client";
import { downloadBinary } from "../../../utilites/download";
import { showError } from "../../../utilites/notifications";
import React, {useState} from "react";
import {useParams} from "react-router";
import {Button} from "@mantine/core";
import {IconDownload} from "@tabler/icons-react";
import {t} from "@lingui/macro";
import {useGetEvent} from "../../../queries/useGetEvent";
import {useGetEventOrders} from "../../../queries/useGetEventOrders";
import {PageTitle} from "../../common/PageTitle";
import {PageBody} from "../../common/PageBody";
import {OrdersTable} from "../../common/OrdersTable";
import {SearchBarWrapper} from "../../common/SearchBar";
import {Pagination} from "../../common/Pagination";
import {ToolBar} from "../../common/ToolBar";
import {useFilterQueryParamSync} from "../../../hooks/useFilterQueryParamSync";
import {IdParam, QueryFilterOperator, QueryFilters} from "../../../types";
import {TableSkeleton} from "../../common/TableSkeleton";
import {orderClient} from "../../../api/order.client";
import {downloadBinary} from "../../../utilites/download";
import {FilterModal, FilterOption} from "../../common/FilterModal";
import {withLoadingNotification} from "../../../utilites/withLoadingNotification.tsx";

const orderStatuses = [
{ label: t`Completed`, value: 'COMPLETED' },
{ label: t`Cancelled`, value: 'CANCELLED' },
{ label: t`Awaiting Offline Payment`, value: 'AWAITING_OFFLINE_PAYMENT' },
{label: t`Completed`, value: 'COMPLETED'},
{label: t`Cancelled`, value: 'CANCELLED'},
{label: t`Awaiting Offline Payment`, value: 'AWAITING_OFFLINE_PAYMENT'},
];

const refundStatuses = [
{ label: t`Refunded`, value: 'REFUNDED' },
{ label: t`Partially Refunded`, value: 'PARTIALLY_REFUNDED' },
{label: t`Refunded`, value: 'REFUNDED'},
{label: t`Partially Refunded`, value: 'PARTIALLY_REFUNDED'},
];

export const Orders: React.FC = () => {
const { eventId } = useParams<{ eventId: string }>();
const { data: event } = useGetEvent(eventId);
const {eventId} = useParams<{ eventId: string }>();
const {data: event} = useGetEvent(eventId);
const [searchParams, setSearchParams] = useFilterQueryParamSync();
const ordersQuery = useGetEventOrders(eventId, searchParams as QueryFilters);
const orders = ordersQuery?.data?.data;
Expand Down Expand Up @@ -61,10 +60,10 @@ export const Orders: React.FC = () => {
filterFields: {
...(searchParams.filterFields || {}),
status: values.status?.length > 0
? { operator: QueryFilterOperator.In, value: values.status }
? {operator: QueryFilterOperator.In, value: values.status}
: undefined,
refund_status: values.refund_status?.length > 0
? { operator: QueryFilterOperator.In, value: values.refund_status }
? {operator: QueryFilterOperator.In, value: values.refund_status}
: undefined
}
};
Expand All @@ -82,26 +81,26 @@ export const Orders: React.FC = () => {

const handleExport = async (eventId: IdParam) => {
await withLoadingNotification(async () => {
setDownloadPending(true);
const blob = await orderClient.exportOrders(eventId);
downloadBinary(blob, 'orders.xlsx');
},
{
loading: {
title: t`Exporting Orders`,
message: t`Please wait while we prepare your orders for export...`
},
success: {
title: t`Orders Exported`,
message: t`Your orders have been exported successfully.`,
onRun: () => setDownloadPending(false)
setDownloadPending(true);
const blob = await orderClient.exportOrders(eventId);
downloadBinary(blob, 'orders.xlsx');
},
error: {
title: t`Failed to export orders`,
message: t`Please try again.`,
onRun: () => setDownloadPending(false)
}
});
{
loading: {
title: t`Exporting Orders`,
message: t`Please wait while we prepare your orders for export...`
},
success: {
title: t`Orders Exported`,
message: t`Your orders have been exported successfully.`,
onRun: () => setDownloadPending(false)
},
error: {
title: t`Failed to export orders`,
message: t`Please try again.`,
onRun: () => setDownloadPending(false)
}
});
};

const currentFilters = {
Expand Down Expand Up @@ -133,7 +132,7 @@ export const Orders: React.FC = () => {
>
<Button
onClick={() => handleExport(eventId)}
rightSection={<IconDownload size={14} />}
rightSection={<IconDownload size={14}/>}
color="green"
loading={downloadPending}
size="sm"
Expand All @@ -142,16 +141,16 @@ export const Orders: React.FC = () => {
</Button>
</ToolBar>

<TableSkeleton isVisible={!orders || ordersQuery.isFetching} />
<TableSkeleton isVisible={!orders || ordersQuery.isFetching}/>

{orders && event && (
<OrdersTable event={event} orders={orders} />
<OrdersTable event={event} orders={orders}/>
)}

{!!orders?.length && (
<Pagination
value={searchParams.pageNumber}
onChange={(value) => setSearchParams({ pageNumber: value })}
onChange={(value) => setSearchParams({pageNumber: value})}
total={Number(pagination?.last_page)}
/>
)}
Expand Down
4 changes: 2 additions & 2 deletions misc/k6/event-hompage-load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { check, sleep } from 'k6';

export let options = {
vus: 50,
duration: '60s', // Using '60s' instead of '60000' for clarity
duration: '5s',
};

export default function () {
let res = http.get('https://api.hi.events/public/events/1', {
let res = http.get('https://api.hi.events/public/events/2', {
headers: {
'Accept': 'application/json',
},
Expand Down
Loading