Skip to content

Commit

Permalink
Fix Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Nov 26, 2024
1 parent 76872df commit 3549235
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 23 deletions.
13 changes: 0 additions & 13 deletions web/src/App.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions web/src/api/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const BASE_URL = 'http://localhost:3000';
// Replace SWR fetcher with axios or fetch implementation
// eslint-disable-next-line no-undef
export async function fetcher<T>(url: string, init?: RequestInit): Promise<T> {
const response = await fetch(url, init);
const response = await fetch(BASE_URL + url, init);

if (!response.ok) {
throw new Error('Network response was not ok');
Expand All @@ -26,7 +26,7 @@ export function useHttp<T>(key: string) {
export function useUpdateData<T>(url: string) {
return useMutation({
mutationFn: (data: T) =>
fetch(url, {
fetch(BASE_URL + url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
4 changes: 2 additions & 2 deletions web/src/api/me.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query';

import { useAuth } from './auth';
import { BASE_URL, fetcher } from './core';
import { fetcher } from './core';

interface MeResponse {
id: string;
Expand All @@ -16,7 +16,7 @@ export function useApiMe() {
return useQuery({
queryKey: ['me', token],
queryFn: () =>
fetcher<MeResponse>(`${BASE_URL}/api/me`, {
fetcher<MeResponse>('/api/me', {
headers: {
Authorization: `Bearer ${token}`,
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Navbar = () => {
</DropdownMenu.Root>
</div>
)}
{!token && (
{(!token || (token && !meData)) && (
<a
href={login_here_url}
className="h-full border-l px-2 py-0.5 flex items-center hover:bg-black/10"
Expand Down
5 changes: 1 addition & 4 deletions web/src/components/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ export const getInitials = (name?: string) => {
const UNKNOWN_USER = 'Unknown User';

export const UserProfile: FC<Properties> = ({ user_id, variant }) => {
const { data: user, isLoading } = useQuery({
queryKey: ['user', user_id],
queryFn: () => fetcher<User>(`${BASE_URL}/api/users/${user_id}`),
});
const { data: user, isLoading } = useApiUserById(user_id);

if (isLoading) {
return <div>Loading...</div>;
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/create.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const component = () => {
To create a new item you will need to give it an identifier.
You can choose to use a generated identifier (by clicking
the generate icon) or you can choose to provide your own
(a-zA-Z0-9).
(a-zA-Z0-9). Leading zeros will be trimmed.
</p>
<div className="flex items-center justify-end gap-2 px-6 pb-4">
<button className="btn w-fit flex items-center gap-2">
Expand Down

0 comments on commit 3549235

Please sign in to comment.