Skip to content

Commit

Permalink
[frontend] make fnt
Browse files Browse the repository at this point in the history
  • Loading branch information
kotto5 committed Jan 30, 2024
1 parent 894f879 commit 0dc9563
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions frontend/app/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function signIn({

export async function authenticate(
prevState: string | undefined,
formData: FormData
formData: FormData,
) {
try {
await signIn({
Expand Down Expand Up @@ -98,7 +98,7 @@ export async function getUser(id: number) {

export async function updateUser(
prevState: string | undefined,
formData: FormData
formData: FormData,
) {
const { user_id, ...updateData } = Object.fromEntries(formData.entries());
const res = await fetch(`${process.env.API_URL}/user/${user_id}`, {
Expand All @@ -121,7 +121,7 @@ export async function updateUser(

export async function deleteUser(
prevState: string | undefined,
formData: FormData
formData: FormData,
) {
const { user_id } = Object.fromEntries(formData.entries());
const res = await fetch(`${process.env.API_URL}/user/${user_id}`, {
Expand Down Expand Up @@ -194,7 +194,7 @@ export async function getDirectRoom(userId: number) {

export async function createRoom(
prevState: { error?: string },
formData: FormData
formData: FormData,
) {
let payload;
if (formData.get("accessLevel") === "PROTECTED") {
Expand Down Expand Up @@ -256,7 +256,7 @@ export async function createDirectRoom(userId: number) {
export async function joinRoom(
roomId: number,
prevState: { error: string } | undefined,
formData: FormData
formData: FormData,
) {
const payload = JSON.stringify({
password: formData.get("password"),
Expand Down Expand Up @@ -288,7 +288,7 @@ export async function inviteUserToRoom(roomId: number, userId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
const data = await res.json();
if (!res.ok) {
Expand All @@ -303,7 +303,7 @@ export async function updateRoom(
roomName: string,
roomId: number,
accessLevel: AccessLevel,
password?: string
password?: string,
) {
const res = await fetch(`${process.env.API_URL}/room/${roomId}`, {
method: "PATCH",
Expand All @@ -324,7 +324,7 @@ export async function updateRoom(
export async function updateRoomUser(
role: string,
roomId: number,
userId: number
userId: number,
) {
const res = await fetch(`${process.env.API_URL}/room/${roomId}/${userId}`, {
method: "PATCH",
Expand Down Expand Up @@ -353,7 +353,7 @@ export async function kickUserOnRoom(roomId: number, userId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("kickUserOnRoom error: ", await res.json());
Expand Down Expand Up @@ -405,7 +405,7 @@ export async function getMessages(roomId: number) {

export async function updatePassword(
prevState: string | undefined,
formData: FormData
formData: FormData,
) {
// Check if new password and confirm password match
const newPassword = formData.get("new-password");
Expand Down Expand Up @@ -528,7 +528,7 @@ export async function addFriend(recipientId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("addFriend error: ", await res.json());
Expand All @@ -547,7 +547,7 @@ export async function getFriendRequests(): Promise<FriendRequestsEntity> {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("getFriendRequests error: ", await res.json());
Expand All @@ -567,7 +567,7 @@ export async function acceptFriendRequest(requesterId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("acceptFriendRequest error: ", await res.json());
Expand All @@ -587,7 +587,7 @@ export async function rejectFriendRequest(requesterId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("rejectFriendRequest error: ", await res.json());
Expand All @@ -607,7 +607,7 @@ export async function cancelFriendRequest(recipientId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("cancelFriendRequest error: ", await res.json());
Expand Down Expand Up @@ -638,7 +638,7 @@ export async function unfriend(friendId: number) {
}

export async function getMatchHistory(
userId: number
userId: number,
): Promise<MatchHistoryEntity[]> {
console.log(`${process.env.API_URL}/user/${userId}/history`);
const res = await fetch(`${process.env.API_URL}/user/${userId}/history`, {
Expand Down Expand Up @@ -688,7 +688,7 @@ export async function generate2FASecret() {

export async function enableTwoFactorAuthentication(
prevState: string,
formData: FormData
formData: FormData,
) {
const code = formData.get("code") as string;
const res = await fetch(`${process.env.API_URL}/auth/2fa/enable`, {
Expand All @@ -712,7 +712,7 @@ export async function enableTwoFactorAuthentication(

export async function twoFactorAuthenticate(
prevState: string,
formData: FormData
formData: FormData,
) {
const code = formData.get("code") as string;
const res = await fetch(`${process.env.API_URL}/auth/2fa/authenticate`, {
Expand Down Expand Up @@ -802,7 +802,7 @@ export async function banUser(roomId: number, userId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("banUser error: ", await res.json());
Expand Down Expand Up @@ -836,7 +836,7 @@ export async function unbanUser(roomId: number, userId: number) {
headers: {
Authorization: "Bearer " + getAccessToken(),
},
}
},
);
if (!res.ok) {
console.error("unbanUser error: ", await res.json());
Expand Down Expand Up @@ -865,7 +865,7 @@ export async function leaveRoom(roomId: number) {

export async function createUserWithOauth(
code: string | string[] | undefined,
provider: string
provider: string,
) {
if (!code) return;
const url = `${process.env.API_URL}/auth/oauth2/signup/${provider}`;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/ui/user/user-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function UserList({
avatarSize: AvatarSize;
}) {
const [onlineStatus, setOnlineStatus] = useState<{ [key: string]: boolean }>(
{}
{},
);

const fetchOnlineStatus = async () => {
Expand Down

0 comments on commit 0dc9563

Please sign in to comment.