fix: my profile activity endpoint (#1983)

* fix: my profile activity endpoint

* chore: update service name
This commit is contained in:
Aaryan Khandelwal 2023-08-28 13:29:48 +05:30 committed by GitHub
parent 6e7701d854
commit 485e56bcdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -25,18 +25,10 @@ const ProfileActivity = () => {
const router = useRouter();
const { workspaceSlug } = router.query;
const { data: userActivity } = useSWR(USER_ACTIVITY, () => userService.getUserActivity());
if (!userActivity) {
return (
<Loader className="space-y-5">
<Loader.Item height="40px" />
<Loader.Item height="40px" />
<Loader.Item height="40px" />
<Loader.Item height="40px" />
</Loader>
const { data: userActivity } = useSWR(
workspaceSlug ? USER_ACTIVITY : null,
workspaceSlug ? () => userService.getUserActivity(workspaceSlug.toString()) : null
);
}
return (
<WorkspaceAuthorizationLayout
@ -56,7 +48,7 @@ const ProfileActivity = () => {
</div>
<SettingsNavbar profilePage />
</div>
{userActivity && userActivity.results.length > 0 && (
{userActivity ? (
<div>
<ul role="list" className="-mb-4">
{userActivity.results.map((activityItem: any, activityIdx: number) => {
@ -226,6 +218,13 @@ const ProfileActivity = () => {
})}
</ul>
</div>
) : (
<Loader className="space-y-5">
<Loader.Item height="40px" />
<Loader.Item height="40px" />
<Loader.Item height="40px" />
<Loader.Item height="40px" />
</Loader>
)}
</div>
</WorkspaceAuthorizationLayout>

View File

@ -101,8 +101,8 @@ class UserService extends APIService {
});
}
async getUserActivity(): Promise<IUserActivityResponse> {
return this.get("/api/users/activities/")
async getUserWorkspaceActivity(workspaceSlug: string): Promise<IUserActivityResponse> {
return this.get(`/api/users/workspaces/${workspaceSlug}/activities/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;