Skip to content

Commit

Permalink
chore(client): implement new route structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Sep 18, 2024
1 parent aacaaf9 commit fd7b53b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion client/app/app/(feed)/page.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import PostList from '@/components/app/Post/List';
import { getFeed } from '@/lib/api/auth';
import { getFeed } from '@/lib/api/me';

export default function Page() {
const fetchPosts = async (offset) => {
Expand Down
2 changes: 1 addition & 1 deletion client/app/app/settings/account/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { useToast } from '@/components/ui/use-toast';
import { useAuthStore } from '@/stores/auth';
import { updateMe } from '@/lib/api/auth';
import { updateMe } from '@/lib/api/me';

export default function Page() {
const user = useAuthStore((state) => state.user);
Expand Down
2 changes: 1 addition & 1 deletion client/app/app/settings/profile/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Button } from '@/components/ui/button';
import { useToast } from '@/components/ui/use-toast';
import Avatar from '@/components/app/User/Avatar';
import { useAuthStore } from '@/stores/auth';
import { updateMe } from '@/lib/api/auth';
import { updateMe } from '@/lib/api/me';

const formSchema = z.object({
display_name: z
Expand Down
2 changes: 1 addition & 1 deletion client/components/app/Providers/Auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useEffect } from 'react';
import useLoadingStore from '@/stores/loading';
import useAuthStore from '@/stores/auth';
import { me } from '@/lib/api/auth';
import { me } from '@/lib/api/me';

export default function AuthProvider({ children }) {
const setUser = useAuthStore((state) => state.setUser);
Expand Down
27 changes: 0 additions & 27 deletions client/lib/api/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,4 @@ export async function logout() {
} catch (error) {
return error.response;
}
}

export async function me() {
try {
const response = await api.get('/auth/me');
return response;
} catch (error) {
return error.response;
}
}

export async function updateMe(data) {
try {
const response = await api.patch('/auth/me', data);
return response;
} catch (error) {
return error.response;
}
}

export async function getFeed() {
try {
const response = await api.get('/auth/me/feed');
return response;
} catch (error) {
return error.response;
}
}
28 changes: 28 additions & 0 deletions client/lib/api/me/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import api from '@/lib/api';

export async function me() {
try {
const response = await api.get('/me');
return response;
} catch (error) {
return error.response;
}
}

export async function updateMe(data) {
try {
const response = await api.patch('/me', data);
return response;
} catch (error) {
return error.response;
}
}

export async function getFeed() {
try {
const response = await api.get('/me/feed');
return response;
} catch (error) {
return error.response;
}
}

0 comments on commit fd7b53b

Please sign in to comment.