update
This commit is contained in:
@@ -3,6 +3,7 @@ import DialogTransition from "@/core/components/DialogTransition";
|
||||
import { Close } from "@mui/icons-material";
|
||||
import { Dialog, DialogTitle, IconButton } from "@mui/material";
|
||||
import CreateOrUpdateForm from "../../Forms/CreateOrUpdate";
|
||||
import { SET_INQUIRE_PRIVACY_FENCING } from "@/core/utils/routes";
|
||||
|
||||
const InquiryPrivacyFencingCreate = ({ open, handleClose, mutate }) => {
|
||||
|
||||
@@ -24,7 +25,7 @@ const InquiryPrivacyFencingCreate = ({ open, handleClose, mutate }) => {
|
||||
>
|
||||
<Close />
|
||||
</IconButton>
|
||||
<CreateOrUpdateForm handleClose={handleClose} mutate={mutate} />
|
||||
<CreateOrUpdateForm handleClose={handleClose} mutate={mutate} url={SET_INQUIRE_PRIVACY_FENCING} />
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import LtrTextField from "@/core/components/LtrTextField";
|
||||
import StyledForm from "@/core/components/StyledForm";
|
||||
import { SET_INQUIRE_PRIVACY_FENCING } from "@/core/utils/routes";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import { Autocomplete, Box, Button, Chip, DialogActions, DialogContent, Fade, Grid, InputAdornment, Stack, TextField, Typography } from "@mui/material";
|
||||
import { DatePicker, LocalizationProvider, faIR } from "@mui/x-date-pickers";
|
||||
@@ -66,7 +65,7 @@ const initValues = {
|
||||
ronevesht: '',
|
||||
}
|
||||
|
||||
const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues }) => {
|
||||
const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues, url }) => {
|
||||
const request = useRequest()
|
||||
const { control, watch, register, handleSubmit, setValue, formState: { isSubmitting } } = useForm({ defaultValues: defaultValues || initValues });
|
||||
|
||||
@@ -128,7 +127,7 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues }) => {
|
||||
formData.append('ronevesht', data.ronevesht)
|
||||
|
||||
try {
|
||||
await request(SET_INQUIRE_PRIVACY_FENCING, 'post', { data: formData })
|
||||
await request(url, 'post', { data: formData })
|
||||
handleClose()
|
||||
mutate()
|
||||
} catch (error) {
|
||||
@@ -374,7 +373,7 @@ const CreateOrUpdateForm = ({ handleClose, mutate, defaultValues }) => {
|
||||
<LtrTextField autoComplete="off" {...register('kilometr')} label="كيلومتر *" size="small" fullWidth type="tel" />
|
||||
</Grid>
|
||||
<Grid item xs={1} sm={2} sx={{ height: 300 }}>
|
||||
<LocationOnMap setValue={setValue} />
|
||||
<LocationOnMap setValue={setValue} defaultLatLon={defaultValues ? [defaultValues.lat, defaultValues.lon] : null} defaultValues />
|
||||
</Grid>
|
||||
<Grid item xs={1}>
|
||||
<Stack spacing={3}>
|
||||
|
||||
@@ -9,7 +9,7 @@ const locationMarker = L.icon({
|
||||
iconAnchor: [25, 50],
|
||||
});
|
||||
|
||||
const MarkerLocation = ({ setValue }) => {
|
||||
const MarkerLocation = ({ setValue, defaultLatLon }) => {
|
||||
const location = useRef();
|
||||
const map = useMapEvents({
|
||||
move: (e) => {
|
||||
@@ -25,8 +25,9 @@ const MarkerLocation = ({ setValue }) => {
|
||||
setValue('lon', latlon.lng)
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Marker ref={location} icon={locationMarker} position={map.getCenter()} key="location" />
|
||||
<Marker ref={location} icon={locationMarker} position={defaultLatLon ? L.LatLng(defaultLatLon.lat, defaultLatLon.lon) : map.getCenter()} key="location" />
|
||||
)
|
||||
}
|
||||
export default MarkerLocation
|
||||
@@ -8,12 +8,12 @@ const MapLayer = dynamic(() => import("@/core/components/MapLayer"), {
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
const LocationOnMap = ({ setValue }) => {
|
||||
const LocationOnMap = ({ setValue, defaultLatLon }) => {
|
||||
return (
|
||||
<Stack sx={{ height: "100%", position: "relative" }}>
|
||||
<Paper sx={{ flexGrow: 1, border: 1, borderRadius: 1, borderColor: 'divider' }} elevation={0}>
|
||||
<MapLayer style={{ borderRadius: '4px' }}>
|
||||
<MarkerLocation setValue={setValue} />
|
||||
<MarkerLocation setValue={setValue} defaultLatLon={defaultLatLon} />
|
||||
</MapLayer>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user