diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/orders/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/orders/page.tsx index 1ef2213..fd6d6a2 100644 --- a/src/app/[lang]/(dashboard)/(private)/dashboards/orders/page.tsx +++ b/src/app/[lang]/(dashboard)/(private)/dashboards/orders/page.tsx @@ -7,18 +7,87 @@ import Grid from '@mui/material/Grid2' import DistributedBarChartOrder from '@views/dashboards/crm/DistributedBarChartOrder' // Server Action Imports +import { TextField, Typography, useTheme } from '@mui/material' +import { useState } from 'react' import Loading from '../../../../../../components/layout/shared/Loading' import { useSalesAnalytics } from '../../../../../../services/queries/analytics' import { RecentSale } from '../../../../../../types/services/analytic' +import { formatDateDDMMYYYY, formatForInputDate } from '../../../../../../utils/transform' import OrdersReport from '../../../../../../views/dashboards/orders/OrdersReport' const DashboardOrder = () => { - const { data, isLoading } = useSalesAnalytics() + const theme = useTheme() + + const today = new Date() + const monthAgo = new Date() + monthAgo.setDate(today.getDate() - 30) + + const [filter, setFilter] = useState({ + date_from: formatDateDDMMYYYY(monthAgo), + date_to: formatDateDDMMYYYY(today) + }) + + const { data, isLoading } = useSalesAnalytics({ + date_from: filter.date_from, + date_to: filter.date_to + }) if (isLoading) return return ( + +
+ + Orders Analysis Dashboard + +
+ { + setFilter({ + ...filter, + date_from: formatDateDDMMYYYY(new Date(e.target.value)) + }) + }} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> + - + {}} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> +
+
+
+ { - // Sample data - replace with your actual data - const { data: salesData, isLoading } = useDashboardAnalytics() + const theme = useTheme() - if (isLoading) return + const today = new Date() + const monthAgo = new Date() + monthAgo.setDate(today.getDate() - 30) + + const [filter, setFilter] = useState({ + date_from: formatDateDDMMYYYY(monthAgo), + date_to: formatDateDDMMYYYY(today) + }) + + // Sample data - replace with your actual data + const { data: salesData, isLoading } = useDashboardAnalytics({ + date_from: filter.date_from, + date_to: filter.date_to + }) const MetricCard = ({ iconClass, title, value, subtitle, bgColor = 'bg-blue-500', isCurrency = false }: any) => (
@@ -29,70 +42,108 @@ const DashboardOverview = () => {
) - const ProgressBar = ({ percentage, color = 'bg-blue-500' }: any) => ( -
-
-
- ) - return ( <> - {salesData && ( -
- {/* Header */} - {/*
-

Sales Dashboard

-

- {formatDate(salesData.date_from)} - {formatDate(salesData.date_to)} -

-
*/} - - {/* Overview Metrics */} -
- + {/* Header */} +
+ + Analysis Dashboard + +
+ { + setFilter({ + ...filter, + date_from: formatDateDDMMYYYY(new Date(e.target.value)) + }) + }} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} /> - - - - + {}} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} />
- -
- {/* Top Products */} - - - {/* Payment Methods */} - -
- - {/* Recent Sales */} -
- )} + + {salesData ? ( + <> + {/* Overview Metrics */} +
+ + + + +
+ +
+ {/* Top Products */} + + + {/* Payment Methods */} + +
+ + {/* Recent Sales */} + + + ) : ( + + )} +
) } diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx index 568ea25..a1e3d4c 100644 --- a/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx +++ b/src/app/[lang]/(dashboard)/(private)/dashboards/payment-methods/page.tsx @@ -11,14 +11,82 @@ import Loading from '../../../../../../components/layout/shared/Loading' import { usePaymentAnalytics } from '../../../../../../services/queries/analytics' import { PaymentDataItem } from '../../../../../../types/services/analytic' import PaymentMethodReport from '../../../../../../views/dashboards/payment-methods/PaymentMethodReport' +import { Typography, TextField, useTheme } from '@mui/material' +import { useState } from 'react' +import { formatDateDDMMYYYY, formatForInputDate } from '../../../../../../utils/transform' const DashboardPayment = () => { - const { data, isLoading } = usePaymentAnalytics() + const theme = useTheme() + + const today = new Date() + const monthAgo = new Date() + monthAgo.setDate(today.getDate() - 30) + + const [filter, setFilter] = useState({ + date_from: formatDateDDMMYYYY(monthAgo), + date_to: formatDateDDMMYYYY(today) + }) + + const { data, isLoading } = usePaymentAnalytics({ + date_from: filter.date_from, + date_to: filter.date_to + }) if (isLoading) return return ( + +
+ + Payments Analysis Dashboard + +
+ { + setFilter({ + ...filter, + date_from: formatDateDDMMYYYY(new Date(e.target.value)) + }) + }} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> + - + {}} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> +
+
+
{ - const { data, isLoading } = useProductSalesAnalytics() + const theme = useTheme() - const summary = { - totalProducts: data?.data.length, - totalQuantitySold: data?.data.reduce((sum, item) => sum + item.quantity_sold, 0), - totalRevenue: data?.data.reduce((sum, item) => sum + item.revenue, 0), - totalOrders: data?.data.reduce((sum, item) => sum + item.order_count, 0), - averageOrderValue: data?.data - ? data!.data.reduce((sum, item) => sum + item.revenue, 0) / - data!.data.reduce((sum, item) => sum + item.order_count, 0) - : 0 - } + const today = new Date() + const monthAgo = new Date() + monthAgo.setDate(today.getDate() - 30) - const formatDate = (dateString: any) => { - return new Date(dateString).toLocaleDateString('id-ID', { - month: 'short', - day: 'numeric' - }) - } + const [filter, setFilter] = useState({ + date_from: formatDateDDMMYYYY(monthAgo), + date_to: formatDateDDMMYYYY(today) + }) - const transformSalesData = (data: any) => { - return [ - { - type: 'products', - avatarIcon: 'tabler-package', - date: data.map((d: any) => d.product_name), - series: [{ data: data.map((d: any) => d.revenue) }] - } - ] - } + const { data, isLoading } = useProductSalesAnalytics({ + date_from: filter.date_from, + date_to: filter.date_to + }) if (isLoading) return return ( - {data?.data && } + +
+ + Products Analysis Dashboard + +
+ { + setFilter({ + ...filter, + date_from: formatDateDDMMYYYY(new Date(e.target.value)) + }) + }} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> + - + {}} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> +
+
+
+ + {data?.data ? : } +
) } diff --git a/src/app/[lang]/(dashboard)/(private)/dashboards/profit-loss/page.tsx b/src/app/[lang]/(dashboard)/(private)/dashboards/profit-loss/page.tsx index 1355d80..b4b1ff4 100644 --- a/src/app/[lang]/(dashboard)/(private)/dashboards/profit-loss/page.tsx +++ b/src/app/[lang]/(dashboard)/(private)/dashboards/profit-loss/page.tsx @@ -2,23 +2,28 @@ import React, { useState } from 'react' import { useProfitLossAnalytics } from '../../../../../../services/queries/analytics' -import { formatDateDDMMYYYY, formatShortCurrency } from '../../../../../../utils/transform' +import { formatDateDDMMYYYY, formatForInputDate, formatShortCurrency } from '../../../../../../utils/transform' import MultipleSeries from '../../../../../../views/dashboards/profit-loss/EarningReportWithTabs' import { DailyData, ProfitLossReport } from '../../../../../../types/services/analytic' import { TextField, Typography, useTheme } from '@mui/material' +import Loading from '../../../../../../components/layout/shared/Loading' const DashboardProfitloss = () => { const theme = useTheme() + const today = new Date() + const monthAgo = new Date() + monthAgo.setDate(today.getDate() - 30) + const [filter, setFilter] = useState({ - date_from: new Date().setDate(new Date().getDate() - 30).toString(), - date_to: new Date().toString() + date_from: formatDateDDMMYYYY(monthAgo), + date_to: formatDateDDMMYYYY(today) }) // Sample data - replace with your actual data const { data: profitData, isLoading } = useProfitLossAnalytics({ - date_from: formatDateDDMMYYYY(filter.date_from), - date_to: formatDateDDMMYYYY(filter.date_to) + date_from: filter.date_from, + date_to: filter.date_to }) const formatCurrency = (amount: any) => { @@ -99,303 +104,319 @@ const DashboardProfitloss = () => { return ( <> - {profitData && ( -
- {/* Header */} -
- - Profit Analysis Dashboard - -
- {}} - size='small' - sx={{ - '& .MuiOutlinedInput-root': { - '&.Mui-focused fieldset': { - borderColor: 'primary.main' - }, - '& fieldset': { - borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider - } +
+ {/* Header */} +
+ + Profit Analysis Dashboard + +
+ { + setFilter({ + ...filter, + date_from: formatDateDDMMYYYY(new Date(e.target.value)) + }) + }} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider } - }} + } + }} + /> + - + {}} + size='small' + sx={{ + '& .MuiOutlinedInput-root': { + '&.Mui-focused fieldset': { + borderColor: 'primary.main' + }, + '& fieldset': { + borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider + } + } + }} + /> +
+
+ + {profitData ? ( + <> +
+ - - - {}} - size='small' - sx={{ - '& .MuiOutlinedInput-root': { - '&.Mui-focused fieldset': { - borderColor: 'primary.main' - }, - '& fieldset': { - borderColor: theme.palette.mode === 'dark' ? 'rgba(231, 227, 252, 0.22)' : theme.palette.divider - } - } - }} + + +
-
- {/* Summary Metrics */} -
- - - - -
- - {/* Additional Summary Metrics */} -
-
-
- -

Net Profit

+ {/* Additional Summary Metrics */} +
+
+
+ +

Net Profit

+
+

+ Rp {formatShortCurrency(profitData.summary.net_profit)} +

+

+ Margin: {formatPercentage(profitData.summary.net_profit_margin)} +

-

- Rp {formatShortCurrency(profitData.summary.net_profit)} -

-

Margin: {formatPercentage(profitData.summary.net_profit_margin)}

-
-
-
- -

Total Orders

+
+
+ +

Total Orders

+
+

{profitData.summary.total_orders}

-

{profitData.summary.total_orders}

-
-
-
- -

Tax & Discount

+
+
+ +

Tax & Discount

+
+

+ Rp {formatShortCurrency(profitData.summary.total_tax + profitData.summary.total_discount)} +

+

+ Tax: {formatShortCurrency(profitData.summary.total_tax)} | Discount:{' '} + {formatShortCurrency(profitData.summary.total_discount)} +

-

- Rp {formatShortCurrency(profitData.summary.total_tax + profitData.summary.total_discount)} -

-

- Tax: {formatShortCurrency(profitData.summary.total_tax)} | Discount:{' '} - {formatShortCurrency(profitData.summary.total_discount)} -

-
- {/* Profit Chart */} -
- -
+ {/* Profit Chart */} +
+ +
-
- {/* Daily Breakdown */} +
+ {/* Daily Breakdown */} +
+
+
+ +

Daily Breakdown

+
+
+ + + + + + + + + + + + + {profitData.data.map((day, index) => ( + + + + + + + + + ))} + +
DateRevenueCostProfitMarginOrders
+ {formatDate(day.date)} + + {formatCurrency(day.revenue)} + + {formatCurrency(day.cost)} + = 0 ? 'text-green-600' : 'text-red-600' + }`} + > + {formatCurrency(day.gross_profit)} + + + {formatPercentage(day.gross_profit_margin)} + + + {day.orders} +
+
+
+
+ + {/* Top Performing Products */} +
+
+
+ +

Top Performers

+
+
+ {profitData.product_data + .sort((a, b) => b.gross_profit - a.gross_profit) + .slice(0, 5) + .map((product, index) => ( +
+
+ + {index + 1} + +
+

{product.product_name}

+

{product.category_name}

+
+
+
+

= 0 ? 'text-green-600' : 'text-red-600'}`}> + {formatCurrency(product.gross_profit)} +

