-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(portal): add post push history creation
- Loading branch information
Showing
7 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 25 additions & 6 deletions
31
kraken-app/kraken-app-portal/src/hooks/pushApiEvent/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
import { getPushEventHistory } from '@/services/pushApiActivity'; | ||
import { createActivityHistoryLog, getPushEventHistory } from '@/services/pushApiActivity'; | ||
import { STALE_TIME } from '@/utils/constants/common'; | ||
import { IPagingData } from '@/utils/types/common.type'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { ICreateActivityHistoryLogRequest, IPagingData } from '@/utils/types/common.type'; | ||
import { useMutation, useQuery } from '@tanstack/react-query'; | ||
import { AxiosResponse } from 'axios'; | ||
import { PRODUCT_CACHE_KEYS } from '../product'; | ||
import { queryClient } from "@/utils/helpers/reactQuery"; | ||
|
||
const PUSH_API_EVENT_CACHE_KEYS = { | ||
create_activity_history_log: "create_activity_history_log", | ||
get_product_env_list: "get_product_env_list", | ||
}; | ||
|
||
export const useGetPushActivityLogHistory = () => { | ||
return useQuery<AxiosResponse, Error, IPagingData<any>>({ // TODO: type push history | ||
queryKey: [PRODUCT_CACHE_KEYS.get_product_env_list], | ||
queryKey: [PUSH_API_EVENT_CACHE_KEYS.get_product_env_list], | ||
queryFn: () => getPushEventHistory(), | ||
select: (data) => data.data, | ||
staleTime: STALE_TIME, | ||
}); | ||
} | ||
} | ||
|
||
export const usePostPushActivityLog = () => { | ||
return useMutation<any, Error, ICreateActivityHistoryLogRequest>({ | ||
mutationKey: [PUSH_API_EVENT_CACHE_KEYS.create_activity_history_log], | ||
mutationFn: (data) => { | ||
return createActivityHistoryLog(data); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ | ||
queryKey: [PUSH_API_EVENT_CACHE_KEYS.create_activity_history_log], | ||
}); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
kraken-app/kraken-app-portal/src/services/pushApiActivity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import request from "@/utils/helpers/request"; | ||
import { PUSH_API_ACTIVITY } from "@/utils/constants/api"; | ||
import { ICreateActivityHistoryLogRequest } from '@/utils/types/common.type'; | ||
|
||
export const getPushEventHistory = () => | ||
request(`${PUSH_API_ACTIVITY}/history`); | ||
|
||
export const createActivityHistoryLog = (payload: ICreateActivityHistoryLogRequest) => { | ||
return request(PUSH_API_ACTIVITY, { | ||
method: "POST", | ||
data: { | ||
...payload, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters