Merge branch 'window-build' of http://git.hicglobalsolutions.in/BhawanSingh/va-tracker - 05-Dec | 5-50
This commit is contained in:
commit
312007655f
|
|
@ -407,7 +407,7 @@ ipcMain.handle("get-payslips", async (event, vaId: string) => {
|
|||
console.log("get-payslips", vaId)
|
||||
try {
|
||||
const response = await api.get(`/paySlip/${vaId}`);
|
||||
console.log(response.data , "Line 409")
|
||||
console.log(response.data, "Line 409")
|
||||
return {
|
||||
success: true,
|
||||
data: response.data || [],
|
||||
|
|
@ -493,6 +493,47 @@ ipcMain.handle("get-adjustments-list", async (event, vaId: string) => {
|
|||
});
|
||||
|
||||
|
||||
ipcMain.handle("update-payment", async (event, data: Record<string, any>) => {
|
||||
console.log("data-update-payment", data);
|
||||
|
||||
// Build userDetails object
|
||||
const userDetails: Record<string, any> = {
|
||||
paymentMethod: data.paymentMethod,
|
||||
};
|
||||
|
||||
// Add payment-specific fields
|
||||
if (data.paymentMethod === "wise" && data.wiseEmail) {
|
||||
userDetails.wiseEmail = data.wiseEmail;
|
||||
// Clear veemAccount when switching to wise
|
||||
userDetails.veemAccount = "";
|
||||
} else if (data.paymentMethod === "veem" && data.veemAccount) {
|
||||
userDetails.veemAccount = data.veemAccount;
|
||||
// Clear wiseEmail when switching to veem
|
||||
userDetails.wiseEmail = "";
|
||||
}
|
||||
|
||||
// Build final payload
|
||||
const payload = {
|
||||
userDetails: userDetails,
|
||||
};
|
||||
|
||||
console.log("Update Payment payload", payload);
|
||||
|
||||
try {
|
||||
const response = await api.patch("/profile", payload);
|
||||
console.log("Update-payment-response", response);
|
||||
return { success: true, data: response?.data?.userDetails };
|
||||
} catch (error: any) {
|
||||
console.error("❌ Update payment error:", error.message);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || "Payment update failed",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
export const sendTokenExpired = () => {
|
||||
console.log("⚠️ Sending token-expired event to renderer");
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
changePassword: (data: { oldPassword: string; password: string; cPassword: string }) =>
|
||||
ipcRenderer.invoke("change-password", data),
|
||||
|
||||
updatePayment: (data: {
|
||||
paymentMethod: string;
|
||||
wiseEmail?: string;
|
||||
veemAccount?: string;
|
||||
}) => ipcRenderer.invoke('update-payment', data),
|
||||
|
||||
onTokenExpired: (callback) => {
|
||||
// Remove old listeners
|
||||
ipcRenderer.removeAllListeners("token-expired");
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export const handleLogin = async (credentials: { email: string, password: string
|
|||
try {
|
||||
console.log("➡️ Calling API...");
|
||||
const response = await axios.post(
|
||||
'https://quality-friendly-goldfish.ngrok-free.app/api/v1/va/login',
|
||||
'https://daniela-nonprofessed-boastfully.ngrok-free.app/api/v1/va/login',
|
||||
{ userDetails: { ...credentials } },
|
||||
{ headers: { "ngrok-skip-browser-warning": 69420 }, httpsAgent }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
// contexts/ToastContext.tsx
|
||||
import React, { createContext, useContext, useState, ReactNode } from 'react';
|
||||
|
||||
interface Toast {
|
||||
id: number;
|
||||
message: string;
|
||||
type: 'success' | 'error' | 'info' | 'warning';
|
||||
}
|
||||
|
||||
interface ToastContextType {
|
||||
showToast: (message: string, type?: Toast['type']) => void;
|
||||
hideToast: (id: number) => void;
|
||||
}
|
||||
|
||||
const ToastContext = createContext<ToastContextType | undefined>(undefined);
|
||||
|
||||
export const ToastProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
|
||||
const [toasts, setToasts] = useState<Toast[]>([]);
|
||||
|
||||
const showToast = (message: string, type: Toast['type'] = 'success') => {
|
||||
const id = Date.now();
|
||||
setToasts(prev => [...prev, { id, message, type }]);
|
||||
|
||||
// Auto remove after 5 seconds
|
||||
setTimeout(() => {
|
||||
hideToast(id);
|
||||
}, 3000);
|
||||
};
|
||||
|
||||
const hideToast = (id: number) => {
|
||||
setToasts(prev => prev.filter(toast => toast.id !== id));
|
||||
};
|
||||
|
||||
return (
|
||||
<ToastContext.Provider value={{ showToast, hideToast }}>
|
||||
{children}
|
||||
<ToastContainer toasts={toasts} hideToast={hideToast} />
|
||||
</ToastContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useToast = () => {
|
||||
const context = useContext(ToastContext);
|
||||
if (!context) {
|
||||
throw new Error('useToast must be used within a ToastProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
const ToastContainer: React.FC<{
|
||||
toasts: Toast[];
|
||||
hideToast: (id: number) => void;
|
||||
}> = ({ toasts, hideToast }) => {
|
||||
const getTypeStyles = (type: Toast['type']) => {
|
||||
switch (type) {
|
||||
case 'success':
|
||||
return 'bg-success text-success-content';
|
||||
case 'error':
|
||||
return 'bg-error text-error-content';
|
||||
case 'warning':
|
||||
return 'bg-warning text-warning-content';
|
||||
case 'info':
|
||||
return 'bg-info text-info-content';
|
||||
default:
|
||||
return 'bg-neutral text-neutral-content';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="toast toast-center toast-top z-2000">
|
||||
{toasts.map((toast) => (
|
||||
<div
|
||||
key={toast.id}
|
||||
className="w-full max-w-md px-2 mb-2"
|
||||
>
|
||||
<div
|
||||
className={`alert ${getTypeStyles(toast.type)} shadow-lg flex items-start`}
|
||||
onClick={() => hideToast(toast.id)}
|
||||
>
|
||||
<div className="flex-grow min-w-0">
|
||||
<p className="text-sm break-words whitespace-pre-wrap">
|
||||
{toast.message}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
className="btn btn-ghost btn-xs flex-shrink-0 ml-2"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
hideToast(toast.id);
|
||||
}}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -588,7 +588,7 @@ const DashboardLayout = () => {
|
|||
if (!selectedProject?.projectId) return
|
||||
|
||||
console.log(selectedProject?.projectId, "SelectedProject ID")
|
||||
socketRef.current = io("https://quality-friendly-goldfish.ngrok-free.app", {
|
||||
socketRef.current = io("https://daniela-nonprofessed-boastfully.ngrok-free.app", {
|
||||
transports: ["websocket"],
|
||||
secure: true,
|
||||
rejectUnauthorized: false,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ import App from './App'
|
|||
import './index.css'
|
||||
import { Provider } from "react-redux";
|
||||
import { store } from "./store";
|
||||
import { ToastProvider } from './helper/ToastContext';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
<ToastProvider>
|
||||
<App />
|
||||
</ToastProvider>
|
||||
</Provider>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ const Dashboard: React.FC = () => {
|
|||
try {
|
||||
console.log("📡 Fetching projects...Dashboard");
|
||||
const res = await window.electron.getProjectList();
|
||||
console.log(" Project list response in dashboard:", res);
|
||||
console.log(" Project list response in dashboard: ", res.data?.[0]);
|
||||
|
||||
if (res?.success && Array.isArray(res.data)) {
|
||||
// Store data redux store
|
||||
|
|
@ -152,9 +152,11 @@ const Dashboard: React.FC = () => {
|
|||
);
|
||||
|
||||
// Auto-select first project
|
||||
if (res.data.length > 0 && !selectedProject) {
|
||||
if (res.data.length > 0) {
|
||||
const firstProject = res.data[0];
|
||||
|
||||
|
||||
console.log("Line 158" , firstProject)
|
||||
// Select the project
|
||||
dispatch(setSelectedProjectSlice(firstProject));
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { quillModules } from '../../../utils/quillConfig';
|
|||
import Quill from 'quill';
|
||||
import 'quill/dist/quill.snow.css';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useToast } from '../../../helper/ToastContext';
|
||||
|
||||
interface Project {
|
||||
projectId: string;
|
||||
|
|
@ -50,6 +51,7 @@ const AdjustmentTab: React.FC<AdjustmentTabProps> = ({ projects }) => {
|
|||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const quillRef = useRef<any>(null);
|
||||
const navigate = useNavigate()
|
||||
const { showToast } = useToast();
|
||||
|
||||
// Field validation functions
|
||||
const validateProjectId = (projectId: string): string | undefined => {
|
||||
|
|
@ -460,9 +462,14 @@ const AdjustmentTab: React.FC<AdjustmentTabProps> = ({ projects }) => {
|
|||
|
||||
if (res?.success) {
|
||||
console.log("Timesheet Created Successfully");
|
||||
alert(res.message);
|
||||
resetForm();
|
||||
navigate('/dashboard/leave-adjustments')
|
||||
// Show success toast instead of alert
|
||||
showToast("PTO Request submitted successfully!", "success");
|
||||
|
||||
// Navigate after a small delay
|
||||
setTimeout(() => {
|
||||
navigate('/dashboard/leave-adjustments');
|
||||
}, 300);
|
||||
} else {
|
||||
setFormErrors(prev => ({
|
||||
...prev,
|
||||
|
|
@ -475,6 +482,7 @@ const AdjustmentTab: React.FC<AdjustmentTabProps> = ({ projects }) => {
|
|||
...prev,
|
||||
general: err.message || "Something went wrong while saving timesheet"
|
||||
}));
|
||||
showToast(err.message || "Something went wrong while saving timesheet", "error");
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import ReactQuill from "react-quill-new";
|
|||
import Quill from "quill";
|
||||
import "quill/dist/quill.snow.css";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useToast } from "../../../helper/ToastContext";
|
||||
|
||||
interface LeaveFormData {
|
||||
fromDate: string;
|
||||
|
|
@ -26,6 +27,9 @@ const PtoLeaveTab: React.FC<{
|
|||
const quillRef = useRef<any>(null);
|
||||
const navigate = useNavigate()
|
||||
|
||||
const { showToast } = useToast();
|
||||
|
||||
console.log("ptoLeave", ptoLeave)
|
||||
const [errors, setErrors] = useState<Partial<LeaveFormData>>({});
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -200,11 +204,18 @@ const PtoLeaveTab: React.FC<{
|
|||
|
||||
if (result.success) {
|
||||
resetForm();
|
||||
alert("PTO Request submitted!");
|
||||
navigate('/dashboard/leave-adjustments')
|
||||
// Show success toast instead of alert
|
||||
showToast("PTO Request submitted successfully!", "success");
|
||||
|
||||
// Navigate after a small delay
|
||||
setTimeout(() => {
|
||||
navigate('/dashboard/leave-adjustments');
|
||||
}, 300);
|
||||
} else {
|
||||
setServerError(result.message || "Something went wrong");
|
||||
showToast(result.message || "Failed to submit PTO request", "error");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -213,7 +224,6 @@ const PtoLeaveTab: React.FC<{
|
|||
<div className="max-w-4xl space-y-3 ">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
|
||||
|
||||
{/* From Date */}
|
||||
<div className="form-control">
|
||||
<label className="label">
|
||||
|
|
@ -262,12 +272,12 @@ const PtoLeaveTab: React.FC<{
|
|||
className="h-60"
|
||||
/>
|
||||
</div>
|
||||
{errors.comment && <p className="text-error text-xs">{errors.comment}</p>}
|
||||
{errors.comment && <p className="text-error text-xs">{errors.comment}</p>}
|
||||
</div>
|
||||
|
||||
{serverError && (
|
||||
<p className="text-red-500 font-medium text-center text-xs">{serverError}</p>
|
||||
)}
|
||||
<p className="text-red-500 font-medium text-center text-xs">{serverError}</p>
|
||||
)}
|
||||
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import ReactQuill from "react-quill-new";
|
|||
import Quill from "quill";
|
||||
import "quill/dist/quill.snow.css"; // correct CSS
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useToast } from '../../../helper/ToastContext';
|
||||
|
||||
interface LeaveFormData {
|
||||
fromDate: string;
|
||||
|
|
@ -24,6 +25,7 @@ const SickLeaveTab: React.FC<{
|
|||
const quillRef = useRef<any>(null);
|
||||
const [sickErrors, setSickErrors] = useState<Partial<LeaveFormData>>({});
|
||||
const navigate = useNavigate()
|
||||
const { showToast } = useToast();
|
||||
|
||||
useEffect(() => {
|
||||
const editor = quillRef.current?.getEditor();
|
||||
|
|
@ -216,10 +218,16 @@ const SickLeaveTab: React.FC<{
|
|||
|
||||
if (result.success) {
|
||||
resetForm();
|
||||
alert("SICK leave applied!");
|
||||
navigate('/dashboard/leave-adjustments')
|
||||
// Show success toast instead of alert
|
||||
showToast("SICK Request submitted successfully!", "success");
|
||||
|
||||
// Navigate after a small delay
|
||||
setTimeout(() => {
|
||||
navigate('/dashboard/leave-adjustments');
|
||||
}, 300);
|
||||
} else {
|
||||
setServerError(result.message || "Something went wrong");
|
||||
showToast(result.message || "Failed to submit SICK request", "error");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,156 +2,189 @@ import React, { useState, useEffect } from "react";
|
|||
import { CreditCard } from "lucide-react";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { RootState } from "../../../store";
|
||||
import { setProfile } from "../../../store/profileSlice";
|
||||
|
||||
interface ChangePaymentModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const ChangePaymentModal: React.FC<ChangePaymentModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
isOpen,
|
||||
onClose,
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
const { profile } = useSelector((state: RootState) => state.profile);
|
||||
const dispatch = useDispatch();
|
||||
const { profile } = useSelector((state: RootState) => state.profile);
|
||||
|
||||
const [method, setMethod] = useState(profile?.paymentMethod || "");
|
||||
const [wiseEmail, setWiseEmail] = useState(profile?.wiseEmail || "");
|
||||
const [veemAccount, setVeemAccount] = useState(profile?.veemAccount || "");
|
||||
const [method, setMethod] = useState(profile?.paymentMethod || "");
|
||||
const [wiseEmail, setWiseEmail] = useState(profile?.wiseEmail || "");
|
||||
const [veemAccount, setVeemAccount] = useState(profile?.veemAccount || "");
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setMethod(profile?.paymentMethod || "");
|
||||
setWiseEmail(profile?.wiseEmail || "");
|
||||
setVeemAccount(profile?.veemAccount || "");
|
||||
setError("");
|
||||
}
|
||||
}, [isOpen]);
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setMethod(profile?.paymentMethod || "");
|
||||
setWiseEmail(profile?.wiseEmail || "");
|
||||
setVeemAccount(profile?.veemAccount || "");
|
||||
setError("");
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setError("");
|
||||
const handleSubmit = async () => {
|
||||
setError("");
|
||||
|
||||
// Validation
|
||||
if (!method) {
|
||||
return setError("Please select a payment method.");
|
||||
}
|
||||
// Validation
|
||||
if (!method) {
|
||||
return setError("Please select a payment method.");
|
||||
}
|
||||
|
||||
if (method === "wise" && !wiseEmail.trim()) {
|
||||
return setError("Wise email is required.");
|
||||
}
|
||||
if (method === "wise" && !wiseEmail.trim()) {
|
||||
return setError("Wise email is required.");
|
||||
}
|
||||
|
||||
if (method === "wise" && !/^\S+@\S+\.\S+$/.test(wiseEmail)) {
|
||||
return setError("Enter a valid Wise email.");
|
||||
}
|
||||
if (method === "wise" && !/^\S+@\S+\.\S+$/.test(wiseEmail)) {
|
||||
return setError("Enter a valid Wise email.");
|
||||
}
|
||||
|
||||
if (method === "veem" && !veemAccount.trim()) {
|
||||
return setError("Veem account number is required.");
|
||||
}
|
||||
if (method === "veem" && !veemAccount.trim()) {
|
||||
return setError("Veem account number is required.");
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setLoading(true);
|
||||
|
||||
// try {
|
||||
// // Replace with your electron API
|
||||
// await window.electron.updatePayment({
|
||||
// method,
|
||||
// wiseEmail: method === "wise" ? wiseEmail.trim() : "",
|
||||
// veemAccount: method === "veem" ? veemAccount.trim() : "",
|
||||
// });
|
||||
try {
|
||||
// Prepare data for API
|
||||
const updateData: any = {
|
||||
paymentMethod: method
|
||||
};
|
||||
|
||||
// // Refresh or update Redux
|
||||
// // dispatch(updateProfile({...}));
|
||||
// Add appropriate field based on selection
|
||||
if (method === "wise") {
|
||||
updateData.wiseEmail = wiseEmail.trim();
|
||||
} else if (method === "veem") {
|
||||
updateData.veemAccount = veemAccount.trim();
|
||||
}
|
||||
|
||||
// onClose();
|
||||
// } catch (err) {
|
||||
// setError("Failed to update payment info. Try again.");
|
||||
// }
|
||||
console.log("Sending to electron:", updateData);
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
// Call Electron API
|
||||
const result = await window.electron.updatePayment(updateData);
|
||||
|
||||
return (
|
||||
<dialog open className="modal modal-open">
|
||||
<div className="modal-box w-96">
|
||||
console.log(result)
|
||||
|
||||
<h3 className="font-bold text-lg mb-4 flex items-center gap-2">
|
||||
<CreditCard size={18} /> Change Payment Method
|
||||
</h3>
|
||||
if (result.success) {
|
||||
// Prepare data for Redux update (clear unused field)
|
||||
const reduxUpdateData: any = {
|
||||
paymentMethod: method
|
||||
};
|
||||
|
||||
{/* Error */}
|
||||
{error && (
|
||||
<div className="alert alert-error py-2 text-xs mb-3">{error}</div>
|
||||
)}
|
||||
if (method === "wise") {
|
||||
reduxUpdateData.wiseEmail = wiseEmail.trim();
|
||||
reduxUpdateData.veemAccount = ""; // Clear veem
|
||||
} else if (method === "veem") {
|
||||
reduxUpdateData.veemAccount = veemAccount.trim();
|
||||
reduxUpdateData.wiseEmail = ""; // Clear wise
|
||||
}
|
||||
|
||||
{/* Dropdown */}
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Payment Method</span>
|
||||
</label>
|
||||
// Update Redux store
|
||||
dispatch(setProfile(result.data));
|
||||
|
||||
<select
|
||||
className="select select-bordered select-sm"
|
||||
value={method}
|
||||
onChange={(e) => setMethod(e.target.value)}
|
||||
>
|
||||
<option value="">Select method</option>
|
||||
<option value="wise">Wise</option>
|
||||
<option value="veem">Veem</option>
|
||||
</select>
|
||||
</div>
|
||||
// Show success message if needed
|
||||
// toast.success("Payment method updated successfully");
|
||||
|
||||
{/* Wise Email */}
|
||||
{method === "wise" && (
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Wise Email</span>
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
className="input input-bordered input-sm"
|
||||
placeholder="Enter Wise email"
|
||||
value={wiseEmail}
|
||||
onChange={(e) => setWiseEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
onClose();
|
||||
} else {
|
||||
setError(result.message || "Failed to update payment info.");
|
||||
}
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Failed to update payment info. Try again.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
{/* Veem Account */}
|
||||
{method === "veem" && (
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Veem Account Number</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input input-bordered input-sm"
|
||||
placeholder="Enter Veem account"
|
||||
value={veemAccount}
|
||||
onChange={(e) => setVeemAccount(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
return (
|
||||
<dialog open className="modal modal-open">
|
||||
<div className="modal-box w-96">
|
||||
|
||||
<div className="modal-action">
|
||||
<button className="btn btn-sm btn-ghost" onClick={onClose}>
|
||||
Cancel
|
||||
</button>
|
||||
<h3 className="font-bold text-lg mb-4 flex items-center gap-2">
|
||||
<CreditCard size={18} /> Change Payment Method
|
||||
</h3>
|
||||
|
||||
<button
|
||||
className={`btn btn-sm btn-primary ${loading ? "loading" : ""}`}
|
||||
onClick={handleSubmit}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "Updating..." : "Update"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
);
|
||||
{/* Error */}
|
||||
{error && (
|
||||
<div className="alert alert-error py-2 text-xs mb-3">{error}</div>
|
||||
)}
|
||||
|
||||
{/* Dropdown */}
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Payment Method</span>
|
||||
</label>
|
||||
|
||||
<select
|
||||
className="select select-bordered select-sm"
|
||||
value={method}
|
||||
onChange={(e) => setMethod(e.target.value)}
|
||||
>
|
||||
<option value="">Select method</option>
|
||||
<option value="wise">Wise</option>
|
||||
<option value="veem">Veem</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Wise Email */}
|
||||
{method === "wise" && (
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Wise Email</span>
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
className="input input-bordered input-sm"
|
||||
placeholder="Enter Wise email"
|
||||
value={wiseEmail}
|
||||
onChange={(e) => setWiseEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Veem Account */}
|
||||
{method === "veem" && (
|
||||
<div className="form-control mb-4">
|
||||
<label className="label">
|
||||
<span className="text-sm font-medium">Veem Account Number</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input input-bordered input-sm"
|
||||
placeholder="Enter Veem account"
|
||||
value={veemAccount}
|
||||
onChange={(e) => setVeemAccount(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="modal-action">
|
||||
<button className="btn btn-sm btn-ghost" onClick={onClose}>
|
||||
Cancel
|
||||
</button>
|
||||
|
||||
<button
|
||||
className={`btn btn-sm btn-primary ${loading ? "loading" : ""}`}
|
||||
onClick={handleSubmit}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? "Updating..." : "Update"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default ChangePaymentModal;
|
||||
|
|
|
|||
|
|
@ -104,24 +104,24 @@ const Settings: React.FC = () => {
|
|||
</div>
|
||||
|
||||
|
||||
{profile?.paymentMethod === "wise" && (
|
||||
{profile?.veemAccount && (
|
||||
<div className="p-2 rounded bg-base-200/40">
|
||||
<p className="text-xs text-base-content/60 flex items-center gap-1 mb-0.5">
|
||||
💳 Wise
|
||||
🏦 Veem Account
|
||||
</p>
|
||||
<p className="text-xs font-medium truncate" title={profile?.payoneerAccount || "N/A"}>
|
||||
{maskLast5(profile?.wiseEmail)}
|
||||
<p className="text-xs font-medium truncate" title={profile?.veemAccount || "N/A"}>
|
||||
{profile?.veemAccount || "N/A"}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{profile?.paymentMethod === "veem" && (
|
||||
{profile?.wiseEmail&& (
|
||||
<div className="p-2 rounded bg-base-200/40">
|
||||
<p className="text-xs text-base-content/60 flex items-center gap-1 mb-0.5">
|
||||
🏦 Veem
|
||||
<p className="text-xs text-base-content/60 flex items-center gap-1 mb-0.5 ">
|
||||
🏦 Wise Email
|
||||
</p>
|
||||
<p className="text-xs font-medium truncate" title={profile?.veemAccount || "N/A"}>
|
||||
{profile?.veemAccount || "N/A"}
|
||||
<p className="text-xs font-medium overflow-auto no-scrollbar" title={profile?.wiseEmail || "N/A"}>
|
||||
{profile?.wiseEmail || "N/A"}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -154,13 +154,13 @@ interface Window {
|
|||
vaId: string;
|
||||
projectId: string;
|
||||
type: string;
|
||||
time:string
|
||||
time: string
|
||||
}) => Promise<any>;
|
||||
stopProjectTracking: (data: {
|
||||
vaId: string;
|
||||
projectId: string;
|
||||
type: string;
|
||||
time:string
|
||||
time: string
|
||||
}) => Promise<any>;
|
||||
trackingTabsOpeningClosing: (data: {
|
||||
id?: string;
|
||||
|
|
@ -193,6 +193,13 @@ interface Window {
|
|||
cPassword: string;
|
||||
}) => Promise<{ success: boolean; message?: string; data?: any }>;
|
||||
|
||||
// In your electron API handler
|
||||
updatePayment: (data: {
|
||||
paymentMethod: string;
|
||||
wiseEmail?: string;
|
||||
veemAccount?: string;
|
||||
}) => Promise<{ success: boolean; message?: string; data?: any }>;
|
||||
|
||||
|
||||
onTokenExpired: (callback: () => void) => void;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue