dsg
INSERT INTO `cp_filejs` (`id`,`app`,`path`,`modul`,`file_name`,`content`) VALUES ('216','3','u7/collector','','js/api/scanner.js-','import {\r\n getSessionUser\r\n} from \\\"./auth.js\\\"\r\nimport {\r\n API_URL\r\n} from \\\"./consts.js\\\"\r\n\r\nexport const verifyScan = async (decodedText) => {\r\n const user = await getSessionUser()\r\n\r\n const response = await fetch(`${API_URL}/wp-json/app/v1/verify-qr-code`, {\r\n method: \\\"POST\\\",\r\n headers: {\r\n \\\"Content-Type\\\": \\\"application/json\\\",\r\n },\r\n body: JSON.stringify({\r\n user_id: user?.id,\r\n qr_code: decodedText\r\n }),\r\n })\r\n\r\n const data = await response.json()\r\n return data\r\n}\r\n\r\nconst linkProfile = async (decodedText) => {\r\n const user = await getSessionUser()\r\n\r\n const response = await fetch(`${API_URL}/wp-json/app/v1/link-qr-code-entity`, {\r\n cache: \\\"no-cache\\\",\r\n method: \\\"POST\\\",\r\n headers: {\r\n \\\"Content-Type\\\": \\\"application/json\\\",\r\n },\r\n body: JSON.stringify({\r\n entity_id: user?.id,\r\n qr_code: decodedText,\r\n entity_type: \\\"profile\\\"\r\n }),\r\n })\r\n\r\n const data = await response.json()\r\n return data\r\n}\r\n\r\nconst unlinkProfile = async (decodedText) => {\r\n const user = await getSessionUser()\r\n\r\n const response = await fetch(`${API_URL}/wp-json/app/v1/unlink-qr-code-entity`, {\r\n cache: \\\"no-cache\\\",\r\n method: \\\"POST\\\",\r\n headers: {\r\n \\\"Content-Type\\\": \\\"application/json\\\",\r\n },\r\n body: JSON.stringify({\r\n qr_code: decodedText,\r\n entity_id: user?.id,\r\n entity_type: \\\"profile\\\"\r\n }),\r\n })\r\n\r\n const data = await response.json()\r\n return data\r\n}\r\n\r\nexport const getIDFromQrCode = async (decodedText) => {\r\n const response = await fetch(`${API_URL}/wp-json/app/v1/get-linked-entity`, {\r\n cache: \\\"no-cache\\\",\r\n method: \\\"POST\\\",\r\n headers: {\r\n \\\"Content-Type\\\": \\\"application/json\\\",\r\n },\r\n body: JSON.stringify({\r\n qr_code: decodedText\r\n }),\r\n })\r\n\r\n const data = await response.json()\r\n\r\n if ((data && data.error) || response.status === 404) {\r\n throw new Error(data.error)\r\n }\r\n\r\n return data\r\n}\r\n\r\nexport const handleLink = async (result) => {\r\n if (!result) {\r\n return\r\n }\r\n\r\n try {\r\n const response = await linkProfile(result?.qr_code)\r\n return response\r\n } catch (e) {\r\n console.error(\\\"Error linking profile\\\", e)\r\n return {\r\n status: \\\\\\\'error\\\\\\\',\r\n text: \\\\\\\'Error linking profile\\\\\\\'\r\n }\r\n }\r\n}\r\n\r\nexport const handleUnlink = async (result) => {\r\n if (!result) {\r\n return\r\n }\r\n\r\n try {\r\n const response = await unlinkProfile(result?.qr_code)\r\n\r\n if (response.status === \\\\\\\'error\\\\\\\') {\r\n return {\r\n type: \\\\\\\'error\\\\\\\',\r\n text: response.message\r\n }\r\n } else {\r\n return {\r\n type: \\\\\\\'success\\\\\\\',\r\n text: response.message\r\n }\r\n }\r\n\r\n } catch (e) {\r\n console.error(\\\"Error unlinking profile\\\", e)\r\n return {\r\n type: \\\\\\\'error\\\\\\\',\r\n text: \\\\\\\'Error unlinking profile\\\\\\\'\r\n }\r\n }\r\n}');
Copy This

Warning: file_get_contents(/home/u340524018/domains/agniaga.com/public_html/sub/u7/collector/js/api/scanner.js-): Failed to open stream: No such file or directory in /home/u340524018/domains/agniaga.com/public_html/sub/u2/cp/inc.filejs.php on line 190
import {
    getSessionUser
} from \"./auth.js\"
import {
    API_URL
} from \"./consts.js\"

export const verifyScan = async (decodedText) => {
    const user = await getSessionUser()

    const response = await fetch(`${API_URL}/wp-json/app/v1/verify-qr-code`, {
        method: \"POST\",
        headers: {
            \"Content-Type\": \"application/json\",
        },
        body: JSON.stringify({
            user_id: user?.id,
            qr_code: decodedText
        }),
    })

    const data = await response.json()
    return data
}

const linkProfile = async (decodedText) => {
    const user = await getSessionUser()

    const response = await fetch(`${API_URL}/wp-json/app/v1/link-qr-code-entity`, {
        cache: \"no-cache\",
        method: \"POST\",
        headers: {
            \"Content-Type\": \"application/json\",
        },
        body: JSON.stringify({
            entity_id: user?.id,
            qr_code: decodedText,
            entity_type: \"profile\"
        }),
    })

    const data = await response.json()
    return data
}

const unlinkProfile = async (decodedText) => {
    const user = await getSessionUser()

    const response = await fetch(`${API_URL}/wp-json/app/v1/unlink-qr-code-entity`, {
        cache: \"no-cache\",
        method: \"POST\",
        headers: {
            \"Content-Type\": \"application/json\",
        },
        body: JSON.stringify({
            qr_code: decodedText,
            entity_id: user?.id,
            entity_type: \"profile\"
        }),
    })

    const data = await response.json()
    return data
}

export const getIDFromQrCode = async (decodedText) => {
    const response = await fetch(`${API_URL}/wp-json/app/v1/get-linked-entity`, {
        cache: \"no-cache\",
        method: \"POST\",
        headers: {
            \"Content-Type\": \"application/json\",
        },
        body: JSON.stringify({
            qr_code: decodedText
        }),
    })

    const data = await response.json()

    if ((data && data.error) || response.status === 404) {
        throw new Error(data.error)
    }

    return data
}

export const handleLink = async (result) => {
    if (!result) {
        return
    }

    try {
        const response = await linkProfile(result?.qr_code)
        return response
    } catch (e) {
        console.error(\"Error linking profile\", e)
        return {
            status: \\\'error\\\',
            text: \\\'Error linking profile\\\'
        }
    }
}

export const handleUnlink = async (result) => {
    if (!result) {
        return
    }

    try {
        const response = await unlinkProfile(result?.qr_code)

        if (response.status === \\\'error\\\') {
            return {
                type: \\\'error\\\',
                text: response.message
            }
        } else {
            return {
                type: \\\'success\\\',
                text: response.message
            }
        }

    } catch (e) {
        console.error(\"Error unlinking profile\", e)
        return {
            type: \\\'error\\\',
            text: \\\'Error unlinking profile\\\'
        }
    }
}
Add JS Function Name