Skip to content

Commit

Permalink
Scale page
Browse files Browse the repository at this point in the history
  • Loading branch information
norahwinda committed Jun 5, 2024
2 parents 6ba1a87 + 9b5f2b7 commit 2bea402
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 33 deletions.
Binary file added public/dowell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 45 additions & 19 deletions src/pages/scales/report/Booth.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,63 @@
// import React from 'react'
// import { useState, useEffect} from 'react';
// import { Link, useParams, useSearchParams } from "react-router-dom";

// const Booth = () => {

// const [boothInput, setBoothInput] = useState()

// const [searchParams, setSearchParams] = useSearchParams();
// const workspaceId=searchParams.get("workspace_id")
// const scaleId=searchParams.get("scale_id")
// const channelName=searchParams.get("channel_name")
// console.log(searchParams.get("scale_id"))


// const handleGoButton = () =>{
// console.log(boothInput)
// }
// return (
// <div className='flex flex-col items-center mt-10 w-[320px] h-[550px] m-auto'>
// <img className='mt-10' src='https://cdn.discordapp.com/attachments/1108341894162952192/1247115439675277424/image.png?ex=665eda43&is=665d88c3&hm=f56e39dc3fdcc0568aaa30ee96283958693cb3909acc5dea18373633d5fc9f07&' alt='booth image'/>
// <h3 className='mt-[140px]'>Please enter your booth number</h3>
// <input name='boothInput' value={boothInput} onChange={(e) =>setBoothInput(e.target.value)} type='number' className='w-[150px] h-[30px] border-2 border-black mt-5' />
// <button className='w-[70px] h-[30px] rounded-lg mt-[50px] bg-orange-500 font-medium'
// onClick={handleGoButton}><Link to={`http://127.0.0.1:8000/nps-lite/api/v5/nps-lite-create-scale/?user=True&scale_type=nps_lite&workspace_id=${workspaceId}&username=Paolo&scale_id=${scaleId}&channel_name=${channelName}&instance_name=${boothInput}`}>Go</Link></button>
// </div>

// )
// }

// export default Booth


import React from 'react'
import { useState, useEffect} from 'react';
import { Link, useParams, useSearchParams } from "react-router-dom";
import { useLocation } from "react-router-dom";

import logo from "../../../../public/dowell.png"
const Booth = () => {

const [boothInput, setBoothInput] = useState()
const {slug}=useParams()
console.log(slug)
const search = useLocation().search;
const scale_id =new URLSearchParams(search).get("scale_id");
const workspace_id =new URLSearchParams(search).get("workspace_id");
const username =new URLSearchParams(search).get("username");
const chanelName =new URLSearchParams(search).get("channel_name");
const [boothInput, setBoothInput] = useState(0)

const [searchParams, setSearchParams] = useSearchParams();
console.log(searchParams.get("scale_id"))
let currentUrlParams = new URLSearchParams(window.location.search);
const workspaceId=searchParams.get("workspace_id")
const scaleId=searchParams.get("scale_id")
const channelName=searchParams.get("channel_name")
console.log(scaleId,channelName,workspaceId)

// useEffect(()=>{
// setSearchParams({ scale_id: "665a8277d5d158ec8391aaf7" });
// }, [])

const handleGoButton = () =>{
console.log(boothInput)
window.location.href=`https://100035.pythonanywhere.com/nps-lite/api/v5/nps-lite-create-scale/?user=False&scale_type=nps_lite&workspace_id=${workspaceId}&username=HeenaK&scale_id=${scaleId}&channel_name=${channelName}&instance_id=${boothInput}`
}
return (
<div className='flex flex-col items-center mt-10 w-[320px] h-[550px] m-auto'>
<img className='mt-10' src='https://cdn.discordapp.com/attachments/1108341894162952192/1247115439675277424/image.png?ex=665eda43&is=665d88c3&hm=f56e39dc3fdcc0568aaa30ee96283958693cb3909acc5dea18373633d5fc9f07&' alt='booth image'/>
<img className='mt-10' src={logo} alt='booth image'/>
<h3 className='mt-[140px]'>Please enter your booth number</h3>
<input name='boothInput' value={boothInput} onChange={(e) =>setBoothInput(e.target.value)} type='number' className='w-[150px] h-[30px] border-2 border-black mt-5' />
<button className='w-[70px] h-[30px] rounded-lg mt-[100px] bg-[#FEC39C]'
onClick={handleGoButton}><Link to={`https://100035.pythonanywhere.com/nps-lite/api/v5/nps-lite-create-scale/?user=False&scale_type=nps_lite&workspace_id=${workspace_id}&username=${username}&scale_id=${scale_id}&channel_name=${chanelName}&instance_id=${boothInput}`}>Go</Link></button>
<button className='w-[70px] h-[30px] rounded-lg mt-[50px] bg-orange-500 font-medium'
onClick={handleGoButton}>GO</button>
</div>

)
}

