Fix apps/console lint issues
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -150,7 +150,7 @@ export const useDeleteAsset = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete "%s". This action cannot be undone.',
|
||||
"This will permanently delete \"%s\". This action cannot be undone.",
|
||||
),
|
||||
asset.name,
|
||||
),
|
||||
|
||||
@@ -135,7 +135,7 @@ export const useDeleteAudit = (
|
||||
await mutate({
|
||||
variables: {
|
||||
input: {
|
||||
auditId: audit.id!,
|
||||
auditId: audit.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { promisifyMutation, sprintf } from "@probo/helpers";
|
||||
import { useMutationWithToasts } from "../useMutationWithToasts";
|
||||
|
||||
export const ContinualImprovementsConnectionKey =
|
||||
"ContinualImprovementsPage_continualImprovements";
|
||||
export const ContinualImprovementsConnectionKey
|
||||
= "ContinualImprovementsPage_continualImprovements";
|
||||
|
||||
export const continualImprovementsQuery = graphql`
|
||||
query ContinualImprovementGraphListQuery(
|
||||
|
||||
@@ -144,7 +144,7 @@ export const useDeleteDatum = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete "%s". This action cannot be undone.',
|
||||
"This will permanently delete \"%s\". This action cannot be undone.",
|
||||
),
|
||||
datum.name,
|
||||
),
|
||||
|
||||
@@ -59,7 +59,7 @@ export const useDeleteFrameworkMutation = (
|
||||
return commitDelete({
|
||||
variables: {
|
||||
input: {
|
||||
frameworkId: framework.id!,
|
||||
frameworkId: framework.id,
|
||||
},
|
||||
connections: [connectionId],
|
||||
},
|
||||
@@ -69,7 +69,7 @@ export const useDeleteFrameworkMutation = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete framework "%s". This action cannot be undone.',
|
||||
"This will permanently delete framework \"%s\". This action cannot be undone.",
|
||||
),
|
||||
framework.name,
|
||||
),
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { promisifyMutation, sprintf } from "@probo/helpers";
|
||||
import { useMutationWithToasts } from "../useMutationWithToasts";
|
||||
|
||||
export const NonconformitiesConnectionKey =
|
||||
"NonconformitiesPage_nonconformities";
|
||||
export const NonconformitiesConnectionKey
|
||||
= "NonconformitiesPage_nonconformities";
|
||||
|
||||
export const nonconformitiesQuery = graphql`
|
||||
query NonconformityGraphListQuery($organizationId: ID!, $snapshotId: ID) {
|
||||
|
||||
@@ -58,7 +58,7 @@ export function usePeople(
|
||||
{ fetchPolicy: "network-only" },
|
||||
);
|
||||
return useMemo(() => {
|
||||
return data.organization?.peoples?.edges.map((edge) => edge.node) ?? [];
|
||||
return data.organization?.peoples?.edges.map(edge => edge.node) ?? [];
|
||||
}, [data]);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ export function usePeopleQuery(
|
||||
paginatedPeopleFragment,
|
||||
data.organization as PeopleGraphPaginatedFragment$key,
|
||||
);
|
||||
const people = pagination.data.peoples?.edges.map((edge) => edge.node);
|
||||
const people = pagination.data.peoples?.edges.map(edge => edge.node);
|
||||
return {
|
||||
...pagination,
|
||||
people,
|
||||
@@ -179,7 +179,7 @@ export const useDeletePeople = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete "%s". This action cannot be undone.',
|
||||
"This will permanently delete \"%s\". This action cannot be undone.",
|
||||
),
|
||||
people.fullName,
|
||||
),
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { promisifyMutation, sprintf } from "@probo/helpers";
|
||||
import { useMutationWithToasts } from "../useMutationWithToasts";
|
||||
|
||||
export const ProcessingActivitiesConnectionKey =
|
||||
"ProcessingActivitiesPage_processingActivities";
|
||||
export const ProcessingActivitiesConnectionKey
|
||||
= "ProcessingActivitiesPage_processingActivities";
|
||||
export type ProcessingActivityDPIAResidualRisk = "LOW" | "MEDIUM" | "HIGH";
|
||||
|
||||
export const processingActivitiesQuery = graphql`
|
||||
|
||||
@@ -97,7 +97,7 @@ export function useRisksQuery(queryRef: PreloadedQuery<RiskGraphListQuery>) {
|
||||
risksFragment,
|
||||
data.organization as RiskGraphFragment$key,
|
||||
);
|
||||
const risks = pagination.data?.risks?.edges.map((edge) => edge.node);
|
||||
const risks = pagination.data?.risks?.edges.map(edge => edge.node);
|
||||
|
||||
return {
|
||||
...pagination,
|
||||
|
||||
@@ -81,7 +81,7 @@ export function useStateOfApplicabilityQuery(
|
||||
paginatedStateOfApplicabilityFragment,
|
||||
data.organization as StateOfApplicabilityGraphPaginatedFragment$key,
|
||||
);
|
||||
const statesOfApplicability = pagination.data.statesOfApplicability?.edges.map((edge) => edge.node);
|
||||
const statesOfApplicability = pagination.data.statesOfApplicability?.edges.map(edge => edge.node);
|
||||
return {
|
||||
...pagination,
|
||||
statesOfApplicability,
|
||||
@@ -142,7 +142,7 @@ export const useDeleteStateOfApplicability = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete "%s". This action cannot be undone.',
|
||||
"This will permanently delete \"%s\". This action cannot be undone.",
|
||||
),
|
||||
stateOfApplicability.name,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { graphql } from 'react-relay';
|
||||
import { graphql } from "react-relay";
|
||||
|
||||
export const trustCenterByIdQuery = graphql`
|
||||
query TrustCenterAccessTokenGraphQuery($trustCenterId: ID!) {
|
||||
|
||||
@@ -28,7 +28,7 @@ export function useCreateTrustCenterFileMutation() {
|
||||
{
|
||||
successMessage: "File uploaded successfully",
|
||||
errorMessage: "Failed to upload file",
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export function useUpdateTrustCenterFileMutation() {
|
||||
{
|
||||
successMessage: "File updated successfully",
|
||||
errorMessage: "Failed to update file",
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,6 @@ export function useDeleteTrustCenterFileMutation() {
|
||||
{
|
||||
successMessage: "File deleted successfully",
|
||||
errorMessage: "Failed to delete file",
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export const useDeleteVendor = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
'This will permanently delete vendor "%s". This action cannot be undone.',
|
||||
"This will permanently delete vendor \"%s\". This action cannot be undone.",
|
||||
),
|
||||
vendor.name,
|
||||
),
|
||||
@@ -218,6 +218,6 @@ export function useVendors(organizationId: string) {
|
||||
{ fetchPolicy: "network-only" },
|
||||
);
|
||||
return useMemo(() => {
|
||||
return data.organization?.vendors?.edges.map((edge) => edge.node) ?? [];
|
||||
return data.organization?.vendors?.edges.map(edge => edge.node) ?? [];
|
||||
}, [data]);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import { useQuery, type UseQueryOptions } from "@tanstack/react-query";
|
||||
*/
|
||||
export function useFetchQuery<T>(
|
||||
url: string,
|
||||
options?: Omit<UseQueryOptions<T>, "queryKey" | "queryFn">
|
||||
options?: Omit<UseQueryOptions<T>, "queryKey" | "queryFn">,
|
||||
) {
|
||||
return useQuery<T>({
|
||||
...options,
|
||||
queryKey: [url],
|
||||
queryFn: () => fetch(url).then((res) => res.json()),
|
||||
queryFn: () => fetch(url).then(res => res.json()),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useMutateField<Input extends Record<string, unknown>>(
|
||||
const [mutate, isUpdating] = useMutation(mutation);
|
||||
|
||||
return {
|
||||
update<T extends keyof Input>(id: string, fieldName: T, value: Input[T]) {
|
||||
update: <T extends keyof Input>(id: string, fieldName: T, value: Input[T]) => {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export function useMutationWithToasts<T extends MutationParameters>(
|
||||
baseOptions?: {
|
||||
successMessage?: string | ((response: T["response"]) => string);
|
||||
errorMessage?: string;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const [mutate, isLoading] = useMutation<T>(query);
|
||||
const { toast } = useToast();
|
||||
@@ -24,7 +24,7 @@ export function useMutationWithToasts<T extends MutationParameters>(
|
||||
onSuccess?: () => void;
|
||||
successMessage?: string | ((response: T["response"]) => string);
|
||||
errorMessage?: string;
|
||||
}
|
||||
},
|
||||
) => {
|
||||
const options = { ...baseOptions, ...queryOptions };
|
||||
return new Promise<void>((resolve, reject) =>
|
||||
@@ -39,7 +39,7 @@ export function useMutationWithToasts<T extends MutationParameters>(
|
||||
description: formatError(errorTitle, error as GraphQLError[]),
|
||||
variant: "error",
|
||||
});
|
||||
reject(error);
|
||||
reject(new Error(errorTitle));
|
||||
return;
|
||||
}
|
||||
const successMessage = typeof options.successMessage === "function"
|
||||
@@ -49,8 +49,8 @@ export function useMutationWithToasts<T extends MutationParameters>(
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description:
|
||||
successMessage ??
|
||||
__("Operation completed successfully"),
|
||||
successMessage
|
||||
?? __("Operation completed successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
options.onSuccess?.();
|
||||
@@ -65,10 +65,10 @@ export function useMutationWithToasts<T extends MutationParameters>(
|
||||
});
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
[mutate, toast, __, baseOptions]
|
||||
[mutate, toast, __, baseOptions],
|
||||
);
|
||||
|
||||
return [mutateWithToast, isLoading] as const;
|
||||
|
||||
@@ -9,13 +9,13 @@ export function useStateWithSchema<T extends ZodTypeAny>(
|
||||
const [value, errors] = useMemo((): [z.infer<T>, Record<string, string>] => {
|
||||
try {
|
||||
schema.parse(state);
|
||||
return [schema.parse(state), {}];
|
||||
return [schema.parse(state) as z.TypeOf<T>, {}];
|
||||
} catch (error) {
|
||||
if (error instanceof ZodError) {
|
||||
return [
|
||||
state,
|
||||
Object.fromEntries(
|
||||
error.issues.map((issue) => [
|
||||
error.issues.map(issue => [
|
||||
issue.path.join("."),
|
||||
issue.message,
|
||||
]) ?? [],
|
||||
@@ -32,7 +32,7 @@ export function useStateWithSchema<T extends ZodTypeAny>(
|
||||
errors,
|
||||
update: useCallback(
|
||||
<TKey extends keyof z.infer<T>>(key: TKey, value: z.infer<T>[TKey]) => {
|
||||
setState((prevState) => ({ ...prevState, [key]: value }));
|
||||
setState(prevState => ({ ...prevState, [key]: value }));
|
||||
},
|
||||
[],
|
||||
),
|
||||
|
||||
@@ -7,7 +7,7 @@ export function useVendorSearch() {
|
||||
const [query, setQuery] = useState("");
|
||||
const [vendors, setVendors] = useState<Vendor[]>([]);
|
||||
useEffect(() => {
|
||||
import("@probo/vendors").then((module) => {
|
||||
void import("@probo/vendors").then((module) => {
|
||||
const ms = new MiniSearch({
|
||||
fields: ["name"],
|
||||
storeFields: Object.keys(module.default[0]),
|
||||
@@ -16,7 +16,7 @@ export function useVendorSearch() {
|
||||
prefix: true,
|
||||
},
|
||||
});
|
||||
ms.addAll(module.default.map((v) => ({ ...v, id: v.name })));
|
||||
ms.addAll(module.default.map(v => ({ ...v, id: v.name })));
|
||||
// @ts-expect-error not enough types to handle this case
|
||||
searchRef.current = ms.search.bind(ms);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user