Skip to content

Commit

Permalink
Merge pull request #274 from LL08-MathematicalModelling-dowell/ft-pranai
Browse files Browse the repository at this point in the history
Ft pranai
  • Loading branch information
Pranai-1 authored Jun 10, 2024
2 parents c5e4c14 + e6f1f6b commit f90659a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 150 deletions.
10 changes: 6 additions & 4 deletions src/pages/scales/report/Booth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,20 @@ function degreesToRadians(degrees) {
}


const handleGoButton = () =>{
const handleGoButton = async() =>{
setSubmitted(true)
if(boothInput<=0 || isNaN(boothInput))
{
setSubmitted(false)
setBoothErr(true)
return
}else{
const response=await axios.get(`https://100035.pythonanywhere.com/addons/register/?shop_number=${boothInput}`)
console.log(response.data.data)
const distance=calculateDistance(latitude,longitude,latitude,longitude)
console.log(distance)
if(distance<=3){
window.location.href=`https://100035.pythonanywhere.com/nps-lite/api/v5/nps-lite-create-scale/?user=False&scale_type=${scaleType}&workspace_id=${workspaceId}&username=HeenaK&scale_id=${scaleId}&channel_name=${channelName}&instance_id=${boothInput}`
window.location.href=`https://100035.pythonanywhere.com/nps-lite/api/v5/nps-lite-create-scale/?user=False&scale_type=${scaleType}&workspace_id=${workspaceId}&username=HeenaK&scale_id=${scaleId}&channel_name=${channelName}&instance_id=${boothInput}`
}else{
setValid(-1)
setSubmitted(false)
Expand All @@ -104,9 +106,9 @@ function degreesToRadians(degrees) {
},[])

async function fetchLocation(){
const response=await axios.get("https://www.qrcodereviews.uxlivinglab.online/api/v6/qrcode-data/22-d4234c7b-77c1-4ed6-8ea1-9417d9ad63d3/")
const response=await axios.get("https://www.qrcodereviews.uxlivinglab.online/api/v6/qrcode-data/22-56d63b0b-5d6c-4d6e-b011-d19a9aa8773b")
const detailedReport = response.data.response.detailed_report;

console.log(response.data)
if (Array.isArray(detailedReport) && detailedReport.length > 0) {


Expand Down
37 changes: 13 additions & 24 deletions src/pages/scales/report/MapComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
import React, { useEffect, useRef } from 'react';
import { GoogleMap, LoadScript } from '@react-google-maps/api';
// src/MapComponent.js
import React from 'react';
import { GoogleMap, LoadScript, MarkerF } from '@react-google-maps/api';

const containerStyle = {
width: '100%',
height: '100%'
};

const MapComponent = ({ lat, lng }) => {
const mapRef = useRef(null);

useEffect(() => {
const initializeMap = async () => {
if (mapRef.current && window.google) {
const { AdvancedMarkerElement } = window.google.maps.marker;

const map = mapRef.current.state.map;
new AdvancedMarkerElement({
position: { lat: parseFloat(lat), lng: parseFloat(lng) },
map: map,
});
}
};

initializeMap().catch((error) => console.error('Error loading Google Maps:', error));
}, [lat, lng]);
const center = {
lat: parseFloat(lat),
lng: parseFloat(lng)
};

return (
<LoadScript googleMapsApiKey="AIzaSyAsH8omDk8y0lSGLTW9YtZiiQ2MkmsF-uQ">
<GoogleMap
mapContainerStyle={containerStyle}
center={{ lat: parseFloat(lat), lng: parseFloat(lng) }}
zoom={10}
onLoad={(map) => (mapRef.current = { state: { map } })}
/>
center={center}
zoom={15}
>
<MarkerF position={center} />
</GoogleMap>
</LoadScript>
);
};
}

export default MapComponent;
157 changes: 41 additions & 116 deletions src/pages/scales/report/NPSScale.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {useState} from "react"
import axios from "axios"
import { useSearchParams } from "react-router-dom";

export default function App() {
const[loading,setLoading]=useState(-1)
const[submitted, setSubmitted]=useState(-1)
Expand All @@ -10,6 +11,9 @@ export default function App() {
const scaleId=searchParams.get("scale_id")
const channelName=searchParams.get("channel")
const instanceName=searchParams.get("instance")
const buttons = Array.from({ length: 11 }, (_, i) => i);



async function submit(index){
setSubmitted(index)
Expand All @@ -31,7 +35,7 @@ export default function App() {

try {
const response = await axios.post("https://100035.pythonanywhere.com/nps/api/v5/nps-create-response/", body, { headers });

console.log(response.data)
if(response.data.success=="true"){
console.log("redirecting.....")
window.location.href=response.data.redirect_url
Expand All @@ -44,128 +48,49 @@ export default function App() {

return (
<div className="w-full flex flex-col justify-center items-center ">
<p className="mt-[150px] text-[20px]">Give your feedback</p>
<p className="mt-5 text-[16px] sm:text-[20px] font-bold">Give your feedback</p>
<p className="mt-3 text-[14px]">Stand/Shop Number</p>
<p className="w-[190px] border-2 h-[50px] rounded-3xl flex items-center justify-center">1</p>
<p className=" w-[80px] sm:w-[150px] border-2 h-[30px] sm:h-[50px] mt-2 rounded-3xl flex items-center justify-center">1</p>
<div className="flex flex-col justify-center items-center font-sans font-medium p-3 mt-5 text-[20px] text-[#E45E4C]">
<p className="font-sans font-bold font-medium text-[20px] text-[#E45E4C] text-center">
<p className="font-sans sm:font-bold font-medium text-[14px] sm:text-[20px] text-[#E45E4C] text-center">
Would you like to use our products/services

</p>
</div>
{/* <p className="text-[14px]">(Low)0-10(High)</p> */}
<div className="w-max flex flex-col">
<div className="flex justify-center items-center gap-1 sm:gap-3 bg-white p-2 md:p-4 lg:px-8 w-max">
<style>
{`
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.loader {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
}
`}
</style>
<button
key="0"
onClick={()=>submit(0)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200 "
>
{submitted==0 ? <div className="loader"></div> : 0}
</button>

<button
key="1"
onClick={()=>submit(1)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==1 ? <div className="loader"></div> : 1}
</button>

<button
key="2"
onClick={()=>submit(2)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==2 ? <div className="loader"></div> : 2}
</button>
<button
key="3"
onClick={()=>submit(3)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==3 ? <div className="loader"></div> : 3}
</button>

<button
key="4"
onClick={()=>submit(4)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==4 ? <div className="loader"></div> : 4}
</button>

<button
key="5"
onClick={()=>submit(5)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==5 ? <div className="loader"></div> : 5}
</button>

<button
key="6"
onClick={()=>submit(6)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==6 ? <div className="loader"></div> : 6}
</button>

<button
key="7"
onClick={()=>submit(7)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==7 ? <div className="loader"></div> : 7}
</button>

<button
key="8"
onClick={()=>submit(8)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==8 ? <div className="loader"></div> : 8}
</button>

<button
key="9"
onClick={()=>submit(9)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==9 ? <div className="loader"></div> : 9}
</button>

<button
key="10"
onClick={()=>submit(10)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted==10 ? <div className="loader"></div> : 10}
</button>

</div>
<div className="w-full flex p-2 justify-between items-center text-[12px] sm:text-[14px] ">


<div className="flex justify-center items-center gap-1 sm:gap-3 bg-white p-2 md:p-4 lg:px-8 w-max">
<style>
{`
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.loader {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
}
`}
</style>
{buttons.map((value) => (
<button
key={value}
onClick={() => submit(value)}
className="md:text-[20px] sm:text-[14px] py-[2px] px-[6px] sm:p-2 sm:px-3 rounded-full md:px-4 cursor-pointer bg-[#FCEAD4] text-[#F7B75F] font-bold hover:bg-green-200"
>
{submitted === value ? <div className="loader"></div> : value}
</button>
))}
</div>
<div className="w-full flex justify-center items-center gap-24 sm:gap-48 text-[12px] sm:text-[14px] ">
<p>low</p>
<p>Average</p>
<p>High</p>
Expand Down
12 changes: 6 additions & 6 deletions src/pages/scales/report/NpsScaleTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ setSubmitted(index)

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 className="flex justify-center items-center font-sans font-medium p-3 mt-5 text-[12px] sm:text-[18px] text-orange-600">
Would you like to use our product/ service?
</p>

<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]">
<div className="flex justify-center items-center gap-6 md:gap-12 text-[12px] sm:text-[14px] md:text-[18px]">
<style>
{`
@keyframes spin {
Expand All @@ -71,21 +71,21 @@ setSubmitted(index)
`}
</style>
<button
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"
className="bg-[#ff4a4a] rounded-lg p-[9px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(0)}
>
{submitted==0 ? <div className="loader"></div> : "Bad 😞"}

</button>
<button
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"
className="bg-[#f3dd1f] rounded-lg p-[9px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(1)}
>
{submitted==1 ? <div className="loader"></div> : " Average 😐"}

</button>
<button
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"
className="bg-[#129561] rounded-lg p-[9px] sm:p-2 sm:px-6 md:p-4 md:px-12 sm:font-medium cursor-pointer"
onClick={() => submit(2)}
>
{submitted==2 ? <div className="loader"></div> : "Excellent 😄"}
Expand Down

0 comments on commit f90659a

Please sign in to comment.