Skip to content

Commit

Permalink
Merge pull request #54 from Prodeko:purchase-history-fixes
Browse files Browse the repository at this point in the history
Purchase-history-fixes
  • Loading branch information
ccruzkauppila authored Jan 6, 2025
2 parents b31cd70 + 8f28624 commit 4e6843a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
9 changes: 6 additions & 3 deletions src/app/(loggedin)/account/deposits/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import { formatCleverDate, parseISOString } from "@/common/utils";
import { EmptyPage } from "@/components/ui/EmptyPage";
import { HistoryList, HistoryListItem } from "@/components/ui/HistoryList";
import { AccountHistoryLayout } from "@/components/ui/Layouts/AccountHistoryLayout";
import { getCurrentUser } from "@/server/db/queries/account";
import { getDepositHistory } from "@/server/db/queries/deposit";
import { InternalServerError } from "@/server/exceptions/exception";

export const dynamic = "force-dynamic";

const DepositHistoryPage = async () => {
const session = await getSession();
if (!session) {
const user = await getCurrentUser();
if (!user.ok) {
redirect("/login");
}
const userId = session.user.userId;
const userId = user.user.id;
const depositHistoryQuery = await getDepositHistory(userId);
if (!depositHistoryQuery.ok) {
throw new InternalServerError({
Expand Down
12 changes: 6 additions & 6 deletions src/app/(loggedin)/account/purchases/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { redirect } from "next/navigation";

import { getSession } from "@/auth/ironsession";
import { formatCleverDateTime } from "@/common/utils";
import { EmptyPage } from "@/components/ui/EmptyPage";
import { HistoryList, HistoryListItem } from "@/components/ui/HistoryList";
import { AccountHistoryLayout } from "@/components/ui/Layouts/AccountHistoryLayout";
import { getCurrentUser } from "@/server/db/queries/account";
import { getUserTransactionsWithItems } from "@/server/db/queries/transaction";

export const dynamic = "force-dynamic";

const PurchaseHistoryPage = async () => {
const session = await getSession();
if (!session) {
const user = await getCurrentUser();
if (!user.ok) {
redirect("/login");
}
const purchaseHistory = await getUserTransactionsWithItems(
session.user.userId,
);
const purchaseHistory = await getUserTransactionsWithItems(user.user.id);

return (
<AccountHistoryLayout title="Purchase History">
Expand Down
10 changes: 5 additions & 5 deletions src/components/ui/HistoryList/HistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ export interface Props {

export const HistoryList = ({ eventDate, totalPrice, children }: Props) => {
return (
<div className="flex flex-col gap-4 border-b-2 py-6 md:py-8">
<div className="flex items-center justify-between pb-3">
<h3 className="px-6 text-2xl font-bold text-neutral-600 md:px-12 md:text-3xl">
<div className="flex flex-col gap-2 border-b-2 py-6 md:gap-4 md:py-8">
<div className="flex items-center justify-between">
<h3 className="pl-4 text-xl font-bold text-neutral-700 md:pl-12 md:text-3xl">
{eventDate}
</h3>
<div className="flex items-center gap-1 px-6 text-xl font-medium md:px-12 md:text-2xl">
<div className="flex items-center gap-1 px-4 text-xl font-medium md:px-12 md:text-2xl">
<span>Total:</span>
<span className=" text-primary-500">
{formatCurrency(totalPrice)}
</span>
</div>
</div>
<div className="flex flex-col gap-1 px-6 md:px-12">{children}</div>
<div className="flex flex-col gap-1 px-4 md:px-12">{children}</div>
</div>
);
};
4 changes: 2 additions & 2 deletions src/components/ui/Layouts/AccountHistoryLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const AccountHistoryLayout = ({ title, children }: Props) => {
<SectionTitle
withBackButton
title={title}
className="px-6 align-middle md:px-12"
className="px-4 align-middle md:px-12"
/>
<div className="flex flex-grow flex-col">{children}</div>
<div className="flex flex-grow flex-col pt-4 md:pt-6">{children}</div>
</div>
);
};

0 comments on commit 4e6843a

Please sign in to comment.