+

{formatPercentage(product.gross_profit_margin)}

+
+
+ ))} +
+
+
+
+ + {/* Product Analysis Table */}
- -

Daily Breakdown

+ +

Product Analysis

- + + + - + - {profitData.data.map((day, index) => ( - - - - - - + + + + + + - - - ))} + {formatCurrency(product.gross_profit)} + + + + + ))}
DateProductCategoryQty Revenue Cost Profit MarginOrdersPer Unit
- {formatDate(day.date)} - - {formatCurrency(day.revenue)} - - {formatCurrency(day.cost)} - = 0 ? 'text-green-600' : 'text-red-600' - }`} - > - {formatCurrency(day.gross_profit)} - - b.gross_profit - a.gross_profit) + .map(product => ( +
+
{product.product_name}
+
+ + {product.category_name} + + + {product.quantity_sold} + + {formatCurrency(product.revenue)} + + {formatCurrency(product.cost)} + = 0 ? 'text-green-600' : 'text-red-600' + }`} > - {formatPercentage(day.gross_profit_margin)} - - {day.orders}
+ + {formatPercentage(product.gross_profit_margin)} + + = 0 ? 'text-green-600' : 'text-red-600' + }`} + > + {formatCurrency(product.profit_per_unit)} +
- - {/* Top Performing Products */} -
-
-
- -

Top Performers

-
-
- {profitData.product_data - .sort((a, b) => b.gross_profit - a.gross_profit) - .slice(0, 5) - .map((product, index) => ( -
-
- - {index + 1} - -
-

{product.product_name}

-

{product.category_name}

-
-
-
-

= 0 ? 'text-green-600' : 'text-red-600'}`}> - {formatCurrency(product.gross_profit)} -

