Skip to content

Commit

Permalink
fix: Inventory OAS
Browse files Browse the repository at this point in the history
  • Loading branch information
vholik committed Dec 18, 2024
1 parent a254680 commit c9577a0
Show file tree
Hide file tree
Showing 50 changed files with 704 additions and 105 deletions.
1 change: 0 additions & 1 deletion apps/backend/src/api/openapi/vendor/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@
* format: date-time
* title: updated_at
* description: The date the sales channel was updated.
* deleted_at:
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { VendorUpdateInventoryLevel } from '../../../validators'
* schema:
* type: string
* - in: path
* name: locationId
* name: location_id
* required: true
* description: The ID of the Stock Location.
* schema:
Expand Down Expand Up @@ -85,7 +85,7 @@ export const POST = async (
* schema:
* type: string
* - in: path
* name: locationId
* name: location_id
* required: true
* description: The ID of the Stock Location.
* schema:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const GET = async (
}

/**
* @oas [post] /vendor/inventory-items/{id}/location-levels/{locationId}
* @oas [post] /vendor/inventory-items/{id}/location-levels
* operationId: "VendorCreateInventoryLevel"
* summary: "Create inventory level"
* description: "Creates inventory level of the InventoryItem in the specified location"
Expand Down
6 changes: 0 additions & 6 deletions apps/backend/src/api/vendor/inventory-items/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ export const GET = async (
* description: The ID of the InventoryItem.
* schema:
* type: string
* - in: path
* name: locationId
* required: true
* description: The ID of the Stock Location.
* schema:
* type: string
* requestBody:
* content:
* application/json:
Expand Down
42 changes: 23 additions & 19 deletions apps/vendor/src/app/router/ui/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Redirect, Route, Switch } from 'wouter'
import { ProtectedRoute } from './protected-route'
import { RegisterPageAsync } from '@/pages/register'
import { LoginPageAsync } from '@/pages/login'
import { Suspense } from 'react'
import { SidebarTrigger } from '@/shared/ui'
import { PropsWithChildren, Suspense } from 'react'
import { AppSidebarAsync } from '@/widgets/app-sidebar'
import { OrdersPageAsync } from '@/pages/orders'

export const AppRouter = () => {
return (
Expand All @@ -23,17 +23,16 @@ export const AppRouter = () => {

{/* Protected dashboard routes */}
<ProtectedRoute path="/dashboard" nest>
<Suspense fallback={<div>Loading...</div>}>
<AppSidebarAsync />
</Suspense>
<SidebarTrigger className="ml-2" />
<Switch>
<Route path="/orders">
<Orders />
<Route path="/:id" component={OrderDetails} />
</Route>
<Route>404, Not Found!</Route>
</Switch>
<Shell>
<Switch>
<Route path="/orders">
<Suspense fallback={<div>Loading...</div>}>
<OrdersPageAsync />
</Suspense>
</Route>
<Route>404, Not Found!</Route>
</Switch>
</Shell>
</ProtectedRoute>

{/* Root redirect */}
Expand All @@ -47,10 +46,15 @@ export const AppRouter = () => {
)
}

const Orders = () => {
return <div>Orders</div>
}

const OrderDetails = () => {
return <div>OrderDetails</div>
const Shell = ({ children }: PropsWithChildren) => {
return (
<div className="flex h-screen items-start overflow-hidden w-full">
<Suspense fallback={<div>Loading...</div>}>
<AppSidebarAsync />
</Suspense>
<div className="flex w-full max-w-[1600px] flex-col gap-y-2 p-10">
{children}
</div>
</div>
)
}
2 changes: 1 addition & 1 deletion apps/vendor/src/entities/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './api'
export * from './model'
File renamed without changes.
1 change: 1 addition & 0 deletions apps/vendor/src/entities/order/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ui'
15 changes: 15 additions & 0 deletions apps/vendor/src/entities/order/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { queryKeysFactory } from '@/shared/lib'
import { useQuery } from '@tanstack/react-query'

const ORDER_QUERY_KEY = 'order'
export const orderQueryKeys = queryKeysFactory(ORDER_QUERY_KEY)

export const useOrders = () => {
const { data, ...other } = useQuery({
queryKey: orderQueryKeys.details(),
queryFn: () => vendorGetOrd().then((res) => res.data),
retry: false
})

return { ...data, ...other }
}
1 change: 1 addition & 0 deletions apps/vendor/src/entities/order/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './order-table'
72 changes: 72 additions & 0 deletions apps/vendor/src/entities/order/ui/order-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow
} from '@/shared/ui'

const orders = [
{
display_id: 123,
customer: 'John Doe',
products: ['Product 1', 'Product 2', 'Product 3'],
status: 'active',
date: new Date(),
revenue: 250
},
{
display_id: 123,
customer: 'John Doe',
products: ['Product 1', 'Product 2', 'Product 3'],
status: 'active',
date: new Date(),
revenue: 250
},
{
display_id: 123,
customer: 'John Doe',
products: ['Product 1', 'Product 2', 'Product 3'],
status: 'active',
date: new Date(),
revenue: 250
},
{
display_id: 123,
customer: 'John Doe',
products: ['Product 1', 'Product 2', 'Product 3'],
status: 'active',
date: new Date(),
revenue: 250
}
]

export const OrderTable = () => {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">#</TableHead>
<TableHead>Customer</TableHead>
<TableHead>Products</TableHead>
<TableHead>Status</TableHead>
<TableHead>Date</TableHead>
<TableHead className="text-right">Revenue</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{orders.map((order) => (
<TableRow key={order.display_id}>
<TableCell className="font-medium">{order.display_id}</TableCell>
<TableCell>{order.customer}</TableCell>
<TableCell>{order.products.join(', ')}</TableCell>
<TableCell>{order.status}</TableCell>
<TableCell>{order.date.toLocaleDateString()}</TableCell>
<TableCell className="text-right">{order.revenue}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}
2 changes: 1 addition & 1 deletion apps/vendor/src/entities/seller/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './api'
export * from './model'
File renamed without changes.
17 changes: 13 additions & 4 deletions apps/vendor/src/pages/login/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ const LoginPage = () => {
})

async function onSubmit({ email, password }: z.infer<typeof schema>) {
const { token } = await login({
email,
password
})
const { token } = await login(
{
email,
password
},
{
onError: (error) => {
toast.error('Error occurred while logging in', {
description: error.message
})
}
}
)

await createSession(
{ token },
Expand Down
1 change: 1 addition & 0 deletions apps/vendor/src/pages/orders/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ui.async'
3 changes: 3 additions & 0 deletions apps/vendor/src/pages/orders/ui.async.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { lazy } from 'react'

export const OrdersPageAsync = lazy(() => import('./ui'))
13 changes: 13 additions & 0 deletions apps/vendor/src/pages/orders/ui.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { OrderTable } from '@/entities/order'
import { Text } from '@/shared/ui'

export default function OrdersPage() {
return (
<>
<Text size="2xlarge" weight="plus">
Orders
</Text>
<OrderTable />
</>
)
}
3 changes: 2 additions & 1 deletion apps/vendor/src/shared/ui/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const textVariants = cva({
small: 'text-sm',
base: 'text-base',
large: 'text-lg',
xlarge: 'text-xl'
xlarge: 'text-xl',
'2xlarge': 'text-2xl'
},
weight: {
regular: 'font-normal',
Expand Down
Loading

0 comments on commit c9577a0

Please sign in to comment.