Skip to content

Commit

Permalink
Merge pull request #3840 from bcgov/feat/3165
Browse files Browse the repository at this point in the history
chore: organize constants
  • Loading branch information
junminahn authored Sep 25, 2024
2 parents 8a3db10 + 5feec87 commit cd5ac96
Show file tree
Hide file tree
Showing 25 changed files with 354 additions and 354 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import { zodResolver } from '@hookform/resolvers/zod';
import { notifications } from '@mantine/notifications';
import { PrivateCloudProject } from '@prisma/client';
import { IconInfoCircle, IconUsersGroup, IconSettings, IconComponents } from '@tabler/icons-react';
import { useEffect, useState } from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { proxy, useSnapshot } from 'valtio';
import { z } from 'zod';
import Table from '@/components/generic/table/Table';
import TableBodyPrivateRequests from '@/components/table/TableBodyPrivateRequests';
import { requestSortsInProduct } from '@/constants/private-cloud';
import { requestSortsInProduct } from '@/constants';
import createClientPage from '@/core/client-page';
import { processPrivateCloudRequestData } from '@/helpers/row-mapper';
import { searchPrivateCloudRequests } from '@/services/backend/private-cloud/requests';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { proxy, useSnapshot } from 'valtio';
import { requestSortsInProduct } from '@/constants/private-cloud';
import { requestSortsInProduct } from '@/constants';
import { PrivateCloudRequestSearchBody } from '@/validation-schemas/private-cloud';

