Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_MUNICIPALITY=Tabuk
VITE_IS_ONLINE=false
10 changes: 3 additions & 7 deletions client/src/components/TransactionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { checkDispensingEligibility, type LocalSettings, type GuardResult } from '../utils/dispensingGuard';
import { checkDispensingEligibility, type GuardResult } from '../utils/dispensingGuard';
import { type PatientDocType } from '../db/schema';
import { LOCAL_SETTINGS } from '../config';

// Mock Patient Data (Since we don't have a patient picker UI yet)
const MOCK_PATIENTS: (PatientDocType & { last_sync_date: string })[] = [
Expand All @@ -9,11 +10,6 @@ const MOCK_PATIENTS: (PatientDocType & { last_sync_date: string })[] = [
{ id: 'P3', name: 'Jose Rizal', municipality: 'Tabuk', last_sync_date: '2023-01-01T00:00:00Z' } // Stale
];

const LOCAL_SETTINGS: LocalSettings = {
municipality: 'Tabuk',
isOnline: false // Simulating Offline Mode
};

interface TransactionFormProps {
onAdd: (type: 'DISPENSE' | 'RECEIVE' | 'ADJUST', qty: number, batchId: string) => void;
sku: string;
Expand Down Expand Up @@ -57,7 +53,7 @@ export const TransactionForm: React.FC<TransactionFormProps> = ({ onAdd, sku })
))}
</select>
<div style={{ fontSize: '0.8rem', color: '#666', marginTop: '5px' }}>
Context: Offline Mode. Home: Tabuk.
Context: {LOCAL_SETTINGS.isOnline ? 'Online' : 'Offline Mode'}. Home: {LOCAL_SETTINGS.municipality}.
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions client/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type LocalSettings } from './utils/dispensingGuard';

export const LOCAL_SETTINGS: LocalSettings = {
municipality: import.meta.env.VITE_MUNICIPALITY || 'Tabuk',
isOnline: import.meta.env.VITE_IS_ONLINE === 'true' // Default to false if not set
};
6 changes: 3 additions & 3 deletions client/src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const TRANSACTION_SCHEMA_LITERAL = {
required: ['id', 'type', 'sku', 'qty', 'timestamp', 'sync_status']
} as const;

const schemaTypedTransaction = toTypedRxJsonSchema(TRANSACTION_SCHEMA_LITERAL);
export const schemaTypedTransaction = toTypedRxJsonSchema(TRANSACTION_SCHEMA_LITERAL);
export type TransactionDocType = ExtractDocumentTypeFromTypedRxJsonSchema<typeof schemaTypedTransaction>;

export const TransactionSchema: RxJsonSchema<TransactionDocType> = TRANSACTION_SCHEMA_LITERAL;
Expand Down Expand Up @@ -79,7 +79,7 @@ export const INVENTORY_SCHEMA_LITERAL = {
required: ['sku', 'batch_id', 'current_stock']
} as const;

const schemaTypedInventory = toTypedRxJsonSchema(INVENTORY_SCHEMA_LITERAL);
export const schemaTypedInventory = toTypedRxJsonSchema(INVENTORY_SCHEMA_LITERAL);
export type InventoryDocType = ExtractDocumentTypeFromTypedRxJsonSchema<typeof schemaTypedInventory>;

export const InventorySchema: RxJsonSchema<InventoryDocType> = INVENTORY_SCHEMA_LITERAL;
Expand Down Expand Up @@ -110,7 +110,7 @@ export const PATIENT_SCHEMA_LITERAL = {
required: ['id', 'name', 'municipality']
} as const;

const schemaTypedPatient = toTypedRxJsonSchema(PATIENT_SCHEMA_LITERAL);
export const schemaTypedPatient = toTypedRxJsonSchema(PATIENT_SCHEMA_LITERAL);
export type PatientDocType = ExtractDocumentTypeFromTypedRxJsonSchema<typeof schemaTypedPatient>;

export const PatientSchema: RxJsonSchema<PatientDocType> = PATIENT_SCHEMA_LITERAL;