Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
fix: adjusted id parameters for mock api calls (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaseta authored Feb 10, 2023
1 parent 60b14a2 commit 82117e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/components/FavouriteActivities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const FavouriteActivities = () => {
});
};

const updateCards = (index: number, card: CardType) => {
const putUrl = getUrl(ApiAddresses.FavouriteActiviteSave).replace(':id', index.toString());
const updateCards = (index: string, card: CardType) => {
const putUrl = getUrl(ApiAddresses.FavouriteActiviteSave).replace(':id', index);
axios.put(putUrl, card, getAxiosConfig())
.catch((error) => {
// eslint-disable-next-line
Expand All @@ -70,11 +70,11 @@ const FavouriteActivities = () => {

// We need to remove the current highlighted card
// if it exists, so we can submit new highlighted one
cards.forEach((item: CardType, i: number) => {
cards.forEach((item: CardType) => {
const card = item;
if (card.highlighted && card.id !== target.id) {
card.highlighted = false;
updateCards(i, card);
updateCards(card.id, card);
}
});

Expand All @@ -83,12 +83,12 @@ const FavouriteActivities = () => {
} else {
target.highlighted = false;
}
updateCards(index, target);
updateCards(target.id, target);
getCards();
};

const deleteCard = (index:number) => {
const deleteUrl = getUrl(ApiAddresses.FavouriteActiviteDelete).replace(':id', index.toString());
const deleteCard = (index:string) => {
const deleteUrl = getUrl(ApiAddresses.FavouriteActiviteDelete).replace(':id', index);
axios.delete(deleteUrl, getAxiosConfig())
.then(() => {
getCards();
Expand Down Expand Up @@ -132,7 +132,7 @@ const FavouriteActivities = () => {
description={card.description}
highlighted={card.highlighted}
highlightFunction={() => { highlightFunction(index); }}
deleteFunction={() => { deleteCard(index); }}
deleteFunction={() => { deleteCard(card.id); }}
/>
))}
</Row>
Expand Down
16 changes: 8 additions & 8 deletions src/mock-api/fixtures/FavouriteActivitiesCardItems.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const FavouriteActivitiesCardItems = [
{
id: '0',
id: '1',
image: 'SoilMoistureField',
header: 'Seedlot registration',
description:
Expand All @@ -9,7 +9,7 @@ const FavouriteActivitiesCardItems = [
highlighted: false
},
{
id: '1',
id: '2',
image: 'Tree',
header: 'Parent tree orchard',
description:
Expand All @@ -18,7 +18,7 @@ const FavouriteActivitiesCardItems = [
highlighted: false
},
{
id: '2',
id: '3',
image: 'CropHealth',
header: 'Latest sowing date recommended',
description:
Expand All @@ -27,39 +27,39 @@ const FavouriteActivitiesCardItems = [
highlighted: false
},
{
id: '3',
id: '4',
image: 'CropGrowth',
header: 'Seedling request',
description: 'Open a new seedling request for your reforestation needs.',
link: '#',
highlighted: false
},
{
id: '4',
id: '5',
image: 'MapBoundaryVegetation',
header: 'Orchard maintenance',
description: 'Keep your orchard update with the orchard maintenance.',
link: '#',
highlighted: false
},
{
id: '5',
id: '6',
image: 'Sprout',
header: 'Generic shortcut',
description: 'Generic shortcut page description',
link: '#',
highlighted: false
},
{
id: '6',
id: '7',
image: 'Sprout',
header: 'Generic shortcut',
description: 'Generic shortcut page description',
link: '#',
highlighted: false
},
{
id: '7',
id: '8',
image: 'Sprout',
header: 'Generic shortcut',
description: 'Generic shortcut page description',
Expand Down
1 change: 1 addition & 0 deletions src/mock-api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function makeServer(environment = 'development') {
routes() {
this.namespace = 'mock-api';
this.passthrough('https://test.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token');
this.passthrough('https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token');
}
});

Expand Down

0 comments on commit 82117e6

Please sign in to comment.