Skip to content

Commit 2f549ac

Browse files
committed
Merge branch 'feature/consistency-before-first-prod-deployment'
2 parents 6d95828 + 1af55bc commit 2f549ac

File tree

127 files changed

+7274
-1041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+7274
-1041
lines changed

app/src/app/activity-categories/use-activity-categories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ export type Queries = {
1616
};
1717

1818
type ActivityCategoryResult = {
19-
activityCategories: Tables<"activity_category_available">[];
19+
activityCategories: Tables<"activity_category_enabled">[];
2020
count: number;
2121
};
2222

2323
const fetcher: Fetcher<ActivityCategoryResult, { pagination: Pagination; queries: Queries }> = async ({ pagination, queries }) => {
2424
const client = await getBrowserRestClient();
25-
let query = client.from('activity_category_available').select('*', { count: 'exact' });
25+
let query = client.from('activity_category_enabled').select('*', { count: 'exact' });
2626

2727
const offset = pagination.pageNumber && pagination.pageSize
2828
? (pagination.pageNumber - 1) * pagination.pageSize

app/src/app/dashboard/statistical-variable-count-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useAtomValue } from 'jotai';
99
import { statDefinitionsAtom } from '@/atoms/base-data'; // Assuming statDefinitionsAtom holds the active ones or we need a new atom
1010

