Skip to content

Commit

Permalink
feat(client): Respect Sub-topic and Dataset order
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Nov 22, 2024
1 parent dd90257 commit 45785d2
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 15 deletions.
7 changes: 1 addition & 6 deletions client/src/components/panels/contextual-layers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import XMarkIcon from "@/svgs/xmark.svg";
import Item from "./item";

const ContextualLayersPanel = () => {
const { data, isLoading } = useDatasetsBySubTopic(
"contextual",
"sub_topic.name,name",
["layer", "download_link"],
true,
);
const { data, isLoading } = useDatasetsBySubTopic("contextual", ["layer", "download_link"], true);

return (
<>
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/drought/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import useDatasetsBySubTopic from "@/hooks/use-datasets-by-sub-topic";
const DroughtPanel = () => {
const { data, isLoading } = useDatasetsBySubTopic(
"drought",
"sub_topic.name:desc,name",
["name", "params_config", "download_link"],
true,
);
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/flood/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import useDatasetsBySubTopic from "@/hooks/use-datasets-by-sub-topic";
const FloodPanel = () => {
const { data, isLoading } = useDatasetsBySubTopic(
"flood",
"sub_topic.name:desc,name",
["name", "params_config", "download_link"],
true,
);
Expand Down
1 change: 0 additions & 1 deletion client/src/components/panels/hydrometeorological/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import HydrometeorologicalImage from "../../../../public/assets/images/hydromete
const HydrometeorologicalPanel = () => {
const { data, isLoading } = useDatasetsBySubTopic(
"hydrometeorological",
"sub_topic.name:desc,name",
["name", "params_config", "download_link"],
true,
);
Expand Down
7 changes: 3 additions & 4 deletions client/src/hooks/use-datasets-by-sub-topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type DatasetsBySubTopic = {

export default function useDatasetsBySubTopic(
topicSlug: string,
sort = "sub_topic.name,name",
layersFields = ["name"],
includeMetadata = false,
) {
Expand All @@ -25,10 +24,10 @@ export default function useDatasetsBySubTopic(
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-error
fields: ["name", "short_description"],
fields: ["name", "short_description", "order"],
populate: {
sub_topic: {
fields: ["name"],
fields: ["name", "order"],
},
default_layer: {
fields: ["id"],
Expand All @@ -46,7 +45,7 @@ export default function useDatasetsBySubTopic(
},
},
},
sort,
sort: "sub_topic.order,order",
},
{
query: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/use-topic-tab-layer-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useTopicTabLayerManagement() {

const [layers, { addLayer, removeLayer }] = useMapLayers();

const { data, isLoading } = useDatasetsBySubTopic(tab, "sub_topic.name:desc,name");
const { data, isLoading } = useDatasetsBySubTopic(tab);

// The ids of all the layers that belong to the topic
const topicLayerIds = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-11-22T14:00:12.515Z"
"x-generation-date": "2024-11-22T14:01:53.948Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit 45785d2

Please sign in to comment.