ok
This commit is contained in:
11030
package-lock.json
generated
11030
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
src/App.js
17
src/App.js
@@ -74,6 +74,10 @@ function App() {
|
||||
const [newTransaction, setNewTransaction] = useState({});
|
||||
|
||||
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
const tokenParams = queryParams.get("token");
|
||||
if(tokenParams) localStorage.setItem('auth', tokenParams)
|
||||
|
||||
const validTransactionStates = [
|
||||
'new_transaction',
|
||||
'transaction_canceled',
|
||||
@@ -226,7 +230,7 @@ function App() {
|
||||
});
|
||||
} else {
|
||||
socket.emit("checkUserToken", {
|
||||
token: getLocalStorage("auth"),
|
||||
token: getLocalStorage("auth") || tokenParams,
|
||||
shopId,
|
||||
});
|
||||
}
|
||||
@@ -471,17 +475,6 @@ function App() {
|
||||
};
|
||||
}, [socket, shopId, location]); // Ensure location is in the dependencies to respond to changes in the URL
|
||||
|
||||
// useEffect(() => {
|
||||
// if (user.cafeId != null && user.cafeId !== shopId) {
|
||||
// // Preserve existing query parameters
|
||||
// const currentParams = new URLSearchParams(location.search).toString();
|
||||
|
||||
// // Navigate to the new cafeId while keeping existing params
|
||||
// navigate(`/${user.cafeId}?${currentParams}`, { replace: true });
|
||||
// }
|
||||
|
||||
// }, [user, shopId]);
|
||||
|
||||
function handleMoveToTransaction(direction, from) {
|
||||
console.log(direction);
|
||||
console.log(from);
|
||||
|
||||
@@ -44,10 +44,10 @@ const App = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const shopId = window.location.pathname.split('/')[1]; // Get shopId from the URL
|
||||
const userId = localStorage.getItem('userId');
|
||||
const user_id = localStorage.getItem('user_id');
|
||||
|
||||
// Connect to Socket.IO if userId is present
|
||||
// if (userId) {
|
||||
// Connect to Socket.IO if user_id is present
|
||||
// if (user_id) {
|
||||
// connectSocket(shopId, 1);
|
||||
// }
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ const Header = ({
|
||||
{shopId && user.roleId == 1 && (
|
||||
<Child onClick={goToAdminCafes}>Dashboard</Child>)}
|
||||
{shopId &&
|
||||
user.userId == shopOwnerId &&
|
||||
user.user_id == shopOwnerId &&
|
||||
user.username !== undefined &&
|
||||
user.roleId === 1 && (
|
||||
<>
|
||||
|
||||
@@ -598,7 +598,7 @@ const ItemLister = ({
|
||||
return (
|
||||
<>
|
||||
{(items.length > 0 ||
|
||||
(user && (user.cafeId == shopId || user.userId == shopOwnerId))) && (
|
||||
(user && (user.cafeId == shopId || user.user_id == shopOwnerId))) && (
|
||||
<div
|
||||
key={itemTypeId}
|
||||
className={`${styles["item-lister"]} ${isEdit ? styles["fullscreen"] : ""
|
||||
@@ -866,7 +866,7 @@ const ItemLister = ({
|
||||
<h2 className={styles["item-list-title"]}>{items && items.length < 1 ? 'Buat item' : 'Daftar item'}</h2></div>}
|
||||
<div className={styles["item-list"]}>
|
||||
{user && (
|
||||
user.userId == shopOwnerId || user.cafeId == shopId) &&
|
||||
user.user_id == shopOwnerId || user.cafeId == shopId) &&
|
||||
isEditMode && (
|
||||
<>
|
||||
{!isAddingNewItem && (
|
||||
@@ -1113,7 +1113,7 @@ const ItemLister = ({
|
||||
|
||||
{user &&
|
||||
user.roleId == 1 &&
|
||||
user.userId == shopOwnerId &&
|
||||
user.user_id == shopOwnerId &&
|
||||
isEdit && (
|
||||
<>
|
||||
{/* <button
|
||||
|
||||
@@ -103,7 +103,7 @@ const ItemTypeLister = ({
|
||||
{isEditMode &&
|
||||
!isAddingNewItem &&
|
||||
user && (
|
||||
user.userId == shopOwnerId || user.cafeId == shopId) && (
|
||||
user.user_id == shopOwnerId || user.cafeId == shopId) && (
|
||||
<ItemType
|
||||
onClick={toggleAddNewItem}
|
||||
name={"buat baru"}
|
||||
@@ -111,7 +111,7 @@ const ItemTypeLister = ({
|
||||
/>
|
||||
)}
|
||||
{user &&(
|
||||
user.userId == shopOwnerId || user.cafeId == shopId) &&
|
||||
user.user_id == shopOwnerId || user.cafeId == shopId) &&
|
||||
isAddingNewItem && (
|
||||
<>
|
||||
<ItemLister
|
||||
@@ -141,7 +141,7 @@ const ItemTypeLister = ({
|
||||
itemTypes.map(
|
||||
(itemType) =>
|
||||
(
|
||||
itemType.itemList.length > 0 || (user && (user.userId == shopOwnerId || user.cafeId == shopId))) && (
|
||||
itemType.itemList.length > 0 || (user && (user.user_id == shopOwnerId || user.cafeId == shopId))) && (
|
||||
<ItemType
|
||||
key={itemType.itemTypeId}
|
||||
name={itemType.name}
|
||||
|
||||
@@ -108,7 +108,7 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo
|
||||
// setSubtitleColor("white");
|
||||
// setSubtitleBG("black");
|
||||
// }
|
||||
const proxiedUrl = `https://dev.api.kedaimaster.com/image?url=${encodeURIComponent(modifyUrl(imageUrl))}`; // Use your proxy to fetch the image
|
||||
const proxiedUrl = `https://api.kedaimaster.com/image?url=${encodeURIComponent(modifyUrl(imageUrl))}`; // Use your proxy to fetch the image
|
||||
|
||||
setBackgroundImage(proxiedUrl);
|
||||
} catch (error) {
|
||||
@@ -479,7 +479,7 @@ export function MusicPlayer({ socket, shopId, user, shopOwnerId, isSpotifyNeedLo
|
||||
className={`expandable-container ${expanded ? "expanded" : ""}`}
|
||||
ref={expandableContainerRef}
|
||||
>
|
||||
{user.cafeId == shopId || user.userId == shopOwnerId && (
|
||||
{user.cafeId == shopId || user.user_id == shopOwnerId && (
|
||||
<>
|
||||
<div className="auth-box">
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// src/config.js
|
||||
|
||||
const API_BASE_URL = 'https://dev.api.kedaimaster.com';
|
||||
const API_BASE_URL = 'https://api.kedaimaster.com';
|
||||
|
||||
export default API_BASE_URL;
|
||||
|
||||
@@ -106,10 +106,10 @@ export async function getCafeByIdentifier(cafeIdentifyName) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
export async function getOwnedCafes(userId) {
|
||||
export async function getOwnedCafes(user_id) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/cafe/get-cafe-by-ownerId/` + userId,
|
||||
`${API_BASE_URL}/cafe/get-cafe-by-ownerId/` + user_id,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
||||
@@ -117,10 +117,10 @@ function CafePage({
|
||||
|
||||
useEffect(() => {
|
||||
function fetchData() {
|
||||
console.log(user.userId == shopOwnerId)
|
||||
console.log(user.user_id == shopOwnerId)
|
||||
setModal("create_item");
|
||||
|
||||
}
|
||||
|
||||
console.log(getLocalStorage('auth'))
|
||||
if (getLocalStorage("auth") != null) {
|
||||
const executeFetch = async () => {
|
||||
@@ -129,7 +129,7 @@ function CafePage({
|
||||
}
|
||||
console.log(user)
|
||||
console.log('open')
|
||||
if (user.length != 0 && user.userId == shopOwnerId && shopItems.length == 0) fetchData();
|
||||
if (user.length != 0 && user.user_id == shopOwnerId && shopItems.length == 0) fetchData();
|
||||
};
|
||||
executeFetch();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ const Dashboard = ({ user, setModal }) => {
|
||||
// Create admin functionality
|
||||
createCafeOwner(newItem.email, newItem.username, newItem.password)
|
||||
.then((newitem) => {
|
||||
setItems([...items, { userId: newitem.userId, name: newitem.username }]);
|
||||
setItems([...items, { user_id: newitem.user_id, name: newitem.username }]);
|
||||
setIsCreating(false);
|
||||
setNewItem({ name: "", type: "" });
|
||||
})
|
||||
|
||||
@@ -95,24 +95,20 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Handle login
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
setError(false);
|
||||
setLoading(true);
|
||||
const response = await loginUser(username, password);
|
||||
if (response.success) {
|
||||
localStorage.setItem('auth', response.token);
|
||||
console.log(response)
|
||||
window.location.href = response.cafeIdentifyName ? `/${response.cafeIdentifyName}` : '/';
|
||||
} else {
|
||||
setError(true);
|
||||
}
|
||||
} catch (error) {
|
||||
setError(true);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
const handleLogin = () => {
|
||||
const baseUrl = "https://kediritechnopark.com/";
|
||||
const modal = "product";
|
||||
const productId = 1;
|
||||
|
||||
const authorizedUri = "http://localhost:3000?token=";
|
||||
const unauthorizedUri = `${baseUrl}?modal=${modal}&product_id=${productId}`;
|
||||
|
||||
const url =
|
||||
`${baseUrl}?modal=${modal}&product_id=${productId}` +
|
||||
`&authorized_uri=${encodeURIComponent(authorizedUri)}` +
|
||||
`&unauthorized_uri=${encodeURIComponent(unauthorizedUri)}`;
|
||||
|
||||
window.location.href = url;
|
||||
};
|
||||
|
||||
// Handle logout
|
||||
@@ -152,7 +148,7 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
try {
|
||||
if (user.roleId < 1) {
|
||||
const newOwner = await createCafeOwner(newItem.email, newItem.username, newItem.password);
|
||||
setItems([...items, { userId: newOwner.userId, name: newOwner.username }]);
|
||||
setItems([...items, { user_id: newOwner.user_id, name: newOwner.username }]);
|
||||
} else {
|
||||
const newCafe = await createCafe(newItem.name);
|
||||
setItems([...items, { cafeId: newCafe.cafeId, name: newCafe.name }]);
|
||||
@@ -202,7 +198,7 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
];
|
||||
console.log(items)
|
||||
|
||||
const selectedItems = items?.items?.find(item => (item.userId || item.cafeId) === selectedItemId);
|
||||
const selectedItems = items?.items?.find(item => (item.user_id || item.cafeId) === selectedItemId);
|
||||
|
||||
// If the selected tenant is found, extract the cafes
|
||||
const selectedSubItems = selectedItems?.subItems || [];
|
||||
@@ -278,7 +274,7 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
gratis 3 bulan pertama
|
||||
gratis 1 bulan pertama
|
||||
</div>
|
||||
:
|
||||
<div className={styles.mainHeading}>
|
||||
@@ -290,7 +286,7 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
Gratis 3 bulan pertama
|
||||
Gratis 1 bulan pertama
|
||||
</div>
|
||||
}
|
||||
<div className={styles.subHeading}>
|
||||
@@ -299,43 +295,8 @@ const LinktreePage = ({ user, setModal }) => {
|
||||
|
||||
<div className={styles.LoginForm}>
|
||||
<div className={`${styles.FormUsername} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : ''}`}>
|
||||
<label htmlFor="username" className={styles.usernameLabel}>---- Masuk -----------------------------</label>
|
||||
<input
|
||||
id="username"
|
||||
placeholder="username"
|
||||
maxLength="30"
|
||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
<button onClick={() => { setInputtingPassword(true); setWasInputtingPassword(true) }} className={styles.claimButton}>
|
||||
<span>➜</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={`${styles.FormPassword} ${inputtingPassword ? styles.animateForm : wasInputtingPassword ? styles.reverseForm : styles.idleForm}`}>
|
||||
<span>
|
||||
<label onClick={() => setInputtingPassword(false)} htmlFor="password" className={styles.usernameLabel}> <--- <-- Kembali </label>
|
||||
<label htmlFor="password" className={styles.usernameLabel}> ----- </label>
|
||||
<label onClick={() => setModal('reset-password', { username: username })} className={styles.usernameLabel}>
|
||||
lupa password?
|
||||
</label>
|
||||
</span>
|
||||
<input
|
||||
id="password"
|
||||
placeholder="password"
|
||||
type="password"
|
||||
maxLength="30"
|
||||
className={!error ? styles.usernameInput : styles.usernameInputError}
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
<button
|
||||
onClick={handleLogin}
|
||||
className={`${styles.claimButton} ${loading ? styles.loading : ''}`}
|
||||
disabled={loading}
|
||||
>
|
||||
<span>{loading ? 'Loading...' : 'Masuk'}</span>
|
||||
<button onClick={() => handleLogin()} className={styles.claimButton}>
|
||||
<span>Masuk</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -110,7 +110,7 @@ const LinktreePage = ({ data, setModal }) => {
|
||||
</div>
|
||||
<div className={styles.linktreeForm}>
|
||||
<button onClick={()=>window.open("https://api.whatsapp.com/send?phone=6281318894994&text=Saya%20ingin%20coba%20gratis%203%20bulan")} className={styles.claimButton}>
|
||||
<span>Dapatkan voucher gratis 3 bulan</span>
|
||||
<span>Dapatkan voucher gratis 1 bulan</span>
|
||||
</button>
|
||||
</div>
|
||||
<div className={styles.footer}>
|
||||
|
||||
@@ -338,7 +338,6 @@
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.footerLinks {
|
||||
|
||||
@@ -326,7 +326,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
setSelectedCafeId(-1);
|
||||
} else if (otherCafes.length === 1) {
|
||||
updatedFullTexts = [
|
||||
[otherCafes[0].cafeIdentifyName || otherCafes[0].username, otherCafes[0].cafeId || otherCafes[0].userId],
|
||||
[otherCafes[0].cafeIdentifyName || otherCafes[0].username, otherCafes[0].cafeId || otherCafes[0].user_id],
|
||||
// Only add the "Buat Bisnis" option for user.roleId == 1
|
||||
...(user.roleId == 1 ? [["Buat Bisnis", -1]] : [])
|
||||
];
|
||||
@@ -335,7 +335,7 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
} else {
|
||||
updatedFullTexts = [
|
||||
["semua", 0], // First entry is "semua"
|
||||
...otherCafes.map(item => [item.cafeIdentifyName || item.username, item.cafeId || item.userId]), // Map over cafes to get name and cafeId pairs
|
||||
...otherCafes.map(item => [item.cafeIdentifyName || item.username, item.cafeId || item.user_id]), // Map over cafes to get name and cafeId pairs
|
||||
// Only add "Buat Bisnis +" option for user.roleId == 1
|
||||
...(user.roleId == 1 ? [["Buat Bisnis +", -1]] : [])
|
||||
];
|
||||
@@ -411,10 +411,10 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
|
||||
console.log(analytics)
|
||||
if (user && user.roleId === 0 && analytics) {
|
||||
// Filter the analytics items based on userId
|
||||
// Filter the analytics items based on user_id
|
||||
if(selectedItem[1] != 0 && selectedItem[1] != -1){
|
||||
const filteredData = analytics.items.filter(
|
||||
(data) => data.userId === nextSelectedId
|
||||
(data) => data.user_id === nextSelectedId
|
||||
);
|
||||
|
||||
// Extract coupons from the filtered data
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function Transactions({ shop, shopId, propsShopId, sendParam, dev
|
||||
console.error("Error fetching transactions:", error);
|
||||
}
|
||||
};
|
||||
|
||||
console.log(deviceType)
|
||||
fetchTransactions();
|
||||
}, [deviceType, newTransaction]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user