Skip to content

Commit

Permalink
fix: drawer content views on examples (refinedev#3904)
Browse files Browse the repository at this point in the history
  • Loading branch information
salihozdemir authored Mar 17, 2023
1 parent ee0f25e commit f71366d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
17 changes: 14 additions & 3 deletions examples/finefoods-antd/src/components/product/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslate, useApiUrl } from "@refinedev/core";
import { Create, getValueFromEvent, useSelect } from "@refinedev/antd";

import {
Drawer,
DrawerProps,
Form,
FormProps,
Expand All @@ -21,7 +22,6 @@ import {
const { Text } = Typography;

import { ICategory } from "interfaces";
import { Drawer } from "./styled";

type CreateProductProps = {
drawerProps: DrawerProps;
Expand All @@ -46,10 +46,21 @@ export const CreateProduct: React.FC<CreateProductProps> = ({
<Drawer
{...drawerProps}
width={breakpoint.sm ? "500px" : "100%"}
bodyStyle={{ padding: 0 }}
zIndex={1001}
>
<Create resource="products" saveButtonProps={saveButtonProps}>
<Create
resource="products"
saveButtonProps={saveButtonProps}
goBack={false}
contentProps={{
style: {
boxShadow: "none",
},
bodyStyle: {
padding: 0,
},
}}
>
<Form
{...formProps}
layout="vertical"
Expand Down
15 changes: 12 additions & 3 deletions examples/finefoods-antd/src/components/product/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTranslate, useApiUrl } from "@refinedev/core";
import { useTranslate, useApiUrl, BaseKey } from "@refinedev/core";

import { Edit, getValueFromEvent, useSelect } from "@refinedev/antd";

Expand Down Expand Up @@ -27,12 +27,14 @@ type EditProductProps = {
drawerProps: DrawerProps;
formProps: FormProps;
saveButtonProps: ButtonProps;
editId?: BaseKey;
};

export const EditProduct: React.FC<EditProductProps> = ({
drawerProps,
formProps,
saveButtonProps,
editId,
}) => {
const t = useTranslate();
const apiUrl = useApiUrl();
Expand All @@ -46,13 +48,20 @@ export const EditProduct: React.FC<EditProductProps> = ({
<Drawer
{...drawerProps}
width={breakpoint.sm ? "500px" : "100%"}
bodyStyle={{ padding: 0 }}
zIndex={1001}
>
<Edit
saveButtonProps={saveButtonProps}
headerProps={{ extra: null }}
resource="products"
recordItemId={editId}
contentProps={{
style: {
boxShadow: "none",
},
bodyStyle: {
padding: 0,
},
}}
>
<Form {...formProps} layout="vertical">
<Form.Item label={t("products.fields.images.label")}>
Expand Down
9 changes: 0 additions & 9 deletions examples/finefoods-antd/src/components/product/styled.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions examples/finefoods-antd/src/pages/products/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const ProductList: React.FC<IResourceComponentsProps> = () => {
formProps: editFormProps,
saveButtonProps: editSaveButtonProps,
show: editShow,
id: editId,
} = useDrawerForm<IProduct>({
action: "edit",
resource: "products",
Expand Down Expand Up @@ -161,6 +162,7 @@ export const ProductList: React.FC<IResourceComponentsProps> = () => {
drawerProps={editDrawerProps}
formProps={editFormProps}
saveButtonProps={editSaveButtonProps}
editId={editId}
/>
</div>
);
Expand Down
21 changes: 20 additions & 1 deletion examples/form-antd-use-drawer-form/src/pages/posts/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ export const PostList: React.FC<IResourceComponentsProps> = () => {
</Table>
</List>
<Drawer {...createDrawerProps}>
<Create saveButtonProps={createSaveButtonProps}>
<Create
saveButtonProps={createSaveButtonProps}
goBack={false}
contentProps={{
style: {
boxShadow: "none",
},
bodyStyle: {
padding: 0,
},
}}
>
<Form {...createFormProps} layout="vertical">
<Form.Item
label="Title"
Expand Down Expand Up @@ -143,6 +154,14 @@ export const PostList: React.FC<IResourceComponentsProps> = () => {
disabled: formLoading,
}}
deleteButtonProps={deleteButtonProps}
contentProps={{
style: {
boxShadow: "none",
},
bodyStyle: {
padding: 0,
},
}}
>
<Form {...editFormProps} layout="vertical">
<Form.Item
Expand Down

0 comments on commit f71366d

Please sign in to comment.