summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/containers/Home.tsx6
-rw-r--r--src/containers/Service/ServiceForm.tsx16
-rw-r--r--src/requests.ts2
-rw-r--r--src/services.js4
4 files changed, 16 insertions, 12 deletions
diff --git a/src/containers/Home.tsx b/src/containers/Home.tsx
index 82fbf25..697cc66 100644
--- a/src/containers/Home.tsx
+++ b/src/containers/Home.tsx
@@ -28,15 +28,15 @@ const cards = [
];
const Home: React.FC = () => (
- <Page title="Главная" actions={[{ name: 'Do nothing' }]}>
+ <Page title="Главная" actions={[{ name: 'Связаться с нами', variant: 'outlined' }]}>
<div className="grid grid-flow-row grid-cols-3">
{cards.map(card => (
- <Paper variant="outlined">
+ <Paper key={card.route} variant="outlined">
<div className="h-full flex flex-col justify-between">
<img className="h-60" src={card.src} alt="Накладная" />
<div className="flex flex-col text-center">
<p className="m-5 text-lg">{card.text}</p>
- <Button size="lg" route="/waybills">{card.name}</Button>
+ <Button size="lg" route={card.route}>{card.name}</Button>
</div>
</div>
</Paper>
diff --git a/src/containers/Service/ServiceForm.tsx b/src/containers/Service/ServiceForm.tsx
index e2dfef6..69cc3c8 100644
--- a/src/containers/Service/ServiceForm.tsx
+++ b/src/containers/Service/ServiceForm.tsx
@@ -4,24 +4,22 @@ import { Formik } from 'formik';
import _ from 'lodash';
import Page, { Action } from '../Page';
import hooks from '../../hooks/useAPIClient';
-import { post, patch } from '../../requests';
+import { post, patch, del } from '../../requests';
import ServiceContext from './ServiceContext';
interface Params {
id: string;
}
-const actions: Action[] = [
- { name: 'Назад', variant: 'outlined', route: '..' },
- { name: 'Сохранить', type: 'submit', form: 'form' },
-];
-
const ServiceForm: React.FC = () => {
const service = useContext(ServiceContext);
const history = useHistory();
const { id } = useParams<Params>();
const { data: item } = hooks[service.route].useItem(id);
+ const handleDelete = () => del(`/${service.route}/${id}`)
+ .then(() => history.push(`/${service.route}`));
+
const onSubmit = (values: any) => {
const promise = id
? patch(`/${service.route}/${id}`, values)
@@ -29,6 +27,12 @@ const ServiceForm: React.FC = () => {
return promise.then(() => history.push(`/${service.route}`));
};
+ const actions: Action[] = [
+ { name: 'Назад', variant: 'outlined', route: '..' },
+ { name: 'Удалить', variant: 'outlined', onClick: handleDelete },
+ { name: 'Сохранить', type: 'submit', form: 'form' },
+ ];
+
return (
<Page title={id ? item?.name : `Новый ${service.nameSingular}`} actions={actions}>
{(!id || item) && (
diff --git a/src/requests.ts b/src/requests.ts
index 2873b37..406127f 100644
--- a/src/requests.ts
+++ b/src/requests.ts
@@ -6,6 +6,6 @@ const baseURL = process.env.NODE_ENV === 'production'
const requests = axios.create({ baseURL });
-export const { get, post, put, patch } = requests;
+export const { get, post, put, patch, delete: del } = requests;
export default requests;
diff --git a/src/services.js b/src/services.js
index bebf07f..f8e27cf 100644
--- a/src/services.js
+++ b/src/services.js
@@ -48,10 +48,10 @@ const services: ServiceParams[] = [
name: 'Накладные',
nameSingular: 'Накладная',
tableFields: [
+ { key: 'status', label: 'Статус', transform: status => waybillStatusNames[status] },
{ key: 'operation', label: 'Операция', transform: op => operationNames[op] },
{ key: 'product.name', label: 'Товар' },
- { key: 'contractor.name', label: 'Поставщик' },
- { key: 'status', label: 'Статус', transform: status => waybillStatusNames[status] },
+ { key: 'contractor.name', label: 'Контрагент' },
{ key: 'quantity', label: 'Количество' },
],
default: {