PageSourceSearch

https://mitiendapos.com.ar/assets/controllers/place_id_verify_controller-43881430.js

js mitiendapos.com.ar collected 2026-09-24 14:36:15 UTC 1,666 bytes, 51 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3// Connects to data-controller="place-id-verify"
4export default class extends Controller {
5  static targets = ["input", "result"]
6  static values = { url: String }
7
8  get _placeIdField() {
9    return document.querySelector('input[name="club[google_place_id]"]')
10  }
11
12  async verify(event) {
13    event.preventDefault()
14    const url = this.inputTarget.value.trim()
15    if (!url) {
16      this._render("err", "Pegá primero una URL de Google Maps.")
17      return
18    }
19
20    this._render("loading", "Verificando…")
21
22    try {
23      const csrf = document.querySelector("meta[name=csrf-token]")?.content
24      const response = await fetch(this.urlValue, {
25        method: "POST",
26        headers: {
27          "Content-Type": "application/json",
28          "Accept": "application/json",
29          "X-CSRF-Token": csrf || ""
30        },
31        body: JSON.stringify({ url })
32      })
33      const data = await response.json()
34      if (response.ok && data.ok) {
35        const field = this._placeIdField
36        if (field) field.value = data.place_id
37        this._render("ok", `Listing encontrado — se va a vincular al guardar: ${data.place_id}`)
38      } else {
39        this._render("err", data.error || "No pude resolver el link.")
40      }
41    } catch (e) {
42      this._render("err", "Error de red. Intentá de nuevo.")
43    }
44  }
45
46  _render(kind, message) {
47    const color = { ok: "text-emerald-600", err: "text-red-600", loading: "text-gray-500" }[kind]
48    const icon = { ok: "✓", err: "✗", loading: "…" }[kind]
49    this.resultTarget.innerHTML = `<p class="text-[11px] ${color} mt-1">${icon} ${message}</p>`
50  }
51}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.