Skip to content
Merged
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
59 changes: 59 additions & 0 deletions src/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as React from "react"
import { Accordion as AccordionPrimitive } from "radix-ui"
import { ChevronDown } from "lucide-react"
import { cn } from "@/lib/utils"

const Accordion = AccordionPrimitive.Root

function AccordionItem({
className,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
return (
<AccordionPrimitive.Item
data-slot="accordion-item"
className={cn("border-b last:border-b-0", className)}
{...props}
/>
)
}

function AccordionTrigger({
className,
children,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
return (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
data-slot="accordion-trigger"
className={cn(
"flex flex-1 items-center justify-between py-4 text-sm font-medium text-foreground transition-all hover:underline outline-none [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{children}
<ChevronDown className="size-4 shrink-0 text-muted-foreground transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
)
}

function AccordionContent({
className,
children,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
return (
<AccordionPrimitive.Content
data-slot="accordion-content"
className="overflow-hidden text-sm data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
{...props}
>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
</AccordionPrimitive.Content>
)
}

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
26 changes: 26 additions & 0 deletions src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react"
import { Checkbox as CheckboxPrimitive } from "radix-ui"
import { CheckIcon } from "lucide-react"
import { cn } from "@/lib/utils"

function Checkbox({
className,
...props
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
return (
<CheckboxPrimitive.Root
data-slot="checkbox"
className={cn(
"peer size-4 shrink-0 rounded border border-input bg-transparent transition-colors outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[#1565C0] data-[state=checked]:border-[#1565C0] data-[state=checked]:text-white",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator className="flex items-center justify-center">
<CheckIcon className="size-3" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
)
}

export { Checkbox }
25 changes: 25 additions & 0 deletions src/components/ui/switch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from "react"
import { Switch as SwitchPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"

function Switch({
className,
...props
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
return (
<SwitchPrimitive.Root
data-slot="switch"
className={cn(
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[#1565C0] data-[state=unchecked]:bg-gray-200",
className
)}
{...props}
>
<SwitchPrimitive.Thumb
className="pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
/>
</SwitchPrimitive.Root>
)
}

export { Switch }
142 changes: 142 additions & 0 deletions src/modules/auth/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import React, { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { User, Lock, Eye, EyeOff } from 'lucide-react'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/ui/button'
import { Label } from '@/components/ui/label'
import { Checkbox } from '@/components/ui/checkbox'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'

const TENANTS = ['greenbank', 'bluebank', 'redbank']

export default function Login() {
const navigate = useNavigate()
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const [tenant, setTenant] = useState('')
const [rememberMe, setRememberMe] = useState(false)
const [showPassword, setShowPassword] = useState(false)

function handleSubmit(e: React.FormEvent) {
e.preventDefault()
if (username === 'mifos' && password === 'password') {
navigate('/')
} else {
alert('Invalid credentials. Use mifos / password.')
}
}

return (
<div className="min-h-screen bg-[#1565C0] flex items-center justify-center p-4">
<div className="w-full max-w-md bg-white rounded-2xl shadow-xl p-8 space-y-6">
{/* Logo + title */}
<div className="flex flex-col items-center gap-2">
<img
src="/payment-hub-ee.png"
alt="Payment Hub EE"
className="h-12 object-contain"
onError={(e) => {
e.currentTarget.style.display = 'none'
}}
/>
<div className="text-center">
<p className="text-xl font-bold text-gray-900">Payment Hub EE</p>
<p className="text-sm text-muted-foreground">Operations</p>
</div>
</div>

{/* Form */}
<form onSubmit={handleSubmit} className="space-y-4">
{/* Username */}
<div className="space-y-1.5">
<Label htmlFor="username">Username</Label>
<div className="relative">
<User className="absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
<Input
id="username"
placeholder="Enter username"
value={username}
onChange={(e) => setUsername(e.target.value)}
className="pl-8"
required
/>
</div>
</div>

{/* Password */}
<div className="space-y-1.5">
<Label htmlFor="password">Password</Label>
<div className="relative">
<Lock className="absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
<Input
id="password"
type={showPassword ? 'text' : 'password'}
placeholder="Enter password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="pl-8 pr-9"
required
/>
<button
type="button"
aria-label={showPassword ? 'Hide password' : 'Show password'}
onClick={() => setShowPassword((v) => !v)}
className="absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
>
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
</div>
</div>

{/* Tenant */}
<div className="space-y-1.5">
<Label htmlFor="tenant">Tenant</Label>
<Select value={tenant} onValueChange={setTenant} required>
<SelectTrigger id="tenant" className="w-full">
<SelectValue placeholder="Select tenant" />
</SelectTrigger>
<SelectContent>
{TENANTS.map((t) => (
<SelectItem key={t} value={t}>
{t}
</SelectItem>
))}
</SelectContent>
</Select>
</div>

{/* Remember me */}
<div className="flex items-center gap-2">
<Checkbox
id="rememberMe"
checked={rememberMe}
onCheckedChange={(v) => setRememberMe(Boolean(v))}
/>
<Label htmlFor="rememberMe" className="font-normal cursor-pointer">
Remember me
</Label>
</div>

{/* Submit */}
<Button
type="submit"
className="w-full bg-[#1565C0] hover:bg-[#0d47a1] text-white"
>
Sign In
</Button>
</form>

{/* Footer */}
<p className="text-center text-xs text-muted-foreground">
Powered by Mifos Initiative
</p>
</div>
</div>
)
}
Loading
Loading