1111
export const StatisticalVariableCountCard = () => {
12-
// This atom currently holds all stat_definition_active from baseDataAtom.
12+
// This atom currently holds all stat_definition_enabled from baseDataAtom.
1313
// If you need a specific atom that just fetches the count, it should be created.
1414
// For now, we derive the count from the length of the statDefinitions array.
1515
const statDefinitions = useAtomValue(statDefinitionsAtom);

app/src/app/getting-started/getting-started-server-actions.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface State {
1212
export type UploadView =
1313
| "region_upload"
1414
| "import_legal_unit_current"
15-
| "activity_category_available_custom"
15+
| "activity_category_enabled_custom"
1616
| "import_establishment_current_for_legal_unit"
1717
| "import_establishment_current_without_legal_unit"
1818
| "sector_custom_only"
@@ -98,10 +98,32 @@ export async function setSettings(formData: FormData) {
9898
}
9999

100100
try {
101+
// region_version_id is required — use form value if provided, else fetch the initial one
102+
const regionVersionIdFormEntry = formData.get("region_version_id");
103+
let regionVersionId: number;
104+
if (regionVersionIdFormEntry) {
105+
regionVersionId = parseInt(regionVersionIdFormEntry.toString(), 10);
106+
if (isNaN(regionVersionId)) {
107+
return { error: "Invalid region version provided" };
108+
}
109+
} else {
110+
const { data: rv, error: rvError } = await client
111+
.from("region_version")
112+
.select("id")
113+
.eq("code", "initial")
114+
.limit(1)
115+
.single();
116+
if (rvError || !rv) {
117+
return { error: "Could not find initial region version" };
118+
}
119+
regionVersionId = rv.id;
120+
}
121+
101122
const response = await client.from("settings").upsert(
102123
{
103124
activity_category_standard_id: activityCategoryStandardId,
104125
country_id: countryId,
126+
region_version_id: regionVersionId,
105127
},
106128
{
107129
onConflict: "only_one_setting",

app/src/app/getting-started/upload-custom-activity-standard-codes/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const CustomActivityCodesCountDisplay = () => {
3737
</InfoBox>
3838
)}
3939
<UploadCSVForm
40-
uploadView="activity_category_available_custom"
40+
uploadView="activity_category_enabled_custom"
4141
nextPage="/getting-started/upload-regions"
4242
refreshRelevantCounts={async () => refreshCodesCount()}
4343
/>

app/src/app/legal-units/[id]/general-info/general-info-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default function GeneralInfoForm({ id }: { readonly id: string }) {
104104
/>
105105
<div className="grid lg:grid-cols-2 gap-4 p-2">
106106
{externalIdentTypes.map(
107-
(type: Tables<"external_ident_type_active">) => {
107+
(type: Tables<"external_ident_type_enabled">) => {
108108
const value = legalUnit?.external_idents[type.code];
109109

110110
// Use hierarchical field component for hierarchical identifier types

app/src/app/legal-units/[id]/statistical-variables/statistical-variables-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function StatisticalVariablesForm({
5151
</InfoBox>
5252
)}
5353
{statDefinitions.map(
54-
(statDefinition: Tables<"stat_definition_active">) => {
54+
(statDefinition: Tables<"stat_definition_enabled">) => {
5555
const stat = stats?.find(
5656
(s) => s.stat_definition_id === statDefinition.id
5757
);

app/src/app/reports/ReportsPageClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function ReportsPageClient({
4646
const statisticalVariables = useMemo(() => {
4747
return [
4848
{ value: "count", label: "Count", title: "Number of enterprises" },
49-
...(statDefinitions.map(({ code, name }: Tables<'stat_definition_active'>) => ({
49+
...(statDefinitions.map(({ code, name }: Tables<'stat_definition_enabled'>) => ({
5050
value: code!,
5151
label: name!,
5252
title: name!,

app/src/app/search/SearchPageClient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface SearchPageClientProps {
1919
readonly allStatuses: Tables<"status">[];
2020
readonly allUnitSizes: Tables<"unit_size">[];
2121
readonly allDataSources: Tables<"data_source_used">[];
22-
readonly allExternalIdentTypes: Tables<"external_ident_type_active">[];
22+
readonly allExternalIdentTypes: Tables<"external_ident_type_enabled">[];
2323
readonly allLegalForms: Tables<"legal_form_used">[];
2424
readonly allSectors: Tables<"sector_used">[];
2525
readonly initialUrlSearchParamsString: string;

app/src/app/search/SearchResults.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface SearchResultsProps {
3333
readonly allStatuses: Tables<"status">[];
3434
readonly allUnitSizes: Tables<"unit_size">[];
3535
readonly allDataSources: Tables<"data_source_used">[];
36-
readonly allExternalIdentTypes: Tables<"external_ident_type_active">[];
36+
readonly allExternalIdentTypes: Tables<"external_ident_type_enabled">[];
3737
readonly allLegalForms: Tables<"legal_form_used">[];
3838
readonly allSectors: Tables<"sector_used">[];
3939
readonly initialUrlSearchParamsString: string;
@@ -43,8 +43,8 @@ interface SearchResultsProps {
4343
// It is a pure function and is the single source of truth for URL -> State conversion.
4444
const deriveStateFromUrl = (
4545
urlSearchParams: URLSearchParams,
46-
externalIdentTypes: Tables<'external_ident_type_active'>[],
47-
statDefinitions: Tables<'stat_definition_active'>[]
46+
externalIdentTypes: Tables<'external_ident_type_enabled'>[],
47+
statDefinitions: Tables<'stat_definition_enabled'>[]
4848
): { _initialQuery: string; _initialFilters: Record<string, any>; _initialPagination: SearchPagination; _initialSorting: SearchSorting } => {
4949

5050
const ftsAction = fullTextSearchDeriveStateUpdateFromSearchParams(urlSearchParams);

app/src/app/search/components/statistical-unit-table-header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function StatisticalUnitTableHeader({
3939
key={`h-cell-${headerCellSuffix(column)}`}
4040
>
4141
<small className="flex">
42-
{externalIdentTypes.map(({ name }: Tables<'external_ident_type_active'>) => name).join(" | ")}
42+
{externalIdentTypes.map(({ name }: Tables<'external_ident_type_enabled'>) => name).join(" | ")}
4343
</small>
4444
</SortableTableHead>
4545
);
@@ -96,7 +96,7 @@ export function StatisticalUnitTableHeader({
9696
if (column.type === "Adaptable" && column.stat_code) {
9797
// Retrieve the matching stat definition based on stat_code
9898
const statDefinition = statDefinitions.find(
99-
(statDefinition: Tables<'stat_definition_active'>) => statDefinition.code === column.stat_code
99+
(statDefinition: Tables<'stat_definition_enabled'>) => statDefinition.code === column.stat_code
100100
);
101101

102102
return (

0 commit comments

Comments
 (0)