Translating Edit and New base page
This commit is contained in:
@@ -4,7 +4,7 @@ import { useParams, Navigate } from "react-router";
|
|||||||
import { Button, CircularProgress } from "@mui/material";
|
import { Button, CircularProgress } from "@mui/material";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import SaveIcon from '@mui/icons-material/Save';
|
import SaveIcon from '@mui/icons-material/Save';
|
||||||
import { useForm } from "@refinedev/core";
|
import { useForm, useTranslation } from "@refinedev/core";
|
||||||
import { DeleteButton } from "@refinedev/mui";
|
import { DeleteButton } from "@refinedev/mui";
|
||||||
import { FirmContext } from "../../../contexts/FirmContext";
|
import { FirmContext } from "../../../contexts/FirmContext";
|
||||||
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
||||||
@@ -19,6 +19,7 @@ type EditProps = {
|
|||||||
const Edit = <T,>(props: EditProps) => {
|
const Edit = <T,>(props: EditProps) => {
|
||||||
const { schemaName, resource, uiSchema } = props;
|
const { schemaName, resource, uiSchema } = props;
|
||||||
const { currentFirm } = useContext(FirmContext);
|
const { currentFirm } = useContext(FirmContext);
|
||||||
|
const { translate: t } = useTranslation();
|
||||||
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
||||||
const { record_id } = useParams();
|
const { record_id } = useParams();
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ const Edit = <T,>(props: EditProps) => {
|
|||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}>
|
}}>
|
||||||
<Button type='submit' variant="contained" size="large"><SaveIcon />Save</Button>
|
<Button type='submit' variant="contained" size="large"><SaveIcon />{t("buttons.save")}</Button>
|
||||||
<DeleteButton variant="contained" size="large" color="error" recordItemId={record_id}/>
|
<DeleteButton variant="contained" size="large" color="error" recordItemId={record_id}/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</CrudForm>
|
</CrudForm>
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { UiSchema } from "@rjsf/utils";
|
import { UiSchema } from "@rjsf/utils";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { useForm } from "@refinedev/core";
|
import { useForm, useTranslation } from "@refinedev/core";
|
||||||
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
import { CrudForm } from "../../../lib/crud/components/crud-form";
|
||||||
import { FirmContext } from "../../../contexts/FirmContext";
|
import { FirmContext } from "../../../contexts/FirmContext";
|
||||||
|
import SaveIcon from "@mui/icons-material/Save";
|
||||||
|
import { Button } from "@mui/material";
|
||||||
|
|
||||||
type NewProps = {
|
type NewProps = {
|
||||||
resource: string,
|
resource: string,
|
||||||
@@ -14,6 +16,7 @@ type NewProps = {
|
|||||||
const New = <T,>(props: NewProps) => {
|
const New = <T,>(props: NewProps) => {
|
||||||
const { schemaName, resource, uiSchema, defaultValue } = props;
|
const { schemaName, resource, uiSchema, defaultValue } = props;
|
||||||
const { currentFirm } = useContext(FirmContext);
|
const { currentFirm } = useContext(FirmContext);
|
||||||
|
const { translate: t } = useTranslation();
|
||||||
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
const resourceBasePath = `firm/${currentFirm.instance}/${currentFirm.firm}`
|
||||||
|
|
||||||
const { onFinish } = useForm({
|
const { onFinish } = useForm({
|
||||||
@@ -29,7 +32,9 @@ const New = <T,>(props: NewProps) => {
|
|||||||
resourceBasePath={resourceBasePath}
|
resourceBasePath={resourceBasePath}
|
||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
onSubmit={(data: any) => onFinish(data)}
|
onSubmit={(data: any) => onFinish(data)}
|
||||||
/>
|
>
|
||||||
|
<Button type='submit' variant="contained" size="large"><SaveIcon />{t("buttons.create")}</Button>
|
||||||
|
</CrudForm>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user