Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed total number of suppliers #1147

Merged
merged 1 commit into from
Mar 19, 2024
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
14 changes: 12 additions & 2 deletions client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ const nextConfig = {
return [
{
source: '/',
destination: '/analysis/map',
destination: '/eurd',
permanent: false,
},
{
source: '/analysis',
destination: '/analysis/map',
destination: '/eudr',
permanent: false,
},
{
source: '/analysis/:id',
destination: '/eudr',
permanent: false,
},
{
source: '/data',
destination: '/eurd',
permanent: false,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
TableCell,
} from '@/components/ui/table';
import { useEUDRData } from '@/hooks/eudr';
import { useAppSelector } from '@/store/hooks';
import { eudr } from '@/store/features/eudr';
import { useAppSelector, useAppDispatch } from '@/store/hooks';
import { eudr, setTotalSuppliers } from '@/store/features/eudr';

import type {
// ColumnFiltersState,
Expand All @@ -50,6 +50,7 @@ export interface Supplier {
}

const SuppliersListTable = (): JSX.Element => {
const dispatch = useAppDispatch();
// const [rowSelection, setRowSelection] = useState({});
// const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
// const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
Expand All @@ -68,6 +69,9 @@ const SuppliersListTable = (): JSX.Element => {
},
{
select: (data) => data?.table,
onSuccess: (data) => {
dispatch(setTotalSuppliers(data?.length || 0));
},
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const TOOLTIP_LABELS = {
const SuppliersStackedBar = () => {
const {
viewBy,
totalSuppliers,
filters: { dates, suppliers, origins, materials },
} = useAppSelector(eudr);
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -92,7 +93,7 @@ const SuppliersStackedBar = () => {
<div className="space-y-4">
<div>
<div className="text-xs text-gray-400">
Total numbers of suppliers: <span className="font-mono">{parsedData?.length || '-'}</span>
Total numbers of suppliers: <span>{totalSuppliers}</span>
</div>
<div className="flex items-center justify-between">
<h3>Suppliers by category</h3>
Expand Down
7 changes: 7 additions & 0 deletions client/src/store/features/eudr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type LayerConfiguration = {

export type EUDRState = {
viewBy: (typeof VIEW_BY_OPTIONS)[number]['value'];
totalSuppliers: number;
filters: {
materials: Option[];
origins: Option[];
Expand All @@ -39,6 +40,7 @@ export type EUDRState = {

export const initialState: EUDRState = {
viewBy: 'materials',
totalSuppliers: 0,
filters: {
materials: [],
origins: [],
Expand Down Expand Up @@ -91,6 +93,10 @@ export const EUDRSlice = createSlice({
...state,
viewBy: action.payload,
}),
setTotalSuppliers: (state, action: PayloadAction<EUDRState['totalSuppliers']>) => ({
...state,
totalSuppliers: action.payload,
}),
setFilters: (state, action: PayloadAction<Partial<EUDRState['filters']>>) => ({
...state,
filters: {
Expand Down Expand Up @@ -141,6 +147,7 @@ export const EUDRSlice = createSlice({

export const {
setViewBy,
setTotalSuppliers,
setFilters,
setBasemap,
setSupplierLayer,
Expand Down
Loading