booking
This commit is contained in:
@@ -12,6 +12,8 @@ const createSiteSetting = async (body: {
|
||||
longitude: string;
|
||||
telegram: string;
|
||||
instagram: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
email: string;
|
||||
@@ -32,6 +34,8 @@ const updateSiteSetting = async ({
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
telegram: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
instagram: string;
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
|
||||
@@ -15,6 +15,8 @@ export interface GetSiteSetting {
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
telegram: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
instagram: string;
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
@@ -33,6 +35,8 @@ export interface GetDetailSiteSetting {
|
||||
latitude: string;
|
||||
longitude: string;
|
||||
telegram: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
instagram: string;
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
|
||||
@@ -33,6 +33,7 @@ type MapClickEvent = {
|
||||
type ContactInfo = {
|
||||
telegram: string;
|
||||
instagram: string;
|
||||
telegram_chat: string;
|
||||
facebook: string;
|
||||
twiter: string;
|
||||
linkedin: string;
|
||||
@@ -44,7 +45,7 @@ type ContactInfo = {
|
||||
|
||||
async function getAddressFromCoords(lat: number, lon: number) {
|
||||
const response = await fetch(
|
||||
`https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json`,
|
||||
`https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lon}&format=json&accept-language=uz`,
|
||||
);
|
||||
const data = await response.json();
|
||||
return data.display_name || "";
|
||||
@@ -57,6 +58,7 @@ export default function ContactSettings() {
|
||||
const [editing, setEditing] = useState<number | null>(null);
|
||||
const [form, setForm] = useState<ContactInfo>({
|
||||
telegram: "",
|
||||
telegram_chat: "",
|
||||
instagram: "",
|
||||
facebook: "",
|
||||
twiter: "",
|
||||
@@ -80,12 +82,15 @@ export default function ContactSettings() {
|
||||
facebook: string;
|
||||
twitter: string;
|
||||
email: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
main_phone: string;
|
||||
other_phone: string;
|
||||
}) => createSiteSetting(body),
|
||||
onSuccess: () => {
|
||||
setForm({
|
||||
telegram: "",
|
||||
telegram_chat: "",
|
||||
instagram: "",
|
||||
facebook: "",
|
||||
twiter: "",
|
||||
@@ -121,6 +126,8 @@ export default function ContactSettings() {
|
||||
telegram: string;
|
||||
instagram: string;
|
||||
facebook: string;
|
||||
telegram_chat: string;
|
||||
linkedin: string;
|
||||
twitter: string;
|
||||
email: string;
|
||||
main_phone: string;
|
||||
@@ -130,6 +137,7 @@ export default function ContactSettings() {
|
||||
onSuccess: () => {
|
||||
setForm({
|
||||
telegram: "",
|
||||
telegram_chat: "",
|
||||
instagram: "",
|
||||
facebook: "",
|
||||
twiter: "",
|
||||
@@ -157,6 +165,7 @@ export default function ContactSettings() {
|
||||
onSuccess: () => {
|
||||
setForm({
|
||||
telegram: "",
|
||||
telegram_chat: "",
|
||||
instagram: "",
|
||||
facebook: "",
|
||||
twiter: "",
|
||||
@@ -207,10 +216,11 @@ export default function ContactSettings() {
|
||||
email: detail.email,
|
||||
facebook: detail.facebook,
|
||||
instagram: detail.instagram,
|
||||
linkedin: detail.twitter,
|
||||
linkedin: detail.linkedin,
|
||||
phonePrimary: detail.main_phone,
|
||||
phoneSecondary: detail.other_phone,
|
||||
telegram: detail.telegram,
|
||||
telegram_chat: detail.telegram_chat,
|
||||
twiter: detail.twitter,
|
||||
});
|
||||
setCoords({
|
||||
@@ -237,14 +247,41 @@ export default function ContactSettings() {
|
||||
};
|
||||
|
||||
const saveContact = () => {
|
||||
const shortLat = Number(coords.latitude.toFixed(6)); // 6ta raqamgacha
|
||||
const shortLat = Number(coords.latitude.toFixed(6));
|
||||
const shortLon = Number(coords.longitude.toFixed(6));
|
||||
|
||||
// Majburiy maydonlar tekshiruvi
|
||||
if (!form.address.trim()) {
|
||||
toast.error(t("Manzilni kiriting!"), {
|
||||
position: "top-center",
|
||||
richColors: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form.phonePrimary.trim() || form.phonePrimary.length < 9) {
|
||||
toast.error(t("Asosiy telefon raqamini to‘g‘ri kiriting!"), {
|
||||
position: "top-center",
|
||||
richColors: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!coords.latitude || !coords.longitude) {
|
||||
toast.error(t("Xaritadan joy tanlang! (latitude/longitude majburiy)"), {
|
||||
position: "top-center",
|
||||
richColors: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (editing) {
|
||||
update({
|
||||
body: {
|
||||
address: form.address,
|
||||
email: form.email,
|
||||
facebook: form.facebook,
|
||||
linkedin: form.linkedin,
|
||||
telegram_chat: form.telegram_chat,
|
||||
instagram: form.instagram,
|
||||
latitude: String(shortLat),
|
||||
longitude: String(shortLon),
|
||||
@@ -259,6 +296,8 @@ export default function ContactSettings() {
|
||||
create({
|
||||
address: form.address,
|
||||
email: form.email,
|
||||
linkedin: form.linkedin,
|
||||
telegram_chat: form.telegram_chat,
|
||||
facebook: form.facebook,
|
||||
instagram: form.instagram,
|
||||
latitude: String(shortLat),
|
||||
@@ -277,6 +316,7 @@ export default function ContactSettings() {
|
||||
instagram: "",
|
||||
facebook: "",
|
||||
twiter: "",
|
||||
telegram_chat: "",
|
||||
linkedin: "",
|
||||
address: "",
|
||||
email: "",
|
||||
@@ -370,12 +410,26 @@ export default function ContactSettings() {
|
||||
</div>
|
||||
<div className="text-sm">{e.telegram || "—"}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Telegram Chat
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
{e.telegram_chat || "—"}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Instagram
|
||||
</div>
|
||||
<div className="text-sm">{e.instagram || "—"}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Instagram
|
||||
</div>
|
||||
<div className="text-sm">{e.linkedin || "—"}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Facebook
|
||||
@@ -438,6 +492,7 @@ export default function ContactSettings() {
|
||||
zoom: 13,
|
||||
}}
|
||||
width="100%"
|
||||
la
|
||||
height="400px"
|
||||
onClick={handleMapClick}
|
||||
>
|
||||
@@ -460,6 +515,13 @@ export default function ContactSettings() {
|
||||
onChange={(e) => handleChange("telegram", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label>Telegram Chat</Label>
|
||||
<Input
|
||||
value={form.telegram_chat || ""}
|
||||
onChange={(e) => handleChange("telegram_chat", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label>Instagram</Label>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user