Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiichyCode committed Mar 23, 2024
1 parent 3ab75ce commit ca71b8e
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 91 deletions.
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"lucide-react": "^0.304.0",
"next": "^14.0.4",
"next-auth": "^4.24.5",
"next-safe-action": "^6.0.1",
"next-safe-action": "^6.0.2",
"react": "18.2.0",
"react-beautiful-dnd": "^13.1.1",
"react-dom": "18.2.0",
Expand Down
1 change: 0 additions & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const config = {
semi: true,
importOrder: [
'<THIRD_PARTY_MODULES>',

'^@/(.*)$', // Absolute imports
'^[./].*(?<!\\.(c|le|sc)ss)$',
'^[.]/[-a-zA-Z0-9_]+[.](module)[.](css|scss|less)$',
Expand Down
17 changes: 2 additions & 15 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ datasource db {
url = env("DATABASE_URL")
}

model Post {
id Int @id @default(autoincrement())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy User @relation(fields: [createdById], references: [id])
createdById String
@@index([name])
}

// Necessary for Next auth
model Account {
id String @id @default(cuid())
Expand Down Expand Up @@ -71,18 +59,17 @@ model User {
createdAt DateTime @default(now())
accounts Account[]
sessions Session[]
posts Post[]
orders Order[]
cart Cart[]
}

model Cart {
id Int @id @default(autoincrement())
userId String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
cartItems CartItem[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model CartItem {
Expand Down
11 changes: 8 additions & 3 deletions src/app/admin/payments/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { stripe } from "@/lib/stripe";
import CheckoutService from "@/features/Shop/services/checkout.service";
import { OrderStatusSelect } from '@/features/Admin/components/OrderStatusSelect';
import CheckoutService from '@/features/Shop/services/checkout.service';
import { stripe } from '@/lib/stripe';

export default async function PaymentPage({
params,
Expand All @@ -14,7 +15,11 @@ export default async function PaymentPage({
paymentIntent.payment_method as string,
);

console.log(order);

return (
<div className="mx-auto w-full max-w-5xl space-y-8 px-14">PaymentPage</div>
<div className="mx-auto w-full max-w-5xl space-y-8 px-14">
<OrderStatusSelect status={order?.status} />
</div>
);
}
40 changes: 40 additions & 0 deletions src/features/Admin/components/OrderStatusSelect/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { OrderStatus } from '@prisma/client';

const orderStatus = [
{ label: 'Pending', value: 'PENDING' },
{ label: 'Processing', value: 'PROCESSING' },
{ label: 'Shipped', value: 'SHIPPED' },
{ label: 'Delivered', value: 'DELIVERED' },
{ label: 'Canceled', value: 'CANCELED' },
];

type Props = {
status: OrderStatus | undefined;
};

export const OrderStatusSelect = ({ status }: Props) => {
return (
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder={status} className="" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{orderStatus.map((status) => (
<SelectItem key={status.value} value={status.value}>
{status.label}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
);
};
8 changes: 4 additions & 4 deletions src/features/Admin/components/common/AdminLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Link from "next/link";
import Image from "next/image";
import { ADMIN_URL } from "@/constants/urls";
import { SHOP_URL } from '@/constants/urls';
import Image from 'next/image';
import Link from 'next/link';

export const AdminLogo = () => {
return (
<div className="py-4">
<Link href={ADMIN_URL}>
<Link href={SHOP_URL}>
<Image
src="/icons/strapi.svg"
width={40}
Expand Down
4 changes: 2 additions & 2 deletions src/features/Admin/components/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AdminLogo } from "../common/AdminLogo";
import { Navigation } from "./Navigation";
import { AdminLogo } from '../common/AdminLogo';
import { Navigation } from './Navigation';

export const Sidebar = () => {
return (
Expand Down
76 changes: 42 additions & 34 deletions src/features/Admin/types/payment.type.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
export type PaymentMethodOptionsType =
| "acss_debit"
| "affirm"
| "afterpay_clearpay"
| "alipay"
| "au_becs_debit"
| "bacs_debit"
| "bancontact"
| "blik"
| "boleto"
| "card"
| "card_present"
| "cashapp"
| "customer_balance"
| "eps"
| "fpx"
| "giropay"
| "grabpay"
| "ideal"
| "interac_present"
| "klarna"
| "konbini"
| "link"
| "oxxo"
| "p24"
| "paynow"
| "paypal"
| "pix"
| "promptpay"
| "revolut_pay"
| "sepa_debit"
| "sofort"
| "us_bank_account"
| "wechat_pay"
| "zip";
| 'acss_debit'
| 'affirm'
| 'afterpay_clearpay'
| 'alipay'
| 'au_becs_debit'
| 'bacs_debit'
| 'bancontact'
| 'blik'
| 'boleto'
| 'card'
| 'card_present'
| 'cashapp'
| 'customer_balance'
| 'eps'
| 'fpx'
| 'giropay'
| 'grabpay'
| 'ideal'
| 'interac_present'
| 'klarna'
| 'konbini'
| 'link'
| 'oxxo'
| 'p24'
| 'paynow'
| 'paypal'
| 'pix'
| 'promptpay'
| 'revolut_pay'
| 'sepa_debit'
| 'sofort'
| 'us_bank_account'
| 'wechat_pay'
| 'zip';

export enum OrderStatus {
PENDING = 'pending',
PROCESSING = 'processing',
SHIPPED = 'shipped',
DELIVERED = 'delivered',
CANCELED = 'canceled',
}
8 changes: 4 additions & 4 deletions src/server/db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient } from '@prisma/client';

import { env } from "@/env";
import { env } from '@/env';

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
Expand All @@ -9,7 +9,7 @@ const globalForPrisma = globalThis as unknown as {
export const db =
globalForPrisma.prisma ??
new PrismaClient({
log: env.NODE_ENV === "development" ? ["error", "warn"] : ["error"],
log: env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
});

if (env.NODE_ENV !== "production") globalForPrisma.prisma = db;
if (env.NODE_ENV !== 'production') globalForPrisma.prisma = db;

0 comments on commit ca71b8e

Please sign in to comment.