feat(Issuer): add admin selection page for issuer
This commit is contained in:
@@ -16,13 +16,13 @@ import {
|
|||||||
const Sidebar = ({ isOpen, onToggle }) => {
|
const Sidebar = ({ isOpen, onToggle }) => {
|
||||||
const navigation = [
|
const navigation = [
|
||||||
{ name: 'Dashboard', href: '/', icon: LayoutDashboard },
|
{ name: 'Dashboard', href: '/', icon: LayoutDashboard },
|
||||||
{ name: 'Transactions', href: '/transactions', icon: CreditCard },
|
// { name: 'Transactions', href: '/transactions', icon: CreditCard },
|
||||||
{ name: 'Roles', href: '/roles', icon: Shield },
|
{ name: 'Roles', href: '/roles', icon: Shield },
|
||||||
{ name: 'Users', href: '/users', icon: Users },
|
{ name: 'Users', href: '/users', icon: Users },
|
||||||
{ name: 'Currency', href: '/currency', icon: DollarSign },
|
{ name: 'Currency', href: '/currency', icon: DollarSign },
|
||||||
{ name: 'Location', href: '/location', icon: MapPin },
|
{ name: 'Location', href: '/location', icon: MapPin },
|
||||||
{ name: 'Issuer', href: '/issuer', icon: Building2 },
|
{ name: 'Issuer', href: '/issuer', icon: Building2 },
|
||||||
{ name: 'Settings', href: '/settings', icon: Settings },
|
// { name: 'Settings', href: '/settings', icon: Settings },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
1170
src/pages/Issuer.jsx
1170
src/pages/Issuer.jsx
File diff suppressed because it is too large
Load Diff
@@ -117,12 +117,10 @@ const Location = () => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// دریافت کشورها برای dropdown ها
|
// دریافت کشورها - لود اولیه (برای country tab و dropdown ها)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeTab === 'province' || activeTab === 'city') {
|
|
||||||
fetchCountries();
|
fetchCountries();
|
||||||
}
|
}, [fetchCountries]);
|
||||||
}, [activeTab, fetchCountries]);
|
|
||||||
|
|
||||||
// دریافت provinces برای province tab - وقتی tab تغییر میکند یا فیلتر country تغییر میکند
|
// دریافت provinces برای province tab - وقتی tab تغییر میکند یا فیلتر country تغییر میکند
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -39,5 +39,20 @@ export const generalAPI = {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// GET /api/v1/General/SearchUsersByEmail
|
||||||
|
async searchUsersByEmail(email) {
|
||||||
|
try {
|
||||||
|
const res = await api.get('/api/v1/General/SearchUsersByEmail', {
|
||||||
|
params: { email: email || '' },
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
// پاسخ به صورت { data: [...], statusCode: 200, ... } است
|
||||||
|
return res?.data?.data || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 General API - searchUsersByEmail error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -276,14 +276,15 @@ export const issuerAPI = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// GET /api/v1/Issuer/{issuerId}/AllowedCurrencies
|
// GET /api/v1/Issuer/{issuerId}/AllowedCurrencies
|
||||||
|
// Response: { data: [{ currencyCode, currencyEnglishName, allowed }, ...], statusCode, ... }
|
||||||
async getAllowedCurrencies(issuerId) {
|
async getAllowedCurrencies(issuerId) {
|
||||||
try {
|
try {
|
||||||
console.log('🔵 Getting allowed currencies for issuer:', issuerId);
|
console.log('🔵 Getting allowed currencies for issuer:', issuerId);
|
||||||
const res = await api.get(`/api/v1/Issuer/${encodeURIComponent(issuerId)}/AllowedCurrencies`, {
|
const res = await api.get(`/api/v1/Issuer/${encodeURIComponent(issuerId)}/AllowedCurrencies`, {
|
||||||
skipAuthRedirect: true
|
skipAuthRedirect: true
|
||||||
});
|
});
|
||||||
// Response is a direct array: [{code, name, nativeName, symbol, numericCode, decimalPlaces, allowed}, ...]
|
// Response structure: { data: [{ currencyCode, currencyEnglishName, allowed }, ...], statusCode, ... }
|
||||||
// Or wrapped: { data: [...] }
|
// Or direct array: [{ currencyCode, currencyEnglishName, allowed }, ...]
|
||||||
const currencies = Array.isArray(res?.data) ? res.data : (res?.data?.data || []);
|
const currencies = Array.isArray(res?.data) ? res.data : (res?.data?.data || []);
|
||||||
console.log('🟢 Allowed Currencies from API:', currencies);
|
console.log('🟢 Allowed Currencies from API:', currencies);
|
||||||
return currencies;
|
return currencies;
|
||||||
@@ -369,6 +370,213 @@ export const issuerAPI = {
|
|||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== TopUpAgentManagement API ==========
|
||||||
|
|
||||||
|
// GET /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement
|
||||||
|
async getTopUpAgentManagement(issuerId) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data?.data || { maxAgents: 0, isActive: false };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// PUT /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement
|
||||||
|
async updateTopUpAgentManagement(issuerId, maxAgents) {
|
||||||
|
try {
|
||||||
|
const payload = { maxAgents: Number(maxAgents) || 0 };
|
||||||
|
const res = await api.put(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement`, payload, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement PUT error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// GET /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency
|
||||||
|
async getTopUpAgentManagementCurrencies(issuerId) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return Array.isArray(res?.data?.data) ? res?.data?.data : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Currencies GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// GET /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}
|
||||||
|
async getTopUpAgentManagementCurrency(issuerId, currencyCode) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data?.data || null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Currency GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// POST /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}
|
||||||
|
async createTopUpAgentManagementCurrency(issuerId, currencyCode, currencyData) {
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
voucherGeneratingFee: {
|
||||||
|
percent: Number(currencyData.voucherGeneratingFee?.percent) || 0,
|
||||||
|
fixed: Number(currencyData.voucherGeneratingFee?.fixed) || 0,
|
||||||
|
minAmount: Number(currencyData.voucherGeneratingFee?.minAmount) || 0,
|
||||||
|
maxAmount: Number(currencyData.voucherGeneratingFee?.maxAmount) || 0
|
||||||
|
},
|
||||||
|
agentMarketingFee: {
|
||||||
|
percent: Number(currencyData.agentMarketingFee?.percent) || 0,
|
||||||
|
fixed: Number(currencyData.agentMarketingFee?.fixed) || 0,
|
||||||
|
minAmount: Number(currencyData.agentMarketingFee?.minAmount) || 0,
|
||||||
|
maxAmount: Number(currencyData.agentMarketingFee?.maxAmount) || 0
|
||||||
|
},
|
||||||
|
agentWalletMaxBalanceLimit: {
|
||||||
|
min: Number(currencyData.agentWalletMaxBalanceLimit?.min) || 0,
|
||||||
|
max: Number(currencyData.agentWalletMaxBalanceLimit?.max) || 0
|
||||||
|
},
|
||||||
|
agentWalletDepositMonthlyLimit: {
|
||||||
|
amount: Number(currencyData.agentWalletDepositMonthlyLimit?.amount) || 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const res = await api.post(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}`, payload, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Currency POST error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// PUT /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}
|
||||||
|
async updateTopUpAgentManagementCurrency(issuerId, currencyCode, currencyData) {
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
voucherGeneratingFee: {
|
||||||
|
percent: Number(currencyData.voucherGeneratingFee?.percent) || 0,
|
||||||
|
fixed: Number(currencyData.voucherGeneratingFee?.fixed) || 0,
|
||||||
|
minAmount: Number(currencyData.voucherGeneratingFee?.minAmount) || 0,
|
||||||
|
maxAmount: Number(currencyData.voucherGeneratingFee?.maxAmount) || 0
|
||||||
|
},
|
||||||
|
agentMarketingFee: {
|
||||||
|
percent: Number(currencyData.agentMarketingFee?.percent) || 0,
|
||||||
|
fixed: Number(currencyData.agentMarketingFee?.fixed) || 0,
|
||||||
|
minAmount: Number(currencyData.agentMarketingFee?.minAmount) || 0,
|
||||||
|
maxAmount: Number(currencyData.agentMarketingFee?.maxAmount) || 0
|
||||||
|
},
|
||||||
|
agentWalletMaxBalanceLimit: {
|
||||||
|
min: Number(currencyData.agentWalletMaxBalanceLimit?.min) || 0,
|
||||||
|
max: Number(currencyData.agentWalletMaxBalanceLimit?.max) || 0
|
||||||
|
},
|
||||||
|
agentWalletDepositMonthlyLimit: {
|
||||||
|
amount: Number(currencyData.agentWalletDepositMonthlyLimit?.amount) || 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const res = await api.put(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}`, payload, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Currency PUT error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// DELETE /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}
|
||||||
|
async deleteTopUpAgentManagementCurrency(issuerId, currencyCode) {
|
||||||
|
try {
|
||||||
|
const res = await api.delete(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Currency DELETE error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== TopUpAgentManagement Wallet API ==========
|
||||||
|
|
||||||
|
// GET /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}/Wallet/Balance
|
||||||
|
async getTopUpAgentManagementWalletBalance(issuerId, currencyCode) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}/Wallet/Balance`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data?.data || null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Wallet Balance GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// POST /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}/Wallet/Deposit
|
||||||
|
async depositTopUpAgentManagementWallet(issuerId, currencyCode, amount) {
|
||||||
|
try {
|
||||||
|
const payload = { amount: Number(amount) || 0 };
|
||||||
|
const res = await api.post(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}/Wallet/Deposit`, payload, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Wallet Deposit POST error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// GET /api/v1/issuer/{issuerId}/Capability/TopUpAgentManagement/Currency/{currencyCode}/Wallet/Transactions
|
||||||
|
async getTopUpAgentManagementWalletTransactions(issuerId, currencyCode) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/issuer/${encodeURIComponent(issuerId)}/Capability/TopUpAgentManagement/Currency/${encodeURIComponent(currencyCode)}/Wallet/Transactions`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return Array.isArray(res?.data?.data) ? res?.data?.data : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 TopUpAgentManagement Wallet Transactions GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== Issuer Admin API ==========
|
||||||
|
|
||||||
|
// GET /api/v1/Issuer/{issuerId}/Admin
|
||||||
|
async getAdmins(issuerId) {
|
||||||
|
try {
|
||||||
|
const res = await api.get(`/api/v1/Issuer/${encodeURIComponent(issuerId)}/Admin`, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
// Response structure: { data: { data: [...], filterSummary: {...} }, statusCode, ... }
|
||||||
|
return res?.data?.data?.data || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 Issuer Admin GET error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// POST /api/v1/Issuer/{issuerId}/Admin
|
||||||
|
async addAdmin(issuerId, adminData) {
|
||||||
|
try {
|
||||||
|
const res = await api.post(`/api/v1/Issuer/${encodeURIComponent(issuerId)}/Admin`, adminData, {
|
||||||
|
skipAuthRedirect: true
|
||||||
|
});
|
||||||
|
return res?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('🔴 Issuer Admin POST error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user