export const pageState = proxy<PrivateCloudRequestSearchBody>({
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/products/all/FilterPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ministry, Cluster, Prisma, ProjectStatus } from '@prisma/client';
import { useSnapshot } from 'valtio';
import FormMultiSelect from '@/components/generic/select/FormMultiSelect';
import { clusters, ministryOptions } from '@/constants';
import { ministryOptions, clusters } from '@/constants';
import { pageState } from './state';

export default function FilterPanel() {
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/products/all/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
import { proxy, useSnapshot } from 'valtio';
import Table from '@/components/generic/table/Table';
import TableBodyPrivateProducts from '@/components/table/TableBodyPrivateProducts';
import { productSorts } from '@/constants/private-cloud';
import { productSorts } from '@/constants';
import createClientPage from '@/core/client-page';
import { processPrivateCloudProductData } from '@/helpers/row-mapper';
import { searchPrivateCloudProducts, downloadPrivateCloudProducts } from '@/services/backend/private-cloud/products';
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/products/all/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Prisma, ProjectStatus } from '@prisma/client';
import { proxy, useSnapshot } from 'valtio';
import { productSorts } from '@/constants/private-cloud';
import { productSorts } from '@/constants';
import { PrivateCloudProductSearchBody } from '@/validation-schemas/private-cloud';

export const pageState = proxy<PrivateCloudProductSearchBody>({
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/requests/all/FilterPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Cluster, DecisionStatus, Ministry, Prisma, RequestType } from '@prisma/client';
import { useSnapshot } from 'valtio';
import FormMultiSelect from '@/components/generic/select/FormMultiSelect';
import { clusters, ministryOptions } from '@/constants';
import { ministryOptions, clusters } from '@/constants';
import { pageState } from './state';

export default function FilterPanel() {
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/requests/all/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
import { proxy, useSnapshot } from 'valtio';
import Table from '@/components/generic/table/Table';
import TableBodyPrivateRequests from '@/components/table/TableBodyPrivateRequests';
import { requestSorts } from '@/constants/private-cloud';
import { requestSorts } from '@/constants';
import createClientPage from '@/core/client-page';
import { processPrivateCloudRequestData } from '@/helpers/row-mapper';
import { searchPrivateCloudRequests } from '@/services/backend/private-cloud/requests';
Expand Down
2 changes: 1 addition & 1 deletion app/app/private-cloud/requests/all/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { proxy, useSnapshot } from 'valtio';
import { requestSorts } from '@/constants/private-cloud';
import { requestSorts } from '@/constants';
import { PrivateCloudRequestSearchBody } from '@/validation-schemas/private-cloud';

export const pageState = proxy<PrivateCloudRequestSearchBody>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useEffect, useRef, useState } from 'react';
import { useSnapshot, subscribe } from 'valtio';
import FormToggle from '@/components/generic/checkbox/FormToggle';
import FormSelect from '@/components/generic/select/FormSelect';
import { ministryOptions, providerOptions } from '@/constants';
import { productSorts } from '@/constants/private-cloud';
import { ministryOptions, productSorts, providerOptions } from '@/constants';
import { pageState } from './state';

export default function FilterPanel() {
Expand Down
3 changes: 1 addition & 2 deletions app/app/public-cloud/products/all/FilterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useEffect, useRef, useState } from 'react';
import { useSnapshot, subscribe } from 'valtio';
import FormToggle from '@/components/generic/checkbox/FormToggle';
import FormSelect from '@/components/generic/select/FormSelect';
import { ministryOptions, providerOptions } from '@/constants';
import { productSorts } from '@/constants/private-cloud';
import { ministryOptions, productSorts, providerOptions } from '@/constants';
import { pageState } from './state';

export default function FilterPanel() {
Expand Down
3 changes: 1 addition & 2 deletions app/app/public-cloud/requests/all/FilterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useEffect, useRef, useState } from 'react';
import { useSnapshot, subscribe } from 'valtio';
import FormToggle from '@/components/generic/checkbox/FormToggle';
import FormSelect from '@/components/generic/select/FormSelect';
import { providers, ministryOptions, providerOptions } from '@/constants';
import { productSorts } from '@/constants/private-cloud';
import { ministryOptions, productSorts, providerOptions } from '@/constants';
import { pageState } from './state';

export default function FilterPanel() {
Expand Down
254 changes: 254 additions & 0 deletions app/constants/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
import { Ministry, Prisma } from '@prisma/client';

export const ministries = Object.values(Ministry);

export const ministryOptions = [
{
value: 'AEST',
label: 'Post-Secondary Education and Future Skills Contacts',
},
{
value: 'AG',
label: 'Attorney General',
},
{
value: 'AGRI',
label: 'Agriculture and Food',
},
{
value: 'ALC',
label: 'Advisory Committee Revitalization',
},
{
value: 'BCPC',
label: 'British Columbia Provincial Committee',
},
{
value: 'CITZ',
label: 'Citizens Services',
},
{
value: 'DBC',
label: 'Drug Benefit Council',
},
{
value: 'EAO',
label: 'Environmental Assessment Office',
},
{
value: 'EDUC',
label: 'Education and Child Care',
},
{
value: 'EMBC',
label: 'Emergency Management',
},
{
value: 'EMPR',
label: 'Energy, Mines and Low Carbon Innovation',
},
{
value: 'ENV',
label: 'Environment and Climate Change Strategy',
},
{
value: 'FIN',
label: 'Finance',
},
{
value: 'FLNR',
label: 'Forests, Lands, Natural Resource',
},
{
value: 'HLTH',
label: 'Health',
},
{
value: 'IRR',
label: 'Indigenous Relations & Reconciliation',
},
{
value: 'JEDC',
label: 'Jobs, Economic Development and Innovation',
},
{
value: 'LBR',
label: 'Labour',
},
{
value: 'LDB',
label: 'Liquor Distribution Branch',
},
{
value: 'MAH',
label: 'Municipal Affairs and Housing',
},
{
value: 'MCF',
label: 'Children and Family Development',
},
{
value: 'MMHA',
label: 'Mental Health and Addictions',
},
{
value: 'PSA',
label: 'Public Service Agency',
},
{
value: 'PSSG',
label: 'Public Safety and Solicitor General',
},
{
value: 'SDPR',
label: 'Social Development and Poverty Reduction',
},
{
value: 'TCA',
label: 'Tangible Capital Assets',
},
{
value: 'TRAN',
label: 'Transportation and Infrastructure',
},
{
value: 'HOUS',
label: 'Ministry of Housing',
},
];

export const AGMinistries = ['AG', 'PSSG', 'EMBC', 'HOUS'];

export const TEAM_SA_PREFIX = 'z_pltsvc-tsa-';

export const productSorts = [
{
label: 'Product update date (new to old)',
sortKey: 'updatedAt',
sortOrder: Prisma.SortOrder.desc,
},
{
label: 'Product update date (old to new)',
sortKey: 'updatedAt',
sortOrder: Prisma.SortOrder.asc,
},
{
label: 'Product name (A-Z)',
sortKey: 'name',
sortOrder: Prisma.SortOrder.asc,
},
{
label: 'Product name (Z-A)',
sortKey: 'name',
sortOrder: Prisma.SortOrder.desc,
},
{
label: 'Product description (A-Z)',
sortKey: 'description',
sortOrder: Prisma.SortOrder.asc,
},
{
label: 'Product description (Z-A)',
sortKey: 'description',
sortOrder: Prisma.SortOrder.desc,
},
{
label: 'Product Licence Plate (A-Z)',
sortKey: 'licencePlate',
sortOrder: Prisma.SortOrder.asc,
},
{
label: 'Product Licence Plate (Z-A)',
sortKey: 'licencePlate',
sortOrder: Prisma.SortOrder.desc,
},
];

export const requestSorts = [
{
label: 'Request update date (new to old)',
sortKey: 'updatedAt',
sortOrder: Prisma.SortOrder.desc,
inData: false,
},
{
label: 'Request update date (old to new)',
sortKey: 'updatedAt',
sortOrder: Prisma.SortOrder.asc,
inData: false,
},
{
label: 'Request create date (new to old)',
sortKey: 'createdAt',
sortOrder: Prisma.SortOrder.desc,
inData: false,
},
{
label: 'Request create date (old to new)',
sortKey: 'createdAt',
sortOrder: Prisma.SortOrder.asc,
inData: false,
},
{
label: 'Request review date (new to old)',
sortKey: 'decisionDate',
sortOrder: Prisma.SortOrder.desc,
inData: false,
},
{
label: 'Request review date (old to new)',
sortKey: 'decisionDate',
sortOrder: Prisma.SortOrder.asc,
inData: false,
},
{
label: 'Request complete date (new to old)',
sortKey: 'provisionedDate',
sortOrder: Prisma.SortOrder.desc,
inData: false,
},
{
label: 'Request complete date (old to new)',
sortKey: 'provisionedDate',
sortOrder: Prisma.SortOrder.asc,
inData: false,
},
{
label: 'Product name (A-Z)',
sortKey: 'name',
sortOrder: Prisma.SortOrder.asc,
inData: true,
},
{
label: 'Product name (Z-A)',
sortKey: 'name',
sortOrder: Prisma.SortOrder.desc,
inData: true,
},
{
label: 'Product description (A-Z)',
sortKey: 'description',
sortOrder: Prisma.SortOrder.asc,
inData: true,
},
{
label: 'Product description (Z-A)',
sortKey: 'description',
sortOrder: Prisma.SortOrder.desc,
inData: true,
},
{
label: 'Product Licence Plate (A-Z)',
sortKey: 'licencePlate',
sortOrder: Prisma.SortOrder.asc,
inData: true,
},
{
label: 'Product Licence Plate (Z-A)',
sortKey: 'licencePlate',
sortOrder: Prisma.SortOrder.desc,
inData: true,
},
];

export const requestSortsInProduct = requestSorts.filter((v) => v.sortKey !== 'licencePlate');
Loading

0 comments on commit cd5ac96

Please sign in to comment.