-

{formatPercentage(product.gross_profit_margin)}

-
-
- ))} -
-
-
-
- - {/* Product Analysis Table */} -
-
-
- -

Product Analysis

-
-
- - - - - - - - - - - - - - - {profitData.product_data - .sort((a, b) => b.gross_profit - a.gross_profit) - .map(product => ( - - - - - - - - - - - ))} - -
ProductCategoryQtyRevenueCostProfitMarginPer Unit
-
{product.product_name}
-
- - {product.category_name} - - - {product.quantity_sold} - - {formatCurrency(product.revenue)} - - {formatCurrency(product.cost)} - = 0 ? 'text-green-600' : 'text-red-600' - }`} - > - {formatCurrency(product.gross_profit)} - - - {formatPercentage(product.gross_profit_margin)} - - = 0 ? 'text-green-600' : 'text-red-600' - }`} - > - {formatCurrency(product.profit_per_unit)} -
-
-
-
-
- )} + + ) : ( + + )} +
) } diff --git a/src/components/layout/shared/Loading.tsx b/src/components/layout/shared/Loading.tsx index 7df9989..83e8039 100644 --- a/src/components/layout/shared/Loading.tsx +++ b/src/components/layout/shared/Loading.tsx @@ -2,7 +2,7 @@ import { CircularProgress } from '@mui/material' export default function Loading({ size = 60 }: { size?: number }) { return ( -
+
) diff --git a/src/services/api.ts b/src/services/api.ts index 25cad69..ab43ede 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -1,4 +1,5 @@ import axios from 'axios' +import { toast } from 'react-toastify' const getToken = () => { return localStorage.getItem('authToken') @@ -40,7 +41,7 @@ api.interceptors.response.use( } if (status >= 500) { - console.error('Server error:', error.response?.data?.message || 'Terjadi kesalahan server.') + toast.error(error.response?.data?.errors[0].cause || 'Terjadi kesalahan server.') } return Promise.reject(error) diff --git a/src/services/mutations/inventories.ts b/src/services/mutations/inventories.ts index d4e800f..16804fa 100644 --- a/src/services/mutations/inventories.ts +++ b/src/services/mutations/inventories.ts @@ -1,7 +1,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { api } from '../api' import { toast } from 'react-toastify' -import { InventoryAdjustRequest, InventoryRequest } from '../../types/services/inventory' +import { InventoryAdjustRequest, InventoryRequest, InventoryRestockRequest } from '../../types/services/inventory' export const useInventoriesMutation = () => { const queryClient = useQueryClient() @@ -34,6 +34,24 @@ export const useInventoriesMutation = () => { } }) + const restockInventory = useMutation({ + mutationFn: async (newInventory: InventoryRestockRequest) => { + newInventory.items.map(item => { + item.quantity = Number(item.quantity) + }) + + const response = await api.post('/inventory/restock', newInventory) + return response.data + }, + onSuccess: () => { + toast.success('Inventory restock successfully!') + queryClient.invalidateQueries({ queryKey: ['inventories'] }) + }, + onError: (error: any) => { + toast.error(error.response?.data?.errors?.[0]?.cause || 'Create failed') + } + }) + const deleteInventory = useMutation({ mutationFn: async (id: string) => { const response = await api.delete(`/inventory/${id}`) @@ -48,5 +66,5 @@ export const useInventoriesMutation = () => { } }) - return { createInventory, adjustInventory, deleteInventory } + return { createInventory, adjustInventory, deleteInventory, restockInventory } } diff --git a/src/types/services/inventory.ts b/src/types/services/inventory.ts index 7d22234..d018108 100644 --- a/src/types/services/inventory.ts +++ b/src/types/services/inventory.ts @@ -29,3 +29,15 @@ export interface InventoryAdjustRequest { delta: number reason: string } + +export interface Item { + item_id: string + item_type: string + quantity: number | string +} + +export interface InventoryRestockRequest { + outlet_id: string + items: Item[] + reason: string +} diff --git a/src/utils/transform.ts b/src/utils/transform.ts index a33ecfc..9f1e131 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -36,12 +36,22 @@ export const formatDate = (dateString: any) => { export const formatDateDDMMYYYY = (dateString: Date | string) => { const date = new Date(dateString) + date.setHours(0, 0, 0, 0) const day = String(date.getDate()).padStart(2, '0') const month = String(date.getMonth() + 1).padStart(2, '0') const year = date.getFullYear() return `${day}-${month}-${year}` } +export const formatForInputDate = (dateString: Date | string) => { + const date = new Date(dateString) + const day = String(date.getDate()).padStart(2, '0') + const month = String(date.getMonth() + 1).padStart(2, '0') + const year = date.getFullYear() + return `${year}-${month}-${day}` +} + + export const formatDatetime = (dateString: string | number | Date) => { const date = new Date(dateString) diff --git a/src/views/apps/ecommerce/products/list/ProductListTable.tsx b/src/views/apps/ecommerce/products/list/ProductListTable.tsx index f864f2d..9114005 100644 --- a/src/views/apps/ecommerce/products/list/ProductListTable.tsx +++ b/src/views/apps/ecommerce/products/list/ProductListTable.tsx @@ -220,13 +220,13 @@ const ProductListTable = () => {
diff --git a/src/views/apps/ecommerce/stock/adjustment/AdjustmentStockDrawer.tsx b/src/views/apps/ecommerce/stock/adjustment/AdjustmentStockDrawer.tsx index fbc0800..6f1b75c 100644 --- a/src/views/apps/ecommerce/stock/adjustment/AdjustmentStockDrawer.tsx +++ b/src/views/apps/ecommerce/stock/adjustment/AdjustmentStockDrawer.tsx @@ -14,12 +14,12 @@ import Typography from '@mui/material/Typography' // Components Imports import CustomTextField from '@core/components/mui/TextField' -import { Autocomplete, CircularProgress } from '@mui/material' +import { Autocomplete, CircularProgress, MenuItem } from '@mui/material' import { useDebounce } from 'use-debounce' import { useInventoriesMutation } from '../../../../../services/mutations/inventories' import { useOutlets } from '../../../../../services/queries/outlets' import { useProducts } from '../../../../../services/queries/products' -import { InventoryAdjustRequest } from '../../../../../types/services/inventory' +import { InventoryRestockRequest, Item } from '../../../../../types/services/inventory' type Props = { open: boolean @@ -30,17 +30,22 @@ const AdjustmentStockDrawer = (props: Props) => { // Props const { open, handleClose } = props - const { mutate: adjustInventory, isPending: isCreating } = useInventoriesMutation().adjustInventory + const { restockInventory } = useInventoriesMutation() // States const [productInput, setProductInput] = useState('') const [productDebouncedInput] = useDebounce(productInput, 500) // debounce for better UX const [outletInput, setOutletInput] = useState('') const [outletDebouncedInput] = useDebounce(outletInput, 500) // debounce for better UX - const [formData, setFormData] = useState({ - product_id: '', + const [formData, setFormData] = useState({ outlet_id: '', - delta: 0, + items: [ + { + item_id: '', + item_type: '', + quantity: 0 + } + ], reason: '' }) @@ -58,14 +63,11 @@ const AdjustmentStockDrawer = (props: Props) => { const handleFormSubmit = (e: any) => { e.preventDefault() - adjustInventory( - { ...formData, delta: Number(formData.delta) }, - { - onSuccess: () => { - handleReset() - } + restockInventory.mutate(formData, { + onSuccess: () => { + handleReset() } - ) + }) } const handleInputChange = (e: any) => { @@ -79,9 +81,14 @@ const AdjustmentStockDrawer = (props: Props) => { const handleReset = () => { handleClose() setFormData({ - product_id: '', outlet_id: '', - delta: 0, + items: [ + { + item_id: '', + item_type: '', + quantity: 0 + } + ], reason: '' }) } @@ -136,18 +143,33 @@ const AdjustmentStockDrawer = (props: Props) => { /> )} /> + setFormData({ ...formData, items: [{ ...formData.items[0], item_type: e.target.value }] })} + > + Product + Ingredient + option.name} - value={options.find(p => p.id === formData.product_id) || null} + value={options.find(p => p.id === formData.items[0].item_id) || null} onInputChange={(event, newProductInput) => { setProductInput(newProductInput) }} onChange={(event, newValue) => { setFormData({ ...formData, - product_id: newValue?.id || '' + items: [ + { + ...formData.items[0], + item_id: newValue?.id || '' + } + ] }) }} renderInput={params => ( @@ -170,10 +192,20 @@ const AdjustmentStockDrawer = (props: Props) => { /> + setFormData({ + ...formData, + items: [ + { + ...formData.items[0], + quantity: e.target.value + } + ] + }) + } placeholder='0' /> { placeholder='Write a Comment...' />
-