Skip to content

Commit

Permalink
Apply Prettier Formatting Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiramtilakiiit authored and github-actions[bot] committed Dec 10, 2024
1 parent 1603174 commit 6c08a9a
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 62 deletions.
13 changes: 6 additions & 7 deletions src/actions/storagefiles/delete/server_action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ export async function deleteStorageFile(fileId) {
const response = { ok: false, error: null };

try {
const result = await getClient().mutation(
DELETE_STORAGEFILE,
{
fileId,
},
);
const result = await getClient().mutation(DELETE_STORAGEFILE, {
fileId,
});

// Handle case where result is null or undefined
if (!result) {
Expand All @@ -29,7 +26,9 @@ export async function deleteStorageFile(fileId) {
if (error) {
response.error = {
title: error.name || "GraphQL Error",
messages: error?.graphQLErrors?.map((ge) => ge?.message) || ["Unknown error occurred"],
messages: error?.graphQLErrors?.map((ge) => ge?.message) || [
"Unknown error occurred",
],
};
} else {
// Safely access deleteStorageFile from data
Expand Down
13 changes: 6 additions & 7 deletions src/actions/storagefiles/update/server_action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ export async function updateStorageFile(fileId) {
const response = { ok: false, error: null };

try {
const result = await getClient().mutation(
UPDATE_STORAGEFILE,
{
fileId,
},
);
const result = await getClient().mutation(UPDATE_STORAGEFILE, {
fileId,
});

// Handle case where result is null or undefined
if (!result) {
Expand All @@ -29,7 +26,9 @@ export async function updateStorageFile(fileId) {
if (error) {
response.error = {
title: error.name || "GraphQL Error",
messages: error?.graphQLErrors?.map((ge) => ge?.message) || ["Unknown error occurred"],
messages: error?.graphQLErrors?.map((ge) => ge?.message) || [
"Unknown error occurred",
],
};
} else {
// Safely access updateStorageFile from data
Expand Down
2 changes: 1 addition & 1 deletion src/app/docs/[id]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function Docs({ params }) {

const { data: { userMeta, userProfile } = {} } = await getClient().query(
GET_USER,
{ userInput: null }
{ userInput: null },
);
const user = { ...userMeta, ...userProfile };

Expand Down
4 changes: 2 additions & 2 deletions src/app/docs/new/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default async function Docs({ params }) {

const { data: { userMeta, userProfile } = {} } = await getClient().query(
GET_USER,
{ userInput: null }
{ userInput: null },
);
const user = { ...userMeta, ...userProfile };

if (user?.role !== "cc") redirect("/404");

return <DocForm/>;
return <DocForm />;
}
4 changes: 2 additions & 2 deletions src/app/docs/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export default async function Docs() {
GET_ALL_FILES,
{
filetype: "pdf",
}
},
);

const { data: { userMeta, userProfile } = {} } = await getClient().query(
GET_USER,
{ userInput: null }
{ userInput: null },
);
const user = { ...userMeta, ...userProfile };
const isPriviliged = user?.role == "cc" ? true : false;
Expand Down
12 changes: 6 additions & 6 deletions src/components/FileUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function getIsTypeofFileRejected(fileRejections, type) {
// ),
// );
return fileRejections.some(({ errors }) =>
errors.some((error) => error.code == type)
errors.some((error) => error.code == type),
);
}

Expand Down Expand Up @@ -162,10 +162,10 @@ function DropZone({
typeof files === "string"
? getFile(files)
: Array.isArray(files)
? typeof files[0] === "string"
? getFile(files[0])
: URL.createObjectURL(files[0])
: null
? typeof files[0] === "string"
? getFile(files[0])
: URL.createObjectURL(files[0])
: null
}
width={800}
height={800}
Expand Down Expand Up @@ -209,7 +209,7 @@ function DropZone({
<FormHelperText
error={getIsTypeofFileRejected(
fileRejections,
ErrorCode.FileInvalidType
ErrorCode.FileInvalidType,
)}
sx={{ mt: 0 }}
>
Expand Down
6 changes: 3 additions & 3 deletions src/components/clubs/ClubForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function ClubForm({ defaultValues = {}, action = "log" }) {
data.logo = await uploadImageFile(
formData.logo[0],
logo_filename,
logo_warnSizeMB
logo_warnSizeMB,
);
} else {
data.logo = null;
Expand All @@ -168,7 +168,7 @@ export default function ClubForm({ defaultValues = {}, action = "log" }) {
data.banner = await uploadImageFile(
formData.banner[0],
banner_filename,
banner_warnSizeMB
banner_warnSizeMB,
);
}
} catch (error) {
Expand All @@ -191,7 +191,7 @@ export default function ClubForm({ defaultValues = {}, action = "log" }) {
data.bannerSquare = await uploadImageFile(
formData.bannerSquare[0],
bannerSquare_filename,
bannerSquare_warnSizeMB
bannerSquare_warnSizeMB,
);
}
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/docs/DocForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ export default function DocForm({ editFile = null, newFile = true }) {
// check all fields
if (!data.title || !data.file) {
throw new Error(
"Please fill all the required Fields before submitting."
"Please fill all the required Fields before submitting.",
);
}

const filename = await uploadPDFFile(
data.file[0],
true,
data.title,
maxFileSizeMB
maxFileSizeMB,
);
if (!filename) {
throw new Error("File upload failed, check Title and File validity");
Expand Down
13 changes: 9 additions & 4 deletions src/components/docs/DocItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Typography,
} from "@mui/material";

import { useTheme } from "@mui/material/styles";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";

import Icon from "components/Icon";
Expand All @@ -22,11 +22,16 @@ export default function DocItem({ file, onClose, open }) {
window.open(fileUrl, "_blank");
};
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('md'));

const fullScreen = useMediaQuery(theme.breakpoints.down("md"));

return (
<Dialog open={open} fullScreen={fullScreen} onClose={onClose} maxWidth="xl" fullWidth>
<Dialog
open={open}
fullScreen={fullScreen}
onClose={onClose}
maxWidth="xl"
fullWidth
>
<DialogTitle
sx={{
m: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/components/docs/DocsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function DocsList({ allFiles, priviliged = false }) {
const date = dayjs(
dateString.replace(" IST", ""),
"DD-MM-YYYY hh:mm A",
true
true,
);
if (!date.isValid()) {
console.error("Invalid date parsing for:", dateString);
Expand Down
20 changes: 15 additions & 5 deletions src/components/events/EventForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,24 @@ export default function EventForm({
}

// upload poster
const poster_filename = ("poster_" + data.name + '_' + data.clubid).replace(".", "_");
try{
const poster_filename = ("poster_" + data.name + "_" + data.clubid).replace(
".",
"_",
);
try {
if (typeof formData.poster === "string") {
data.poster = formData.poster;
} else if (Array.isArray(formData.poster) && formData.poster.length > 0) {
const { filename, underlimit } = await uploadImageFile(formData.poster[0], poster_filename);
const { filename, underlimit } = await uploadImageFile(
formData.poster[0],
poster_filename,
);
if (!underlimit) {
triggerToast({
title: "Warning",
messages: ["Poster FileSize exceeds the maximum limit of 0.3 MB, might affect quality during compression."],
messages: [
"Poster FileSize exceeds the maximum limit of 0.3 MB, might affect quality during compression.",
],
severity: "warning",
});
}
Expand All @@ -264,7 +272,9 @@ export default function EventForm({
} catch (error) {
triggerToast({
title: "Error",
messages: error.message ? [error.message] : error?.messages || ["Failed to upload poster"],
messages: error.message
? [error.message]
: error?.messages || ["Failed to upload poster"],
severity: "error",
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/profile/UserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function UserForm({ defaultValues = {}, action = "log" }) {
data.img = await uploadImageFile(
formData.img[0],
`profile_${defaultValues.uid}`,
profile_warnSizeMB
profile_warnSizeMB,
);
} else {
data.img = null;
Expand Down
30 changes: 15 additions & 15 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function middleware(req) {
requestHeaders.set("x-nonce", nonce);
requestHeaders.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
requestHeaders.set("X-Content-Type-Options", "nosniff");
requestHeaders.set("Referrer-Policy", "strict-origin-when-cross-origin");
Expand All @@ -54,7 +54,7 @@ export function middleware(req) {
});
response.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
response.headers.set("X-Content-Type-Options", "nosniff");
response.headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
Expand All @@ -64,16 +64,16 @@ export function middleware(req) {
// clear logout cookie
req.cookies.delete("logout");
const redirectRes = NextResponse.redirect(
new URL("/logoutCallback", req.url)
new URL("/logoutCallback", req.url),
);
redirectRes.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
redirectRes.headers.set("X-Content-Type-Options", "nosniff");
redirectRes.headers.set(
"Referrer-Policy",
"strict-origin-when-cross-origin"
"strict-origin-when-cross-origin",
);
return redirectRes;
}
Expand All @@ -85,12 +85,12 @@ export function middleware(req) {
);
redirectRes.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
redirectRes.headers.set("X-Content-Type-Options", "nosniff");
redirectRes.headers.set(
"Referrer-Policy",
"strict-origin-when-cross-origin"
"strict-origin-when-cross-origin",
);
return redirectRes;
}
Expand All @@ -107,16 +107,16 @@ export function middleware(req) {
// if protected and current user is not logged in, redirect to login page
if (!req.cookies.has("Authorization")) {
const redirectRes = NextResponse.redirect(
new URL(`/login${pathname}`, req.url)
new URL(`/login${pathname}`, req.url),
);
redirectRes.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
redirectRes.headers.set("X-Content-Type-Options", "nosniff");
redirectRes.headers.set(
"Referrer-Policy",
"strict-origin-when-cross-origin"
"strict-origin-when-cross-origin",
);
return redirectRes;
}
Expand All @@ -132,16 +132,16 @@ export function middleware(req) {
// club account specific redirects
if (clubRedirectRoute && user?.role === "club") {
const redirectRes = NextResponse.redirect(
new URL(clubRedirects[pathname], req.url)
new URL(clubRedirects[pathname], req.url),
);
redirectRes.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
redirectRes.headers.set("X-Content-Type-Options", "nosniff");
redirectRes.headers.set(
"Referrer-Policy",
"strict-origin-when-cross-origin"
"strict-origin-when-cross-origin",
);
return redirectRes;
}
Expand All @@ -152,12 +152,12 @@ export function middleware(req) {
const redirectRes = NextResponse.redirect(new URL("/", req.url));
redirectRes.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue
contentSecurityPolicyHeaderValue,
);
redirectRes.headers.set("X-Content-Type-Options", "nosniff");
redirectRes.headers.set(
"Referrer-Policy",
"strict-origin-when-cross-origin"
"strict-origin-when-cross-origin",
);
return redirectRes;
}
Expand Down
Loading

0 comments on commit 6c08a9a

Please sign in to comment.