1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { create } from "zustand";
const center = {
lat: -6.200000, // Default latitude (Jakarta)
lng: 106.816666, // Default longitude (Jakarta)
};
export const useMaps = create((set) => ({
// State existing
selectedPosition: center,
addressMaps: '',
detailAddress: {},
pinedMaps: false,
// State tambahan untuk penyimpanan posisi sementara
tempPositionCreate: null,
tempPositionEdit: null,
// Setter existing
setSelectedPosition: (position) => set({ selectedPosition: position }),
setAddressMaps: (addressMaps) => set({ addressMaps }),
setDetailAddress: (detailAddress) => set({ detailAddress }),
setPinedMaps: (pinedMaps) => set({ pinedMaps }),
// Setter tambahan untuk posisi sementara
setTempPositionCreate: (position) => set({ tempPositionCreate: position }),
setTempPositionEdit: (position) => set({ tempPositionEdit: position }),
// Opsional: Reset jika ingin clear saat keluar halaman
resetTempPositionCreate: () => set({ tempPositionCreate: null }),
resetTempPositionEdit: () => set({ tempPositionEdit: null }),
}));
|