Introduce prettier

This commit is contained in:
Takeshi Kimata
2024-05-19 21:04:45 +09:00
parent cbb5993276
commit 75eeebefda
89 changed files with 872 additions and 944 deletions

View File

@@ -1,50 +1,42 @@
import { tv } from "tailwind-variants";
import { tv } from 'tailwind-variants';
export const title = tv({
base: "tracking-tight inline font-semibold",
base: 'tracking-tight inline font-semibold',
variants: {
color: {
violet: "from-[#FF1CF7] to-[#b249f8]",
yellow: "from-[#FF705B] to-[#FFB457]",
blue: "from-[#5EA2EF] to-[#0072F5]",
cyan: "from-[#00b7fa] to-[#01cfea]",
green: "from-[#6FEE8D] to-[#17c964]",
pink: "from-[#FF72E1] to-[#F54C7A]",
foreground: "dark:from-[#FFFFFF] dark:to-[#4B4B4B]",
violet: 'from-[#FF1CF7] to-[#b249f8]',
yellow: 'from-[#FF705B] to-[#FFB457]',
blue: 'from-[#5EA2EF] to-[#0072F5]',
cyan: 'from-[#00b7fa] to-[#01cfea]',
green: 'from-[#6FEE8D] to-[#17c964]',
pink: 'from-[#FF72E1] to-[#F54C7A]',
foreground: 'dark:from-[#FFFFFF] dark:to-[#4B4B4B]',
},
size: {
sm: "text-3xl lg:text-4xl",
md: "text-[2.3rem] lg:text-5xl leading-9",
lg: "text-4xl lg:text-6xl",
sm: 'text-3xl lg:text-4xl',
md: 'text-[2.3rem] lg:text-5xl leading-9',
lg: 'text-4xl lg:text-6xl',
},
fullWidth: {
true: "w-full block",
true: 'w-full block',
},
},
defaultVariants: {
size: "md",
size: 'md',
},
compoundVariants: [
{
color: [
"violet",
"yellow",
"blue",
"cyan",
"green",
"pink",
"foreground",
],
class: "bg-clip-text text-transparent bg-gradient-to-b",
color: ['violet', 'yellow', 'blue', 'cyan', 'green', 'pink', 'foreground'],
class: 'bg-clip-text text-transparent bg-gradient-to-b',
},
],
});
export const subtitle = tv({
base: "w-full md:w-1/2 my-2 text-lg lg:text-xl text-default-600 block max-w-full",
base: 'w-full md:w-1/2 my-2 text-lg lg:text-xl text-default-600 block max-w-full',
variants: {
fullWidth: {
true: "!w-full",
true: '!w-full',
},
},
defaultVariants: {

View File

@@ -2,4 +2,4 @@ const Config = {
apiServer: process.env.NEXT_PUBLIC_BACKEND_ORIGIN || 'http://localhost:3001',
};
export default Config;
export default Config;

View File

@@ -1,11 +1,11 @@
import { Fira_Code as FontMono, Inter as FontSans } from "next/font/google";
import { Fira_Code as FontMono, Inter as FontSans } from 'next/font/google';
export const fontSans = FontSans({
subsets: ["latin"],
variable: "--font-sans",
subsets: ['latin'],
variable: '--font-sans',
});
export const fontMono = FontMono({
subsets: ["latin"],
variable: "--font-mono",
subsets: ['latin'],
variable: '--font-mono',
});

View File

@@ -1,92 +1,74 @@
const roles = [{ uid: "admin" }, { uid: "moderator" }, { uid: "user" }];
const roles = [{ uid: 'admin' }, { uid: 'moderator' }, { uid: 'user' }];
const categoricalPalette = [
"#fba91e",
"#6ea56c",
"#3ac6e1",
"#feda2f",
"#f15f47",
"#244470",
"#9c80bb",
"#f595a6",
];
const categoricalPalette = ['#fba91e', '#6ea56c', '#3ac6e1', '#feda2f', '#f15f47', '#244470', '#9c80bb', '#f595a6'];
const priorities = [
{ uid: "critical", color: "#bb3e03", chartColor: "#bb3e03" },
{ uid: "high", color: "#ca6702", chartColor: "#ca6702" },
{ uid: "medium", color: "#ee9b00", chartColor: "#ee9b00" },
{ uid: "low", color: "#94d2bd", chartColor: "#94d2bd" },
{ uid: 'critical', color: '#bb3e03', chartColor: '#bb3e03' },
{ uid: 'high', color: '#ca6702', chartColor: '#ca6702' },
{ uid: 'medium', color: '#ee9b00', chartColor: '#ee9b00' },
{ uid: 'low', color: '#94d2bd', chartColor: '#94d2bd' },
];
const testTypes = [
{ uid: "other", chartColor: categoricalPalette[0] },
{ uid: "security", chartColor: categoricalPalette[1] },
{ uid: "performance", chartColor: categoricalPalette[2] },
{ uid: "accessibility", chartColor: categoricalPalette[3] },
{ uid: "functional", chartColor: categoricalPalette[4] },
{ uid: "acceptance", chartColor: categoricalPalette[5] },
{ uid: "usability", chartColor: categoricalPalette[6] },
{ uid: "smokeSanity", chartColor: categoricalPalette[7] },
{ uid: "compatibility", chartColor: categoricalPalette[0] },
{ uid: "destructive", chartColor: categoricalPalette[1] },
{ uid: "regression", chartColor: categoricalPalette[2] },
{ uid: "automated", chartColor: categoricalPalette[3] },
{ uid: "manual", chartColor: categoricalPalette[4] },
{ uid: 'other', chartColor: categoricalPalette[0] },
{ uid: 'security', chartColor: categoricalPalette[1] },
{ uid: 'performance', chartColor: categoricalPalette[2] },
{ uid: 'accessibility', chartColor: categoricalPalette[3] },
{ uid: 'functional', chartColor: categoricalPalette[4] },
{ uid: 'acceptance', chartColor: categoricalPalette[5] },
{ uid: 'usability', chartColor: categoricalPalette[6] },
{ uid: 'smokeSanity', chartColor: categoricalPalette[7] },
{ uid: 'compatibility', chartColor: categoricalPalette[0] },
{ uid: 'destructive', chartColor: categoricalPalette[1] },
{ uid: 'regression', chartColor: categoricalPalette[2] },
{ uid: 'automated', chartColor: categoricalPalette[3] },
{ uid: 'manual', chartColor: categoricalPalette[4] },
];
const automationStatus = [
{ name: "Automated", uid: "automated" },
{ name: "Automation Not Required", uid: "automation-not-required" },
{ name: "Cannot Be Automated", uid: "cannot-be-automated" },
{ name: "Obsolete", uid: "obsolete" },
{ name: 'Automated', uid: 'automated' },
{ name: 'Automation Not Required', uid: 'automation-not-required' },
{ name: 'Cannot Be Automated', uid: 'cannot-be-automated' },
{ name: 'Obsolete', uid: 'obsolete' },
];
const templates = [{ uid: "text" }, { uid: "step" }];
const templates = [{ uid: 'text' }, { uid: 'step' }];
const testRunStatus = [
{ uid: "new" },
{ uid: "inProgress" },
{ uid: "underReview" },
{ uid: "rejected" },
{ uid: "done" },
{ uid: "closed" },
{ uid: 'new' },
{ uid: 'inProgress' },
{ uid: 'underReview' },
{ uid: 'rejected' },
{ uid: 'done' },
{ uid: 'closed' },
];
const testRunCaseStatus = [
{
uid: "untested",
color: "primary",
chartColor: "#3ac6e1",
uid: 'untested',
color: 'primary',
chartColor: '#3ac6e1',
},
{ uid: "passed", color: "success", chartColor: "#6ea56c" },
{ uid: "failed", color: "danger", chartColor: "#f15f47" },
{ uid: "retest", color: "warning", chartColor: "#fba91e" },
{ uid: "skipped", color: "primary", chartColor: "#805aab" },
{ uid: 'passed', color: 'success', chartColor: '#6ea56c' },
{ uid: 'failed', color: 'danger', chartColor: '#f15f47' },
{ uid: 'retest', color: 'warning', chartColor: '#fba91e' },
{ uid: 'skipped', color: 'primary', chartColor: '#805aab' },
];
const avatars = [
"/avatar/bear.png",
"/avatar/cat.png",
"/avatar/cow.png",
"/avatar/dog.png",
"/avatar/giraffe.png",
"/avatar/koala.png",
"/avatar/lion.png",
"/avatar/owl.png",
"/avatar/panda.png",
"/avatar/penguin.png",
"/avatar/rhinoceros.png",
"/avatar/shark.png",
"/avatar/sloth.png",
'/avatar/bear.png',
'/avatar/cat.png',
'/avatar/cow.png',
'/avatar/dog.png',
'/avatar/giraffe.png',
'/avatar/koala.png',
'/avatar/lion.png',
'/avatar/owl.png',
'/avatar/panda.png',
'/avatar/penguin.png',
'/avatar/rhinoceros.png',
'/avatar/shark.png',
'/avatar/sloth.png',
];
export {
roles,
priorities,
testTypes,
automationStatus,
templates,
testRunStatus,
testRunCaseStatus,
avatars,
};
export { roles, priorities, testTypes, automationStatus, templates, testRunStatus, testRunCaseStatus, avatars };

View File

@@ -1,4 +1,4 @@
const createNextIntlPlugin = require("next-intl/plugin");
const createNextIntlPlugin = require('next-intl/plugin');
const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */

View File

@@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};

View File

@@ -1,13 +1,13 @@
import { UserType } from "@/types/user";
import { avatars } from "@/config/selection";
import Config from "@/config/config";
import { UserType } from '@/types/user';
import { avatars } from '@/config/selection';
import Config from '@/config/config';
const apiServer = Config.apiServer;
async function signUp(newUser: UserType) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(newUser),
};
@@ -22,16 +22,16 @@ async function signUp(newUser: UserType) {
const token = await response.json();
return token;
} catch (error: any) {
console.error("Error sign up:", error);
console.error('Error sign up:', error);
throw error;
}
}
async function signIn(signInUser: UserType) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(signInUser),
};
@@ -46,7 +46,7 @@ async function signIn(signInUser: UserType) {
const token = await response.json();
return token;
} catch (error: any) {
console.error("Error sign in:", error);
console.error('Error sign in:', error);
throw error;
}
}

