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
1 change: 1 addition & 0 deletions apps/community-tool-ui/src/formBuilder/form.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { create } from 'zustand';
const useStore = create((set) => ({
extras: {},
setExtras: (newExtras: any) => set({ extras: newExtras }),
resetExtras: () => set({ extras: {} }),
}));

export default useStore;
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
} from '../../../utils';

export default function AddBeneficiary() {
const { extras }: any = useFormStore();
const { extras, resetExtras }: any = useFormStore();

const { pagination } = usePagination();
const { data: definitions } = useActiveFieldDefList({
Expand Down Expand Up @@ -141,6 +141,8 @@ export default function AddBeneficiary() {
};

const nonEmptyFields = selectNonEmptyFields(formData);

console.log(extras);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover console.log(extras) in the submit handler will leak potentially sensitive form context to the browser console and adds noise in production. Please remove it (or gate behind an explicit dev-only debug flag).

Suggested change
console.log(extras);

Copilot uses AI. Check for mistakes.
await addCommunityBeneficiary.mutateAsync({
...nonEmptyFields,
extras,
Expand All @@ -150,11 +152,37 @@ export default function AddBeneficiary() {
useEffect(() => {
if (addCommunityBeneficiary.isSuccess) {
form.reset();
resetExtras();
}
}, [addCommunityBeneficiary.isSuccess, form]);

const filteredDefinitions = filterFieldDefs(definitions);

const phoneValue = form.watch('phone');

useEffect(() => {
// Only set phoneStatus if phone passes validation
const isValidPhone =
phoneValue &&
phoneValue.length >= 10 &&
/^[0-9+\-()]*$/.test(phoneValue) &&
!/\s/.test(phoneValue);

if (isValidPhone) {
form.setValue('phoneStatus', PhoneStatus.SMART_PHONE, {
shouldValidate: true,
});
} else {
form.setValue('phoneStatus', '');
}
}, [phoneValue, form]);

useEffect(() => {
if (extras.bank_ac_name && extras.bank_ac_number && extras.bank_name) {
form.setValue('bankedStatus', BankedStatus.BANKED);
}
}, [extras.bank_ac_name, extras.bank_ac_number, extras.bank_name, form]);

return (
<Form {...form}>
<form onSubmit={form.handleSubmit(handleCreateBeneficiary)}>
Expand Down Expand Up @@ -244,7 +272,7 @@ export default function AddBeneficiary() {
<FormItem>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
value={field.value}
>
<FormControl>
<SelectTrigger>
Expand Down Expand Up @@ -279,7 +307,7 @@ export default function AddBeneficiary() {
<FormItem>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
value={field.value}
>
<FormControl>
<SelectTrigger>
Expand Down Expand Up @@ -341,7 +369,7 @@ export default function AddBeneficiary() {
<FormItem>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
value={field.value}
>
<FormControl>
<SelectTrigger>
Expand Down Expand Up @@ -528,7 +556,6 @@ export default function AddBeneficiary() {
<br />
{filteredDefinitions && filteredDefinitions.length > 0
? filteredDefinitions.map((definition: any) => {
console.log(definition);
return (
<>
<FormBuilder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 'use client';
'use client';

import { zodResolver } from '@hookform/resolvers/zod';
import { Button } from '@rahat-ui/shadcn/src/components/ui/button';
Expand Down Expand Up @@ -151,7 +151,13 @@ export default function EditBeneficiary({ data }: { data: ListBeneficiary }) {
const formattedDate = formatDate(formData.birthDate as Date);
formData.birthDate = formattedDate;
}
if (formData.phone) {
formData.phoneStatus = PhoneStatus.SMART_PHONE;
}

if (extras.bank_ac_name && extras.bank_ac_number && extras.bank_name) {
formData.bankedStatus = BankedStatus.BANKED;
}
const nonEmptyFields = selectNonEmptyFields(formData);
if (extras.hasOwnProperty('isDuplicate')) {
delete extras.isDuplicate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const PopulationInsights = ({ data }: Props) => {
const vulnerabilityStatus =
data?.data?.find((f) => f?.name === 'VULNERABIILTY_STATUS') || ([] as any);

const benefMapStatsocialProtectionBenefitss =
const benefMapStats =
data?.data?.find((f) => f?.name === 'BENEFICIARY_MAP_STATS') || ([] as any);

const filteredCoords =
Expand Down
5 changes: 5 additions & 0 deletions apps/rahat-ui/src/app/import-beneficiary/[uuid]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ImportDetailView from 'apps/rahat-ui/src/sections/import-beneficiary/importDetailView';

export default function Page() {
return <ImportDetailView />;
}
13 changes: 13 additions & 0 deletions apps/rahat-ui/src/app/import-beneficiary/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client';

import * as React from 'react';
import DashboardLayout from '../dashboard/layout';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<DashboardLayout>
<title>Import Beneficiary</title>
{children}
</DashboardLayout>
);
}
5 changes: 5 additions & 0 deletions apps/rahat-ui/src/app/import-beneficiary/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import ImportListView from '../../sections/import-beneficiary/importListView';

export default function Page() {
return <ImportListView />;
}
2 changes: 2 additions & 0 deletions apps/rahat-ui/src/routes/paths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ROOTS = {
PROFILE: '/profile',
TREASURY: '/treasury',
COMMUNITYBENEFICIARY: '/community-beneficiary',
IMPORTBENEFICIARY: '/import-beneficiary',
SETTINGS: '/settings',
APPAUTHENTICATION: '/auth-apps',
};
Expand Down Expand Up @@ -47,6 +48,7 @@ export const paths = {
`${ROOTS.COMMUNICATION}/text/${id}/edit`,
},
communitybeneficiary: ROOTS.COMMUNITYBENEFICIARY,
importBeneficiary: ROOTS.IMPORTBENEFICIARY,
appAuthentication: ROOTS.APPAUTHENTICATION,
},
settings: {
Expand Down
4 changes: 2 additions & 2 deletions apps/rahat-ui/src/sections/beneficiary/beneficiary.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ function BeneficiaryView() {
</DropdownMenuTrigger>
<DropdownMenuContent className="min-w-(--radix-dropdown-menu-trigger-width)">
<DropdownMenuItem
onClick={() => router.push('/community-beneficiary')}
onClick={() => router.push('/import-beneficiary')}
>
Import from Community Tool
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => router.push('/beneficiary/import')}
onClick={() => router.push('/beneficiary-import')}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

router.push('/beneficiary-import') points to a route that doesn’t exist in the app router (there is apps/rahat-ui/src/app/beneficiary/import/, which maps to /beneficiary/import). This click will navigate to a 404; update the path to the actual route (or add the missing route if /beneficiary-import is intended).

Suggested change
onClick={() => router.push('/beneficiary-import')}
onClick={() => router.push('/beneficiary/import')}

Copilot uses AI. Check for mistakes.
>
Import from Excel Sheet
</DropdownMenuItem>
Expand Down
Loading
Loading