Expand Down
54 changes: 40 additions & 14 deletions src/pages/scales/report/NpsScaleTest.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
import React from 'react'
import { useState, useEffect} from 'react';
import { useSearchParams } from "react-router-dom";

import axios from "axios"
const NpsScaleTest = () => {

const [searchParams, setSearchParams] = useSearchParams({});
let currentUrlParams = new URLSearchParams(window.location.search);
const [searchParams, setSearchParams] = useSearchParams();
const workspaceId=searchParams.get("workspace_id")
const scaleId=searchParams.get("scale_id")
const channelName=searchParams.get("channel_name")
const instanceName=searchParams.get("instance")

async function submit(index){
console.log(index)
const headers = {
"Content-Type": "application/json"
};


const body = {
"scale_id":scaleId,
"workspace_id": workspaceId,
"username": "CustomerSupport",
"scale_type": "nps_lite",
"user_type": true,
"score": index,
"channel": channelName,
"instance": instanceName
};

try {
const response = await axios.post("https://100035.pythonanywhere.com/nps-lite/api/v5/nps-lite-create-response/", body, { headers });
console.log(response.data);
} catch (error) {
console.error("Error submitting response:", error.response ? error.response.data : error.message);
}
}

useEffect(()=>{
setSearchParams({ scale_id: "665a8277d5d158ec8391aaf7", channel:"channel_1", instance: "instance_1" });
}, [])
return (
<div className='flex flex-col justify-center items-center font-sans font-medium p-3 mt-5 text-base m-auto w-full'>
<p className="flex justify-center items-center font-sans font-medium p-3 mt-5 text-base">
How was your experience using our product? Please rate your experience below.
</p>

<div className="flex border p-5 justify-center items-center mt-5">
<div className="flex justify-center items-center gap-6 md:gap-12 mt-5">
<div className="flex border md:p-5 p-2 justify-center items-center mt-5">
<div className="flex justify-center items-center gap-6 md:gap-12 md:mt-5 text-[12px] sm:text-[14px] md:text-[18px]">
<button
className="bg-[#ff4a4a] rounded-lg p-1 px-3 sm:p-2 sm:px-6 md:p-4 md:px-12 text-base sm:font-medium cursor-pointer"
onClick={() => window.location.href ="https://100035.pythonanywhere.com/addons/create-response/v3/?user=True&scale_type=nps_lite&channel=channel_1&instance=instances_1&workspace_id=6385c0e68eca0fb652c9449a&username=CustomerSupport&scale_id=665ee1738c9b16f4f9967dd1&item=0"}
className="bg-[#ff4a4a] rounded-lg py-[6px] px-[3px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(0)}
>
Bad 😞
</button>
<button
className="bg-[#f3dd1f] rounded-lg p-1 px-3 sm:p-2 sm:px-6 md:p-4 md:px-12 text-base sm:font-medium cursor-pointer"
onClick={() => window.location.href ="https://100035.pythonanywhere.com/addons/create-response/v3/?user=True&scale_type=nps_lite&channel=channel_1&instance=instances_1&workspace_id=6385c0e68eca0fb652c9449a&username=CustomerSupport&scale_id=665ee1738c9b16f4f9967dd1&item=1"}
className="bg-[#f3dd1f] rounded-lg py-[6px] px-[3px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(1)}
>
Average 😐
</button>
<button
className="bg-[#129561] rounded-lg p-1 px-3 sm:p-2 sm:px-6 md:p-4 md:px-12 text-base sm:font-medium cursor-pointer"
onClick={() => window.location.href = "https://100035.pythonanywhere.com/addons/create-response/v3/?user=True&scale_type=nps_lite&channel=channel_1&instance=instances_1&workspace_id=6385c0e68eca0fb652c9449a&username=CustomerSupport&scale_id=665ee1738c9b16f4f9967dd1&item=2"}
className="bg-[#129561] rounded-lg py-[6px] px-[3px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(2)}
>
Excellent 😄
</button>
Expand Down

0 comments on commit 2bea402

Please sign in to comment.