Package passenger numbers and pricing updates

This commit is contained in:
Stephanos A
2026-07-05 18:14:42 +03:00
parent 9e77ca7865
commit afd30c36a0
20 changed files with 537 additions and 105 deletions

View File

@@ -289,7 +289,7 @@ export default function ClassesPage() {
<h3 className="font-semibold text-foreground mb-4">Pricing Configuration</h3>
<div>
<label className="label">Base Fare (ETB) *</label>
<label className="label">Base Fare *</label>
<input
type="number"
name="baseFareMinor"

View File

@@ -107,7 +107,7 @@ export default function FareManagementPage() {
render: (r: any) => <span className="text-sm">{r.nationality || 'All'}</span>,
},
{
key: 'baseFareMinor', label: 'Base Fare (ETB)',
key: 'baseFareMinor', label: 'Base Fare',
render: (r: any) => <span className="font-mono">{(r.baseFareMinor / 100).toFixed(2)}</span>,
},
{
@@ -214,7 +214,7 @@ export default function FareManagementPage() {
</select>
</div>
<div>
<label className="label">Base Fare (ETB) *</label>
<label className="label">Base Fare *</label>
<input type="number" name="baseFareMinor" className="input" min="0" step="0.01"
defaultValue={editingRule ? (editingRule.baseFareMinor / 100).toFixed(2) : ''} required
placeholder="e.g. 350.00" />

View File

@@ -116,7 +116,7 @@ export default function PricingPage() {
const { data: segmentFares = [], isLoading: segmentFaresLoading, refetch: refetchSegmentFares } = useQuery({
queryKey: ['segment-fares', selectedRoute],
queryFn: () => (selectedRoute ? apiClient.get(`/schedules/routes/${selectedRoute}/segment-fares`) : Promise.resolve([])),
queryFn: () => (selectedRoute ? apiClient.get(`/admin/segment-fares?routeId=${selectedRoute}`) : Promise.resolve([])),
enabled: !!selectedRoute && tab === 'segment',
});
@@ -199,7 +199,7 @@ export default function PricingPage() {
});
const createSegmentFareMutation = useMutation({
mutationFn: (data: any) => apiClient.post(`/schedules/segment-fares`, data),
mutationFn: (data: any) => apiClient.post(`/admin/segment-fares`, data),
onSuccess: () => {
refetchSegmentFares();
resetSegmentForm();
@@ -211,7 +211,7 @@ export default function PricingPage() {
});
const updateSegmentFareMutation = useMutation({
mutationFn: (data: any) => apiClient.patch(`/schedules/segment-fares/${data.id}`, data),
mutationFn: ({ id, ...data }: any) => apiClient.put(`/admin/segment-fares/${id}`, data),
onSuccess: () => {
refetchSegmentFares();
setEditingFare(null);
@@ -224,7 +224,7 @@ export default function PricingPage() {
});
const deleteSegmentFareMutation = useMutation({
mutationFn: (id: string) => apiClient.delete(`/schedules/segment-fares/${id}`),
mutationFn: (id: string) => apiClient.delete(`/admin/segment-fares/${id}`),
onSuccess: () => {
refetchSegmentFares();
setDeleteConfirm({ isOpen: false, id: null });
@@ -422,7 +422,7 @@ export default function PricingPage() {
},
{
key: 'baseFare',
label: 'Fare (ETB)',
label: 'Fare',
render: (fare: any) => {
const minor = fare.baseFareMinor ?? fare.baseFare;
if (minor == null) return <span className="text-muted-foreground"></span>;
@@ -495,7 +495,7 @@ export default function PricingPage() {
},
{
key: 'baseFare',
label: 'Fare (ETB)',
label: 'Fare',
render: (fare: any) => {
const fareValue = fare.baseFare ?? fare.baseFareMinor;
if (fareValue == null) return <span className="text-muted-foreground"></span>;
@@ -870,7 +870,7 @@ export default function PricingPage() {
</div>
<div>
<label className="label">Fare (ETB) *</label>
<label className="label">Fare *</label>
<input
type="number"
min="0"
@@ -1000,7 +1000,7 @@ export default function PricingPage() {
</div>
<div>
<label className="label">Fare (ETB) *</label>
<label className="label">Fare *</label>
<input
type="number"
min="0"

View File

@@ -458,6 +458,14 @@ export const excessBaggageApi = {
delete: (id: string) => apiClient.delete(`/agents/excess-baggage/${id}`),
};
// Segment Fares API
export const segmentFaresApi = {
getAll: (routeId?: string) => apiClient.get<any>(`/admin/segment-fares${routeId ? `?routeId=${routeId}` : ''}`),
create: (data: any) => apiClient.post<any>('/admin/segment-fares', data),
update: (id: string, data: any) => apiClient.put<any>(`/admin/segment-fares/${id}`, data),
remove: (id: string) => apiClient.delete(`/admin/segment-fares/${id}`),
};
// Route Coach Templates API
export const routeCoachTemplatesApi = {
get: (routeId: string) => apiClient.get<any>(`/routes/${routeId}/coaches`),