move selfservice tables to medreport schema
add base medusa store frontend
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { retrieveCustomer } from '~/medusa/lib/data/customer';
|
||||
import { getRegion } from '~/medusa/lib/data/regions';
|
||||
import AddressBook from '~/medusa/modules/account/components/address-book';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Addresses',
|
||||
description: 'View your addresses',
|
||||
};
|
||||
|
||||
export default async function Addresses(props: {
|
||||
params: Promise<{ countryCode: string }>;
|
||||
}) {
|
||||
const params = await props.params;
|
||||
const { countryCode } = params;
|
||||
const customer = await retrieveCustomer();
|
||||
const region = await getRegion(countryCode);
|
||||
|
||||
if (!customer || !region) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="addresses-page-wrapper">
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Shipping Addresses</h1>
|
||||
<p className="text-base-regular">
|
||||
View and update your shipping addresses, you can add as many as you
|
||||
like. Saving your addresses will make them available during checkout.
|
||||
</p>
|
||||
</div>
|
||||
<AddressBook customer={customer} region={region} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import Spinner from '~/medusa/modules/common/icons/spinner';
|
||||
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="text-ui-fg-base flex h-full w-full items-center justify-center">
|
||||
<Spinner size={36} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { retrieveOrder } from '~/medusa/lib/data/orders';
|
||||
import OrderDetailsTemplate from '~/medusa/modules/order/templates/order-details-template';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export async function generateMetadata(props: Props): Promise<Metadata> {
|
||||
const params = await props.params;
|
||||
const order = await retrieveOrder(params.id).catch(() => null);
|
||||
|
||||
if (!order) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return {
|
||||
title: `Order #${order.display_id}`,
|
||||
description: `View your order`,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function OrderDetailPage(props: Props) {
|
||||
const params = await props.params;
|
||||
const order = await retrieveOrder(params.id).catch(() => null);
|
||||
|
||||
if (!order) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return <OrderDetailsTemplate order={order} />;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { listOrders } from '~/medusa/lib/data/orders';
|
||||
import OrderOverview from '~/medusa/modules/account/components/order-overview';
|
||||
import TransferRequestForm from '~/medusa/modules/account/components/transfer-request-form';
|
||||
import Divider from '~/medusa/modules/common/components/divider';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Orders',
|
||||
description: 'Overview of your previous orders.',
|
||||
};
|
||||
|
||||
export default async function Orders() {
|
||||
const orders = await listOrders();
|
||||
|
||||
if (!orders) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="orders-page-wrapper">
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Orders</h1>
|
||||
<p className="text-base-regular">
|
||||
View your previous orders and their status. You can also create
|
||||
returns or exchanges for your orders if needed.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<OrderOverview orders={orders} />
|
||||
<Divider className="my-16" />
|
||||
<TransferRequestForm />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
23
app/store/[countryCode]/(main)/account/@dashboard/page.tsx
Normal file
23
app/store/[countryCode]/(main)/account/@dashboard/page.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { retrieveCustomer } from '~/medusa/lib/data/customer';
|
||||
import { listOrders } from '~/medusa/lib/data/orders';
|
||||
import Overview from '~/medusa/modules/account/components/overview';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Account',
|
||||
description: 'Overview of your account activity.',
|
||||
};
|
||||
|
||||
export default async function OverviewTemplate() {
|
||||
const customer = await retrieveCustomer().catch(() => null);
|
||||
const orders = (await listOrders().catch(() => null)) || null;
|
||||
|
||||
if (!customer) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return <Overview customer={customer} orders={orders} />;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { retrieveCustomer } from '~/medusa/lib/data/customer';
|
||||
import { listRegions } from '~/medusa/lib/data/regions';
|
||||
import ProfilePhone from '~/medusa/modules/account//components/profile-phone';
|
||||
import ProfileBillingAddress from '~/medusa/modules/account/components/profile-billing-address';
|
||||
import ProfileEmail from '~/medusa/modules/account/components/profile-email';
|
||||
import ProfileName from '~/medusa/modules/account/components/profile-name';
|
||||
import ProfilePassword from '~/medusa/modules/account/components/profile-password';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Profile',
|
||||
description: 'View and edit your Medusa Store profile.',
|
||||
};
|
||||
|
||||
export default async function Profile() {
|
||||
const customer = await retrieveCustomer();
|
||||
const regions = await listRegions();
|
||||
|
||||
if (!customer || !regions) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full" data-testid="profile-page-wrapper">
|
||||
<div className="mb-8 flex flex-col gap-y-4">
|
||||
<h1 className="text-2xl-semi">Profile</h1>
|
||||
<p className="text-base-regular">
|
||||
View and update your profile information, including your name, email,
|
||||
and phone number. You can also update your billing address, or change
|
||||
your password.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex w-full flex-col gap-y-8">
|
||||
<ProfileName customer={customer} />
|
||||
<Divider />
|
||||
<ProfileEmail customer={customer} />
|
||||
<Divider />
|
||||
<ProfilePhone customer={customer} />
|
||||
<Divider />
|
||||
{/* <ProfilePassword customer={customer} />
|
||||
<Divider /> */}
|
||||
<ProfileBillingAddress customer={customer} regions={regions} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const Divider = () => {
|
||||
return <div className="h-px w-full bg-gray-200" />;
|
||||
};
|
||||
``;
|
||||
12
app/store/[countryCode]/(main)/account/@login/page.tsx
Normal file
12
app/store/[countryCode]/(main)/account/@login/page.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Metadata } from 'next';
|
||||
|
||||
import LoginTemplate from '~/medusa/modules/account/templates/login-template';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Sign in',
|
||||
description: 'Sign in to your Medusa Store account.',
|
||||
};
|
||||
|
||||
export default function Login() {
|
||||
return <LoginTemplate />;
|
||||
}
|
||||
21
app/store/[countryCode]/(main)/account/layout.tsx
Normal file
21
app/store/[countryCode]/(main)/account/layout.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Toaster } from '@medusajs/ui';
|
||||
|
||||
import { retrieveCustomer } from '~/medusa/lib/data';
|
||||
import { AccountLayout } from '~/medusa/modules/account/templates';
|
||||
|
||||
export default async function AccountPageLayout({
|
||||
dashboard,
|
||||
login,
|
||||
}: {
|
||||
dashboard?: React.ReactNode;
|
||||
login?: React.ReactNode;
|
||||
}) {
|
||||
const customer = await retrieveCustomer().catch(() => null);
|
||||
|
||||
return (
|
||||
<AccountLayout customer={customer}>
|
||||
{customer ? dashboard : login}
|
||||
<Toaster />
|
||||
</AccountLayout>
|
||||
);
|
||||
}
|
||||
9
app/store/[countryCode]/(main)/account/loading.tsx
Normal file
9
app/store/[countryCode]/(main)/account/loading.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import Spinner from '~/medusa/modules/common/icons/spinner';
|
||||
|
||||
export default function Loading() {
|
||||
return (
|
||||
<div className="text-ui-fg-base flex h-full w-full items-center justify-center">
|
||||
<Spinner size={36} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user