View File

@@ -1,24 +1,24 @@
import { expect, test } from "vitest";
import { isValidEmail, isValidPassword } from "./validate";
import { expect, test } from 'vitest';
import { isValidEmail, isValidPassword } from './validate';
test("validate email", () => {
const email1 = "aaa@gmail.com";
test('validate email', () => {
const email1 = 'aaa@gmail.com';
expect(isValidEmail(email1)).toBe(true);
const email2 = "gmail.com";
const email2 = 'gmail.com';
expect(isValidEmail(email2)).toBe(false);
const email23 = "";
const email23 = '';
expect(isValidEmail(email23)).toBe(false);
});
test("validate password", () => {
const pass1 = "aaaaaaaa";
test('validate password', () => {
const pass1 = 'aaaaaaaa';
expect(isValidPassword(pass1)).toBe(true);
const pass2 = "abcdefg";
const pass2 = 'abcdefg';
expect(isValidPassword(pass2)).toBe(false);
const pass3 = "";
const pass3 = '';
expect(isValidPassword(pass3)).toBe(false);
});

View File

@@ -1,6 +1,5 @@
function isValidEmail(email: string) {
const validRegex =
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
const validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (email.match(validRegex)) {
return true;
} else {

View File

@@ -1,8 +1,8 @@
import { expect, test } from "vitest";
import { isImage } from "./isImage";
import { AttachmentType } from "@/types/case";
import { expect, test } from 'vitest';
import { isImage } from './isImage';
import { AttachmentType } from '@/types/case';
test("isImage", () => {
test('isImage', () => {
type CaseAttachmentType = {
createdAt: Date;
updatedAt: Date;
@@ -19,17 +19,17 @@ test("isImage", () => {
const sampleAttachment: AttachmentType = {
id: 1,
title: "",
detail: "",
path: "",
title: '',
detail: '',
path: '',
createdAt: new Date(),
updatedAt: new Date(),
caseAttachments: sampleCaseAttachment,
};
sampleAttachment.path = "public/uploads/abc.png";
sampleAttachment.path = 'public/uploads/abc.png';
expect(isImage(sampleAttachment)).toBe(true);
sampleAttachment.path = "public/uploads/abc.mp3";
sampleAttachment.path = 'public/uploads/abc.mp3';
expect(isImage(sampleAttachment)).toBe(false);
});

View File

@@ -1,14 +1,11 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
async function fetchDownloadAttachment(
attachmentId: number,
downloadFileName: string
) {
async function fetchDownloadAttachment(attachmentId: number, downloadFileName: string) {
const fetchOptions = {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -23,14 +20,14 @@ async function fetchDownloadAttachment(
const blob = await response.blob();
const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement("a");
const link = document.createElement('a');
link.href = downloadUrl;
link.download = downloadFileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error: any) {
console.error("Error downloading file:", error);
console.error('Error downloading file:', error);
throw error;
}
}
@@ -39,31 +36,31 @@ async function fetchCreateAttachments(caseId: number, files: File[]) {
try {
const formData = new FormData();
for (let i = 0; i < files.length; i++) {
formData.append("files", files[i]);
formData.append('files', files[i]);
}
const url = `${apiServer}/attachments?parentCaseId=${caseId}`;
const response = await fetch(url, {
method: "POST",
method: 'POST',
body: formData,
});
if (!response.ok) {
throw new Error("Network response was not ok");
throw new Error('Network response was not ok');
}
const responseData = await response.json();
return responseData;
} catch (error: any) {
console.error("Error uploading files:", error);
console.error('Error uploading files:', error);
}
}
async function fetchDeleteAttachment(attachmentId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -75,13 +72,9 @@ async function fetchDeleteAttachment(attachmentId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting file:", error);
console.error('Error deleting file:', error);
throw error;
}
}
export {
fetchDownloadAttachment,
fetchCreateAttachments,
fetchDeleteAttachment,
};
export { fetchDownloadAttachment, fetchCreateAttachments, fetchDeleteAttachment };

View File

@@ -1,15 +1,15 @@
import { AttachmentType } from "@/types/case";
import { AttachmentType } from '@/types/case';
function isImage(attachmentFile: AttachmentType) {
let path = attachmentFile.path;
let extension = path.substring(path.lastIndexOf(".") + 1).toLowerCase();
let extension = path.substring(path.lastIndexOf('.') + 1).toLowerCase();
if (
extension === "png" ||
extension === "jpg" ||
extension === "jpeg" ||
extension === "gif" ||
extension === "bmp" ||
extension === "svg"
extension === 'png' ||
extension === 'jpg' ||
extension === 'jpeg' ||
extension === 'gif' ||
extension === 'bmp' ||
extension === 'svg'
) {
return true;
} else {

View File

@@ -1,11 +1,11 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
async function fetchCreateStep(newStepNo: number, parentCaseId: number) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -18,16 +18,16 @@ async function fetchCreateStep(newStepNo: number, parentCaseId: number) {
}
return await response.json();
} catch (error: any) {
console.error("Error deleting project:", error);
console.error('Error deleting project:', error);
throw error;
}
}
async function fetchDeleteStep(stepId: number, parentCaseId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -39,12 +39,9 @@ async function fetchDeleteStep(stepId: number, parentCaseId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting project:", error);
console.error('Error deleting project:', error);
throw error;
}
}
export {
fetchCreateStep,
fetchDeleteStep,
};
export { fetchCreateStep, fetchDeleteStep };

View File

@@ -1,15 +1,15 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
import { CaseType } from "@/types/case";
import { CaseType } from '@/types/case';
async function fetchCase(caseId: number) {
const url = `${apiServer}/cases/${caseId}`;
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -20,7 +20,7 @@ async function fetchCase(caseId: number) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
@@ -29,9 +29,9 @@ async function fetchCases(folderId: string) {
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -42,28 +42,28 @@ async function fetchCases(folderId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
async function createCase(folderId: string) {
const newCase = {
title: "untitled case",
title: 'untitled case',
state: 0,
priority: 2,
type: 0,
automationStatus: 0,
description: "",
description: '',
template: 0,
preConditions: "",
expectedResults: "",
preConditions: '',
expectedResults: '',
folderId: folderId,
};
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(newCase),
};
@@ -78,16 +78,16 @@ async function createCase(folderId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating case:", error);
console.error('Error creating case:', error);
throw error;
}
}
async function updateCase(updateCaseData: CaseType) {
const fetchOptions = {
method: "PUT",
method: 'PUT',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(updateCaseData),
};
@@ -102,16 +102,16 @@ async function updateCase(updateCaseData: CaseType) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error updating project:", error);
console.error('Error updating project:', error);
throw error;
}
}
async function deleteCase(caseId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -123,16 +123,16 @@ async function deleteCase(caseId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting case:", error);
console.error('Error deleting case:', error);
throw error;
}
}
async function deleteCases(deleteCases: string[]) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify({ caseIds: deleteCases }),
};
@@ -145,16 +145,9 @@ async function deleteCases(deleteCases: string[]) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting cases:", error);
console.error('Error deleting cases:', error);
throw error;
}
}
export {
fetchCase,
fetchCases,
updateCase,
createCase,
deleteCase,
deleteCases,
};
export { fetchCase, fetchCases, updateCase, createCase, deleteCase, deleteCases };

View File

@@ -1,4 +1,4 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
/**
@@ -8,9 +8,9 @@ async function fetchFolders(projectId: string) {
try {
const url = `${apiServer}/folders?projectId=${projectId}`;
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -21,19 +21,14 @@ async function fetchFolders(projectId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
/**
* Create project
*/
async function createFolder(
name: string,
detail: string,
projectId: strting,
parentFolderId: number
) {
async function createFolder(name: string, detail: string, projectId: strting, parentFolderId: number) {
const newFolderData = {
name: name,
detail: detail,
@@ -42,9 +37,9 @@ async function createFolder(
};
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(newFolderData),
};
@@ -59,7 +54,7 @@ async function createFolder(
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating new project:", error);
console.error('Error creating new project:', error);
throw error;
}
}
@@ -67,13 +62,7 @@ async function createFolder(
/**
* Update folder
*/
async function updateFolder(
folderId: number,
name: string,
detail: string,
projectId: string,
parentFolderId: number
) {
async function updateFolder(folderId: number, name: string, detail: string, projectId: string, parentFolderId: number) {
const updateFolderData = {
name: name,
detail: detail,
@@ -82,9 +71,9 @@ async function updateFolder(
};
const fetchOptions = {
method: "PUT",
method: 'PUT',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(updateFolderData),
};
@@ -99,7 +88,7 @@ async function updateFolder(
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error updating project:", error);
console.error('Error updating project:', error);
throw error;
}
}
@@ -109,9 +98,9 @@ async function updateFolder(
*/
async function deleteFolder(folderId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -123,7 +112,7 @@ async function deleteFolder(folderId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting project:", error);
console.error('Error deleting project:', error);
throw error;
}
}

View File

@@ -1,6 +1,6 @@
import { ProjectType } from "@/types/project";
import { testTypes, priorities, testRunCaseStatus } from "@/config/selection";
import { HomeMessages } from "./page";
import { ProjectType } from '@/types/project';
import { testTypes, priorities, testRunCaseStatus } from '@/config/selection';
import { HomeMessages } from './page';
// aggregate folder, case, run mum
function aggregateBasicInfo(project: ProjectType) {
@@ -85,9 +85,4 @@ function aggregateProgress(project: ProjectType, messages: HomeMessages) {
return { series, categories };
}
export {
aggregateBasicInfo,
aggregateTestType,
aggregateTestPriority,
aggregateProgress,
};
export { aggregateBasicInfo, aggregateTestType, aggregateTestPriority, aggregateProgress };

View File

@@ -1,15 +1,15 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
import { RunType, RunCaseInfoType } from "@/types/run";
import { RunType, RunCaseInfoType } from '@/types/run';
async function fetchRun(runId: string) {
const url = `${apiServer}/runs/${runId}`;
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -20,7 +20,7 @@ async function fetchRun(runId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
@@ -29,9 +29,9 @@ async function fetchRuns(projectId: string) {
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -42,23 +42,23 @@ async function fetchRuns(projectId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
async function createRun(projectId: string) {
const newTestRun = {
name: "untitled run",
name: 'untitled run',
configurations: 0,
description: "",
description: '',
state: 0,
projectId: projectId,
};
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(newTestRun),
};
@@ -73,16 +73,16 @@ async function createRun(projectId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating new test run:", error);
console.error('Error creating new test run:', error);
throw error;
}
}
async function updateRun(updateTestRun: RunType) {
const fetchOptions = {
method: "PUT",
method: 'PUT',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(updateTestRun),
};
@@ -97,16 +97,16 @@ async function updateRun(updateTestRun: RunType) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error updating run:", error);
console.error('Error updating run:', error);
throw error;
}
}
async function deleteRun(runId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -118,7 +118,7 @@ async function deleteRun(runId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting run:", error);
console.error('Error deleting run:', error);
throw error;
}
}
@@ -128,9 +128,9 @@ async function fetchRunCases(runId: string) {
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -141,15 +141,15 @@ async function fetchRunCases(runId: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
async function createRunCase(runId: string, caseId: number) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -163,16 +163,16 @@ async function createRunCase(runId: string, caseId: number) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating new runcase:", error);
console.error('Error creating new runcase:', error);
throw error;
}
}
async function updateRunCase(runId: string, caseId: number, status: number) {
const fetchOptions = {
method: "PUT",
method: 'PUT',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -186,16 +186,16 @@ async function updateRunCase(runId: string, caseId: number, status: number) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error updating runcase:", error);
console.error('Error updating runcase:', error);
throw error;
}
}
async function bulkCreateRunCases(runCaseInfo: RunCaseInfoType[]) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(runCaseInfo),
};
@@ -210,16 +210,16 @@ async function bulkCreateRunCases(runCaseInfo: RunCaseInfoType[]) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating new runcase:", error);
console.error('Error creating new runcase:', error);
throw error;
}
}
async function deleteRunCase(runId: string, caseId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -231,16 +231,16 @@ async function deleteRunCase(runId: string, caseId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting runcase:", error);
console.error('Error deleting runcase:', error);
throw error;
}
}
async function bulkDeleteRunCases(runCaseInfo: RunCaseInfoType[]) {
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(runCaseInfo),
};
@@ -253,7 +253,7 @@ async function bulkDeleteRunCases(runCaseInfo: RunCaseInfoType[]) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting runcase:", error);
console.error('Error deleting runcase:', error);
throw error;
}
}

View File

@@ -1,4 +1,4 @@
import Config from "@/config/config";
import Config from '@/config/config';
const apiServer = Config.apiServer;
/**
@@ -9,9 +9,9 @@ async function fetchProjects() {
try {
const response = await fetch(url, {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
});
@@ -22,7 +22,7 @@ async function fetchProjects() {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error fetching data:", error.message);
console.error('Error fetching data:', error.message);
}
}
@@ -36,9 +36,9 @@ async function createProject(name: string, detail: string) {
};
const fetchOptions = {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(newProjectData),
};
@@ -53,7 +53,7 @@ async function createProject(name: string, detail: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error creating new project:", error);
console.error('Error creating new project:', error);
throw error;
}
}
@@ -68,9 +68,9 @@ async function updateProject(projectId: number, name: string, detail: string) {
};
const fetchOptions = {
method: "PUT",
method: 'PUT',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
body: JSON.stringify(updatedProjectData),
};
@@ -85,7 +85,7 @@ async function updateProject(projectId: number, name: string, detail: string) {
const data = await response.json();
return data;
} catch (error: any) {
console.error("Error updating project:", error);
console.error('Error updating project:', error);
throw error;
}
}
@@ -95,9 +95,9 @@ async function updateProject(projectId: number, name: string, detail: string) {
*/
async function deleteProject(projectId: number) {
const fetchOptions = {
method: "DELETE",
method: 'DELETE',
headers: {
"Content-Type": "application/json",
'Content-Type': 'application/json',
},
};
@@ -109,7 +109,7 @@ async function deleteProject(projectId: number) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error: any) {
console.error("Error deleting project:", error);
console.error('Error deleting project:', error);
throw error;
}
}

View File

@@ -1,7 +1,7 @@
import { notFound } from "next/navigation";
import { getRequestConfig } from "next-intl/server";
import { notFound } from 'next/navigation';
import { getRequestConfig } from 'next-intl/server';
const locales = ["en", "ja"];
const locales = ['en', 'ja'];
export default getRequestConfig(async ({ locale }) => {
if (!locales.includes(locale as any)) notFound();

View File

@@ -1,12 +1,12 @@
import createMiddleware from "next-intl/middleware";
import { locales, localePrefix } from "./navigation";
import createMiddleware from 'next-intl/middleware';
import { locales, localePrefix } from './navigation';
export default createMiddleware({
defaultLocale: "en",
defaultLocale: 'en',
localePrefix,
locales,
});
export const config = {
matcher: ["/", "/(ja|en)/:path*"],
matcher: ['/', '/(ja|en)/:path*'],
};

View File

@@ -1,10 +1,9 @@
import { createSharedPathnamesNavigation } from "next-intl/navigation";
import { createSharedPathnamesNavigation } from 'next-intl/navigation';
export const locales = ["en", "ja"] as const;
export const localePrefix = "always";
export const locales = ['en', 'ja'] as const;
export const localePrefix = 'always';
export const { Link, redirect, usePathname, useRouter } =
createSharedPathnamesNavigation({ locales, localePrefix });
export const { Link, redirect, usePathname, useRouter } = createSharedPathnamesNavigation({ locales, localePrefix });
export const NextUiLinkClasses =
"data-[focus-visible=true]:outline-focus data-[focus-visible=true]:outline-offset-2 text-medium text-primary hover:underline hover:opacity-80 active:opacity-disabled transition-opacity underline-offset-4 dark:text-white";
'data-[focus-visible=true]:outline-focus data-[focus-visible=true]:outline-offset-2 text-medium text-primary hover:underline hover:opacity-80 active:opacity-disabled transition-opacity underline-offset-4 dark:text-white';

View File

@@ -1,37 +1,37 @@
import { nextui } from "@nextui-org/theme";
import { nextui } from '@nextui-org/theme';
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
'./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}',
],
theme: {
extend: {},
},
darkMode: "class",
darkMode: 'class',
plugins: [
nextui({
themes: {
light: {
colors: {
primary: {
DEFAULT: "#030712",
foreground: "#FFFFFF",
DEFAULT: '#030712',
foreground: '#FFFFFF',
},
focus: "#030712",
focus: '#030712',
},
},
dark: {
colors: {
primary: {
DEFAULT: "#1F883D",
foreground: "#FFFFFF",
DEFAULT: '#1F883D',
foreground: '#FFFFFF',
},
focus: "#1F883D",
focus: '#1F883D',
},
},
},

View File

@@ -1,4 +1,4 @@
import { CaseType } from "./case";
import { CaseType } from './case';
export type FolderType = {
id: number;

View File

@@ -1,4 +1,4 @@
import {SVGProps} from "react";
import { SVGProps } from 'react';
export type IconSvgProps = SVGProps<SVGSVGElement> & {
size?: number;

View File

@@ -1,5 +1,5 @@
import { FolderType } from "./folder";
import { RunType } from "./run";
import { FolderType } from './folder';
import { RunType } from './run';
export type ProjectType = {
id: number;

View File

@@ -29,10 +29,10 @@ type RunStatusCountType = {
type ProgressSeriesType = {
name: string;
data: number[];
}
};
type RunsMessages = {
runList: string,
runList: string;
id: string;
name: string;
description: string;
@@ -44,11 +44,11 @@ type RunsMessages = {
};
type RunMessages = {
backToRuns: string,
backToRuns: string;
updating: string;
update: string;
progress: string,
refresh: string,
progress: string;
refresh: string;
id: string;
title: string;
pleaseEnter: string;
@@ -78,12 +78,4 @@ type RunMessages = {
noCasesFound: string;
};
export {
RunType,
RunCaseType,
RunCaseInfoType,
RunStatusCountType,
ProgressSeriesType,
RunsMessages,
RunMessages,
};
export { RunType, RunCaseType, RunCaseInfoType, RunStatusCountType, ProgressSeriesType, RunsMessages, RunMessages };

View File

@@ -1,6 +1,6 @@
'use client'
import { usePathname } from 'next/navigation'
import { useState, useEffect } from "react";
'use client';
import { usePathname } from 'next/navigation';
import { useState, useEffect } from 'react';
type ProjectFolderIds = {
projectId: number | null;
@@ -12,21 +12,19 @@ type ProjectFolderIds = {
* Example: For the path '/projects/1/folders/3/cases', projectId would be 1 and folderId would be 3.
*/
const useGetCurrentIds = (): ProjectFolderIds => {
const pathname = usePathname()
const pathname = usePathname();
const [projectId, setProjectId] = useState<number | null>(null);
const [folderId, setFolderId] = useState<number | null>(null);
useEffect(() => {
const currentPath = pathname;
const pathSegments = currentPath.split("/").filter(Boolean);
const pathSegments = currentPath.split('/').filter(Boolean);
const projectIdIndex = pathSegments.indexOf("projects") + 1;
const folderIdIndex = pathSegments.indexOf("folders") + 1;
const projectIdIndex = pathSegments.indexOf('projects') + 1;
const folderIdIndex = pathSegments.indexOf('folders') + 1;
const newProjectId =
projectIdIndex !== -1 ? parseInt(pathSegments[projectIdIndex], 10) : null;
const newFolderId =
folderIdIndex !== -1 ? parseInt(pathSegments[folderIdIndex], 10) : null;
const newProjectId = projectIdIndex !== -1 ? parseInt(pathSegments[projectIdIndex], 10) : null;
const newFolderId = folderIdIndex !== -1 ? parseInt(pathSegments[folderIdIndex], 10) : null;
setProjectId(newProjectId);
setFolderId(newFolderId);