This commit is contained in:
zadit
2024-10-20 23:41:35 +07:00
parent 45b958642b
commit e2522bd91c
9 changed files with 146 additions and 97 deletions

View File

@@ -421,6 +421,7 @@ function App() {
guestSideOfClerk={guestSideOfClerk} guestSideOfClerk={guestSideOfClerk}
removeConnectedGuestSides={rmConnectedGuestSides} removeConnectedGuestSides={rmConnectedGuestSides}
setModal={setModal} // Pass the function to open modal setModal={setModal} // Pass the function to open modal
loading={shop.name==null}
/> />
<Footer <Footer
showTable={true} showTable={true}

View File

@@ -20,7 +20,7 @@ const Title = styled.h2`
font-family: "Poppins", sans-serif; font-family: "Poppins", sans-serif;
font-weight: 500; font-weight: 500;
font-style: normal; font-style: normal;
font-size: 32px; font-size: 6vw;
color: rgba(88, 55, 50, 1); color: rgba(88, 55, 50, 1);
`; `;
@@ -91,6 +91,7 @@ const ProfileImage = styled.img`
width: 60px; width: 60px;
height: 60px; height: 60px;
border-radius: 50%; border-radius: 50%;
object-fit: contain;
cursor: pointer; cursor: pointer;
z-index: 199; z-index: 199;
animation: ${(props) => { animation: ${(props) => {

View File

@@ -5,7 +5,6 @@
} }
.item { .item {
border-top: 2px solid #00000017;
display: flex; display: flex;
align-items: stretch; align-items: stretch;
justify-content: space-between; justify-content: space-between;
@@ -20,7 +19,9 @@
padding-top: 10px; padding-top: 10px;
margin-bottom: -3px; margin-bottom: -3px;
} }
.item:not(.itemInvoice) {
border-top: 2px solid #00000017;
}
.itemInvoice { .itemInvoice {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;

View File

@@ -90,8 +90,8 @@
z-index: 100; z-index: 100;
background-color: #0000008c; background-color: #0000008c;
width: 100%; width: 100%;
top: 0; top: 7px;
bottom: 0; bottom: -10px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

View File

@@ -147,7 +147,7 @@
} }
.expand-button:hover { .expand-button:hover {
background-color: rgb(29, 185, 84); background-color: #73a585;
} }
/* Adjust height of the music player container when expanded */ /* Adjust height of the music player container when expanded */

View File

@@ -28,6 +28,11 @@ export function MusicPlayer({ socket, shopId, user, isSpotifyNeedLogin }) {
const [subtitleBG, setSubtitleBG] = useState("white"); const [subtitleBG, setSubtitleBG] = useState("white");
const [backgroundImage, setBackgroundImage] = useState(""); const [backgroundImage, setBackgroundImage] = useState("");
const [videoSrc, setVideoSrc] = useState('');
const videoRef = useRef(null);
useEffect(() => { useEffect(() => {
const getDominantColor = async (imageSrc) => { const getDominantColor = async (imageSrc) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -144,6 +149,40 @@ export function MusicPlayer({ socket, shopId, user, isSpotifyNeedLogin }) {
}; };
}, [socket]); }, [socket]);
// useEffect for setting up the socket listener
useEffect(() => {
const handleUpdateCanvas = (response) => {
if (response) {
fetch(response)
.then((response) => response.blob())
.then((blob) => {
const blobUrl = URL.createObjectURL(blob);
setVideoSrc(blobUrl);
if (videoRef.current) {
videoRef.current.load(); // Reload the video element
}
})
.catch((error) => console.error('Error loading video:', error));
}
else{
setVideoSrc('');
if (videoRef.current) {
videoRef.current.load(); // Reload the video element
}
}
};
// Listen for the "updateCanvas" event
socket.on("updateCanvas", handleUpdateCanvas);
// Clean up the socket listener when the component is unmounted
return () => {
socket.off("updateCanvas", handleUpdateCanvas);
};
}, [socket]);
useEffect(() => { useEffect(() => {
// Simulate progress every 100ms // Simulate progress every 100ms
const interval = setInterval(() => { const interval = setInterval(() => {
@@ -312,23 +351,31 @@ export function MusicPlayer({ socket, shopId, user, isSpotifyNeedLogin }) {
<div <div
onClick={toggleView} onClick={toggleView}
className="current-bgr" className="current-bgr"
style={{ backgroundImage: `url(${backgroundImage})` }} style={{ backgroundImage: `url(${videoSrc != ""? '':backgroundImage})` }}
> >
{currentLines.past.map((line, index) => ( <video
<div className="past" style={{ color: subtitleColor, ref={videoRef}
textShadow: `2px 2px 2px ${subtitleBG}`, }} key={index}> autoPlay
<p>{line.words}</p> loop
</div> playsInline
))} muted
style={{ height: '100%', width: '100%', objectFit: 'cover', position:'absolute', top:0,right:0,zIndex:-1}}
>
{videoSrc && <source src={videoSrc} type="video/mp4" />}
</video>
{currentLines.present.map((line, index) => ( {currentLines.present.map((line, index) => (
<div className="present" style={{ color: subtitleColor, <div className="present" style={{
textShadow: `2px 2px 2px ${subtitleBG}`, }} key={index}> color: subtitleColor,
textShadow: `2px 2px 2px ${subtitleBG}`,
}} key={index}>
<p>{line.words}</p> <p>{line.words}</p>
</div> </div>
))} ))}
{currentLines.future.map((line, index) => ( {currentLines.future.map((line, index) => (
<div className="future" style={{ color: subtitleColor, <div className="future" style={{
textShadow: `2px 2px 2px ${subtitleBG}`, }} key={index}> color: subtitleColor,
textShadow: `2px 2px 2px ${subtitleBG}`,
}} key={index}>
<p>{line.words}</p> <p>{line.words}</p>
</div> </div>
))} ))}

View File

@@ -1,5 +1,5 @@
// src/config.js // src/config.js
const API_BASE_URL = 'https://9qc65z-5000.csb.app'; const API_BASE_URL = 'https://api.kedaimaster.com';
export default API_BASE_URL; export default API_BASE_URL;

View File

@@ -38,6 +38,7 @@ function CafePage({
guestSideOfClerk, guestSideOfClerk,
removeConnectedGuestSides, removeConnectedGuestSides,
setModal, setModal,
loading,
}) { }) {
const location = useLocation(); const location = useLocation();
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
@@ -47,7 +48,6 @@ function CafePage({
const navigate = useNavigate(); const navigate = useNavigate();
const [loading, setLoading] = useState(true);
const [screenMessage, setScreenMessage] = useState(""); const [screenMessage, setScreenMessage] = useState("");
const [isSpotifyNeedLogin, setNeedSpotifyLogin] = useState(true); const [isSpotifyNeedLogin, setNeedSpotifyLogin] = useState(true);
@@ -117,7 +117,6 @@ function CafePage({
socket.on("joined-room", (response) => { socket.on("joined-room", (response) => {
const { isSpotifyNeedLogin } = response; const { isSpotifyNeedLogin } = response;
setNeedSpotifyLogin(isSpotifyNeedLogin); setNeedSpotifyLogin(isSpotifyNeedLogin);
setLoading(false);
}); });
} }

View File

@@ -20,7 +20,7 @@
.circular-image { .circular-image {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: contain;
} }
.welcoming-text { .welcoming-text {