refactor: rename product to partyEvent in list page and view component
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
PRODUCT_COLOR_NAME_OPTIONS,
|
||||
PRODUCT_SIZE_OPTIONS,
|
||||
} from 'src/_mock';
|
||||
import { createProduct, updateProduct } from 'src/actions/party-event';
|
||||
import { createPartyEvent, updatePartyEvent } from 'src/actions/party-event';
|
||||
import { Field, Form, schemaHelper } from 'src/components/hook-form';
|
||||
import { Iconify } from 'src/components/iconify';
|
||||
import { toast } from 'src/components/snackbar';
|
||||
@@ -81,7 +81,7 @@ const PRODUCT_GENDER_OPTIONS = [
|
||||
{ label: 'Kids', value: 'Kids' },
|
||||
];
|
||||
|
||||
export type NewProductSchemaType = zod.infer<typeof NewProductSchema>;
|
||||
export type NewPartyEventSchemaType = zod.infer<typeof NewProductSchema>;
|
||||
|
||||
export const NewProductSchema = zod.object({
|
||||
sku: zod.string().min(1, { message: 'Product sku is required!' }),
|
||||
@@ -128,10 +128,10 @@ export const NewProductSchema = zod.object({
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
currentProduct?: IPartyEventItem;
|
||||
currentPartyEvent?: IPartyEventItem;
|
||||
};
|
||||
|
||||
export function ProductNewEditForm({ currentProduct }: Props) {
|
||||
export function PartyEventNewEditForm({ currentPartyEvent }: Props) {
|
||||
const router = useRouter();
|
||||
|
||||
const openDetails = useBoolean(true);
|
||||
@@ -140,9 +140,9 @@ export function ProductNewEditForm({ currentProduct }: Props) {
|
||||
|
||||
const [includeTaxes, setIncludeTaxes] = useState(false);
|
||||
|
||||
const defaultValues: NewProductSchemaType = {
|
||||
const defaultValues: NewPartyEventSchemaType = {
|
||||
sku: '321',
|
||||
name: 'hello product',
|
||||
name: 'hello party event',
|
||||
code: '123',
|
||||
price: 1.1,
|
||||
taxes: 1.1,
|
||||
@@ -171,10 +171,10 @@ export function ProductNewEditForm({ currentProduct }: Props) {
|
||||
saleLabel: { enabled: false, content: '' },
|
||||
};
|
||||
|
||||
const methods = useForm<NewProductSchemaType>({
|
||||
const methods = useForm<NewPartyEventSchemaType>({
|
||||
resolver: zodResolver(NewProductSchema),
|
||||
defaultValues,
|
||||
values: currentProduct,
|
||||
values: currentPartyEvent,
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -204,17 +204,17 @@ export function ProductNewEditForm({ currentProduct }: Props) {
|
||||
|
||||
const sanitizedValues: IPartyEventItem = values as unknown as IPartyEventItem;
|
||||
|
||||
if (currentProduct) {
|
||||
if (currentPartyEvent) {
|
||||
// perform save
|
||||
updateProduct(sanitizedValues);
|
||||
updatePartyEvent(sanitizedValues);
|
||||
} else {
|
||||
// perform create
|
||||
createProduct(sanitizedValues);
|
||||
createPartyEvent(sanitizedValues);
|
||||
}
|
||||
|
||||
toast.success(currentProduct ? 'Update success!' : 'Create success!');
|
||||
toast.success(currentPartyEvent ? 'Update success!' : 'Create success!');
|
||||
|
||||
router.push(paths.dashboard.product.root);
|
||||
router.push(paths.dashboard.partyEvent.root);
|
||||
|
||||
// console.info('DATA', updatedData);
|
||||
} catch (error) {
|
||||
@@ -542,7 +542,7 @@ export function ProductNewEditForm({ currentProduct }: Props) {
|
||||
/>
|
||||
|
||||
<Button type="submit" variant="contained" size="large" loading={isSubmitting}>
|
||||
{!currentProduct ? 'Create product' : 'Save changes'}
|
||||
{!currentPartyEvent ? 'create-party' : 'save-edit'}
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
||||
import { DashboardContent } from 'src/layouts/dashboard';
|
||||
import { paths } from 'src/routes/paths';
|
||||
import { ProductNewEditForm } from '../party-event-new-edit-form';
|
||||
import { PartyEventNewEditForm } from '../party-event-new-edit-form';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -18,7 +18,7 @@ export function PartyEventCreateView() {
|
||||
sx={{ mb: { xs: 3, md: 5 } }}
|
||||
/>
|
||||
|
||||
<ProductNewEditForm />
|
||||
<PartyEventNewEditForm />
|
||||
</DashboardContent>
|
||||
);
|
||||
}
|
||||
|
@@ -2,29 +2,29 @@ import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
||||
import { DashboardContent } from 'src/layouts/dashboard';
|
||||
import { paths } from 'src/routes/paths';
|
||||
import type { IPartyEventItem } from 'src/types/party-event';
|
||||
import { ProductNewEditForm } from '../party-event-new-edit-form';
|
||||
import { PartyEventNewEditForm } from '../party-event-new-edit-form';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = {
|
||||
product?: IPartyEventItem;
|
||||
partyEvent?: IPartyEventItem;
|
||||
};
|
||||
|
||||
export function PartyEventEditView({ product }: Props) {
|
||||
export function PartyEventEditView({ partyEvent }: Props) {
|
||||
return (
|
||||
<DashboardContent>
|
||||
<CustomBreadcrumbs
|
||||
heading="Edit"
|
||||
backHref={paths.dashboard.product.root}
|
||||
backHref={paths.dashboard.partyEvent.root}
|
||||
links={[
|
||||
{ name: 'Dashboard', href: paths.dashboard.root },
|
||||
{ name: 'Product', href: paths.dashboard.product.root },
|
||||
{ name: product?.name },
|
||||
{ name: 'Product', href: paths.dashboard.partyEvent.root },
|
||||
{ name: partyEvent?.name },
|
||||
]}
|
||||
sx={{ mb: { xs: 3, md: 5 } }}
|
||||
/>
|
||||
|
||||
<ProductNewEditForm currentProduct={product} />
|
||||
<PartyEventNewEditForm currentPartyEvent={partyEvent} />
|
||||
</DashboardContent>
|
||||
);
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ type Props = {
|
||||
loading?: boolean;
|
||||
};
|
||||
|
||||
export function ProductShopView({ products, loading }: Props) {
|
||||
export function PartyEventShopView({ products, loading }: Props) {
|
||||
const { state: checkoutState } = useCheckoutContext();
|
||||
|
||||
const openFilters = useBoolean();
|
||||
|
Reference in New Issue
Block a user