@recruitnepal/shared-packages 1.7.4 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/career-personality-test/components/CareerFitTestLanding.d.ts +10 -0
- package/dist/career-personality-test/components/CareerFitTestLanding.d.ts.map +1 -0
- package/dist/career-personality-test/components/CareerFitTestLanding.js +20 -0
- package/dist/career-personality-test/components/CareerTestDetailsForm.d.ts +28 -0
- package/dist/career-personality-test/components/CareerTestDetailsForm.d.ts.map +1 -0
- package/dist/career-personality-test/components/CareerTestDetailsForm.js +91 -0
- package/dist/career-personality-test/components/CareerTestResultsPage.d.ts +27 -0
- package/dist/career-personality-test/components/CareerTestResultsPage.d.ts.map +1 -0
- package/dist/career-personality-test/components/CareerTestResultsPage.js +121 -0
- package/dist/career-personality-test/components/CareerTestStart.d.ts +7 -0
- package/dist/career-personality-test/components/CareerTestStart.d.ts.map +1 -0
- package/dist/career-personality-test/components/CareerTestStart.js +87 -0
- package/dist/career-personality-test/constants/resultConstants.d.ts +29 -0
- package/dist/career-personality-test/constants/resultConstants.d.ts.map +1 -0
- package/dist/career-personality-test/constants/resultConstants.js +92 -0
- package/dist/career-personality-test/constants/storageKeys.d.ts +3 -0
- package/dist/career-personality-test/constants/storageKeys.d.ts.map +1 -0
- package/dist/career-personality-test/constants/storageKeys.js +2 -0
- package/dist/career-personality-test/data/overallBands.d.ts +13 -0
- package/dist/career-personality-test/data/overallBands.d.ts.map +1 -0
- package/dist/career-personality-test/data/overallBands.js +10 -0
- package/dist/career-personality-test/data/questions.d.ts +16 -0
- package/dist/career-personality-test/data/questions.d.ts.map +1 -0
- package/dist/career-personality-test/data/questions.js +51 -0
- package/dist/career-personality-test/data/traits.d.ts +7 -0
- package/dist/career-personality-test/data/traits.d.ts.map +1 -0
- package/dist/career-personality-test/data/traits.js +15 -0
- package/dist/career-personality-test/index.d.ts +20 -0
- package/dist/career-personality-test/index.d.ts.map +1 -0
- package/dist/career-personality-test/index.js +14 -0
- package/dist/career-personality-test/utils/scoring.d.ts +18 -0
- package/dist/career-personality-test/utils/scoring.d.ts.map +1 -0
- package/dist/career-personality-test/utils/scoring.js +69 -0
- package/dist/components/ui/Badge.d.ts +10 -0
- package/dist/components/ui/Badge.d.ts.map +1 -0
- package/dist/components/ui/Badge.js +20 -0
- package/dist/components/ui/Button.d.ts +12 -0
- package/dist/components/ui/Button.d.ts.map +1 -0
- package/dist/components/ui/Button.js +31 -0
- package/dist/components/ui/DesignationSelect.d.ts +2 -1
- package/dist/components/ui/DesignationSelect.d.ts.map +1 -1
- package/dist/components/ui/DesignationSelect.js +11 -16
- package/dist/components/ui/IndustrySelect.d.ts +3 -1
- package/dist/components/ui/IndustrySelect.d.ts.map +1 -1
- package/dist/components/ui/IndustrySelect.js +7 -8
- package/dist/components/ui/MultiSelectOptions.d.ts +4 -4
- package/dist/components/ui/MultiSelectOptions.d.ts.map +1 -1
- package/dist/components/ui/MultiSelectOptions.js +13 -24
- package/dist/hooks/useDebounce.d.ts +3 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -1
- package/dist/hooks/useDebounce.js +3 -0
- package/dist/hooks/useDesignations.d.ts +1 -9
- package/dist/hooks/useDesignations.d.ts.map +1 -1
- package/dist/hooks/useDesignations.js +59 -68
- package/dist/hooks/useIndustries.d.ts +4 -10
- package/dist/hooks/useIndustries.d.ts.map +1 -1
- package/dist/hooks/useIndustries.js +60 -69
- package/dist/hooks/useSkills.d.ts +1 -2
- package/dist/hooks/useSkills.d.ts.map +1 -1
- package/dist/hooks/useSkills.js +7 -7
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/utils/cn.d.ts +2 -1
- package/dist/utils/cn.d.ts.map +1 -1
- package/dist/utils/cn.js +4 -2
- package/package.json +21 -3
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ChevronsUpDown, Check } from 'lucide-react';
|
|
5
|
-
import { useDesignations } from '
|
|
6
|
-
import { cn } from '
|
|
7
|
-
import { useDebounce } from '
|
|
8
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
9
|
-
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from '
|
|
10
|
-
/** Matches ShadCN <SelectTrigger> so it looks like a normal input */
|
|
5
|
+
import { useDesignations } from '../../hooks/useDesignations';
|
|
6
|
+
import { cn } from '../../utils/cn';
|
|
7
|
+
import { useDebounce } from '../../hooks/useDebounce';
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
9
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from './command';
|
|
11
10
|
const selectTriggerClasses = 'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed cursor-pointer disabled:opacity-50';
|
|
12
11
|
const toString = (v) => String(v ?? '');
|
|
13
|
-
export default function DesignationSelect({ value, onChange, placeholder = 'Select a designation', disabled, className, valueType = 'title',
|
|
14
|
-
}) {
|
|
12
|
+
export default function DesignationSelect({ value, onChange, placeholder = 'Select a designation', disabled, className, valueType = 'title', token, }) {
|
|
15
13
|
const [open, setOpen] = React.useState(false);
|
|
16
14
|
const [searchQuery, setSearchQuery] = React.useState('');
|
|
17
15
|
const debouncedSearch = useDebounce(searchQuery, 300);
|
|
18
|
-
// Use backend search when there's a search query; infinite query for load-more on scroll
|
|
19
16
|
const { designations = [], designationsQuery, isLoading, } = useDesignations({
|
|
20
17
|
queryObject: debouncedSearch ? { search: debouncedSearch } : {},
|
|
21
18
|
limit: 50,
|
|
19
|
+
token,
|
|
22
20
|
});
|
|
23
21
|
const handleListScroll = React.useCallback((e) => {
|
|
24
22
|
if (!designationsQuery.hasNextPage ||
|
|
@@ -35,20 +33,17 @@ export default function DesignationSelect({ value, onChange, placeholder = 'Sele
|
|
|
35
33
|
]);
|
|
36
34
|
const options = React.useMemo(() => designations.map((d) => ({
|
|
37
35
|
id: String(d.id),
|
|
38
|
-
title: d.title
|
|
36
|
+
title: d.title ?? String(d.id),
|
|
39
37
|
})), [designations]);
|
|
40
|
-
// Find selected option based on valueType
|
|
41
38
|
const selectedOption = React.useMemo(() => {
|
|
42
39
|
if (!value)
|
|
43
40
|
return null;
|
|
44
41
|
if (valueType === 'id') {
|
|
45
42
|
return options.find((o) => toString(o.id) === toString(value));
|
|
46
43
|
}
|
|
47
|
-
|
|
48
|
-
return options.find((o) => o.title === value);
|
|
49
|
-
}
|
|
44
|
+
return options.find((o) => o.title === value);
|
|
50
45
|
}, [value, options, valueType]);
|
|
51
|
-
const selectedLabel = selectedOption?.title
|
|
46
|
+
const selectedLabel = selectedOption?.title ?? '';
|
|
52
47
|
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("div", { role: "combobox", "aria-expanded": open, "aria-disabled": disabled || isLoading, tabIndex: 0, onClick: () => !(disabled || isLoading) && setOpen((v) => !v), onKeyDown: (e) => {
|
|
53
48
|
if ((e.key === 'Enter' || e.key === ' ') && !(disabled || isLoading)) {
|
|
54
49
|
e.preventDefault();
|
|
@@ -67,7 +62,7 @@ export default function DesignationSelect({ value, onChange, placeholder = 'Sele
|
|
|
67
62
|
: value === o.title;
|
|
68
63
|
return (_jsxs(CommandItem, { value: o.id, onSelect: () => {
|
|
69
64
|
const newValue = valueType === 'id' ? o.id : o.title;
|
|
70
|
-
onChange(newValue);
|
|
65
|
+
onChange(newValue ?? '');
|
|
71
66
|
setOpen(false);
|
|
72
67
|
setSearchQuery('');
|
|
73
68
|
}, className: "cursor-pointer", children: [_jsx(Check, { className: cn('mr-2 h-4 w-4', isSelected ? 'opacity-100' : 'opacity-0') }), o.title] }, o.id));
|
|
@@ -5,6 +5,8 @@ export interface IndustrySelectProps {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
className?: string;
|
|
7
7
|
valueType?: 'id' | 'title';
|
|
8
|
+
/** Optional auth token for API (e.g. from app session) */
|
|
9
|
+
token?: string;
|
|
8
10
|
}
|
|
9
|
-
export default function IndustrySelect({ value, onChange, placeholder, disabled, className, valueType, }: IndustrySelectProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default function IndustrySelect({ value, onChange, placeholder, disabled, className, valueType, token, }: IndustrySelectProps): import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
//# sourceMappingURL=IndustrySelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndustrySelect.d.ts","sourceRoot":"","sources":["../../../src/components/ui/IndustrySelect.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IndustrySelect.d.ts","sourceRoot":"","sources":["../../../src/components/ui/IndustrySelect.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;IAC3B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,KAAK,EACL,QAAQ,EACR,WAAkC,EAClC,QAAQ,EACR,SAAS,EACT,SAAgB,EAChB,KAAK,GACN,EAAE,mBAAmB,2CA4JrB"}
|
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ChevronsUpDown, Check } from 'lucide-react';
|
|
5
|
-
import { useIndustries } from '
|
|
6
|
-
import { cn } from '
|
|
7
|
-
import { useDebounce } from '
|
|
8
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
9
|
-
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from '
|
|
5
|
+
import { useIndustries } from '../../hooks/useIndustries';
|
|
6
|
+
import { cn } from '../../utils/cn';
|
|
7
|
+
import { useDebounce } from '../../hooks/useDebounce';
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
|
|
9
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from './command';
|
|
10
10
|
/** Matches ShadCN <SelectTrigger> so it looks like a normal input */
|
|
11
11
|
const selectTriggerClasses = 'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed cursor-pointer disabled:opacity-50';
|
|
12
12
|
const toString = (v) => String(v ?? '');
|
|
13
|
-
export default function IndustrySelect({ value, onChange, placeholder = 'Select an industry', disabled, className, valueType = 'id',
|
|
14
|
-
}) {
|
|
13
|
+
export default function IndustrySelect({ value, onChange, placeholder = 'Select an industry', disabled, className, valueType = 'id', token, }) {
|
|
15
14
|
const [open, setOpen] = React.useState(false);
|
|
16
15
|
const [searchQuery, setSearchQuery] = React.useState('');
|
|
17
16
|
const debouncedSearch = useDebounce(searchQuery, 300);
|
|
18
|
-
// Use backend search when there's a search query; infinite query for load-more on scroll
|
|
19
17
|
const { industries = [], industriesQuery, isLoading, } = useIndustries({
|
|
20
18
|
queryObject: debouncedSearch ? { search: debouncedSearch } : {},
|
|
21
19
|
limit: 50,
|
|
20
|
+
token,
|
|
22
21
|
});
|
|
23
22
|
const handleListScroll = React.useCallback((e) => {
|
|
24
23
|
if (!industriesQuery.hasNextPage ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InfiniteData, UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { Skill } from '
|
|
3
|
-
type
|
|
2
|
+
import type { Skill } from '../../hooks/useSkills';
|
|
3
|
+
export type MultiSelectOptionsProps = {
|
|
4
4
|
value: string[];
|
|
5
5
|
onChange: (value: string[]) => void;
|
|
6
6
|
options: string[];
|
|
@@ -10,7 +10,7 @@ type Props = {
|
|
|
10
10
|
}>, Error>;
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
staticOnly?: boolean;
|
|
13
|
+
token?: string;
|
|
13
14
|
};
|
|
14
|
-
export declare function MultiSelectOptions({ value, onChange, options, query: externalQuery, disabled, staticOnly, }:
|
|
15
|
-
export {};
|
|
15
|
+
export declare function MultiSelectOptions({ value, onChange, options, query: externalQuery, disabled, staticOnly, token, }: MultiSelectOptionsProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
//# sourceMappingURL=MultiSelectOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectOptions.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MultiSelectOptions.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"MultiSelectOptions.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MultiSelectOptions.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,sBAAsB,CAC5B,YAAY,CAAC;QAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,EACxD,KAAK,CACN,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsCF,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,EAAE,aAAa,EACpB,QAAQ,EACR,UAAkB,EAClB,KAAK,GACN,EAAE,uBAAuB,2CAwJzB"}
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Popover, PopoverTrigger, PopoverContent, } from '
|
|
4
|
-
import { Command, CommandInput, CommandItem, CommandList, CommandGroup, CommandEmpty, } from '
|
|
5
|
-
import { Button } from '
|
|
6
|
-
import { Badge } from '
|
|
3
|
+
import { Popover, PopoverTrigger, PopoverContent, } from './popover';
|
|
4
|
+
import { Command, CommandInput, CommandItem, CommandList, CommandGroup, CommandEmpty, } from './command';
|
|
5
|
+
import { Button } from './Button';
|
|
6
|
+
import { Badge } from './Badge';
|
|
7
7
|
import { X } from 'lucide-react';
|
|
8
8
|
import { useEffect, useState, useMemo } from 'react';
|
|
9
9
|
import { useInView } from 'react-intersection-observer';
|
|
10
|
-
import { useSkills } from '
|
|
10
|
+
import { useSkills } from '../../hooks/useSkills';
|
|
11
|
+
import { useDebounce } from '../../hooks/useDebounce';
|
|
11
12
|
// Sub-component for badges
|
|
12
13
|
function SelectedBadges({ skills, removeSkill, }) {
|
|
13
14
|
return (_jsx("div", { className: "flex flex-wrap gap-1 w-full", children: skills.map((skill) => (_jsxs(Badge, { variant: "secondary", className: "\n flex items-center gap-1\n px-1.5 py-0.5\n rounded-lg\n bg-primary text-white\n text-[11px] leading-tight sm:text-xs\n max-w-full break-words\n ", children: [_jsx("span", { className: "inline-block max-w-[72vw] sm:max-w-full overflow-hidden text-ellipsis", children: skill }), _jsx(X, { className: "w-3 h-3 cursor-pointer shrink-0", onClick: (e) => removeSkill(skill, e) })] }, skill))) }));
|
|
14
15
|
}
|
|
15
|
-
export function MultiSelectOptions({ value, onChange, options, query: externalQuery, disabled, staticOnly = false, }) {
|
|
16
|
+
export function MultiSelectOptions({ value, onChange, options, query: externalQuery, disabled, staticOnly = false, token, }) {
|
|
16
17
|
const [open, setOpen] = useState(false);
|
|
17
18
|
const [search, setSearch] = useState('');
|
|
18
|
-
const
|
|
19
|
+
const debouncedSearch = useDebounce(search.trim(), 300);
|
|
19
20
|
const { ref, inView } = useInView();
|
|
20
|
-
// Debounce search input to reduce API calls
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const timer = setTimeout(() => {
|
|
23
|
-
setDebouncedSearch(search.trim());
|
|
24
|
-
}, 300); // 300ms debounce delay
|
|
25
|
-
return () => clearTimeout(timer);
|
|
26
|
-
}, [search]);
|
|
27
|
-
// Use internal query with search if no external query provided, or if search is active
|
|
28
|
-
// If external query is provided and no search, use it for backward compatibility
|
|
29
|
-
// Skip API query if staticOnly is true
|
|
30
21
|
const shouldUseInternalQuery = !staticOnly && (!externalQuery || debouncedSearch.length > 0);
|
|
31
22
|
const internalSkills = useSkills({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
batchSize: 1, // Single page per load for faster response
|
|
23
|
+
limit: debouncedSearch ? 50 : 20,
|
|
24
|
+
batchSize: 1,
|
|
35
25
|
queryObject: debouncedSearch ? { search: debouncedSearch } : {},
|
|
26
|
+
token,
|
|
36
27
|
});
|
|
37
28
|
// Use internal query when searching, otherwise use external query if provided
|
|
38
29
|
// If staticOnly, don't use any query
|
|
@@ -50,12 +41,10 @@ export function MultiSelectOptions({ value, onChange, options, query: externalQu
|
|
|
50
41
|
const apiOptions = query?.data?.pages.flatMap((page) => page.data?.map((s) => s.skill).filter(Boolean)) || [];
|
|
51
42
|
return Array.from(new Set([...options, ...apiOptions]));
|
|
52
43
|
}, [options, query?.data, staticOnly, debouncedSearch]);
|
|
53
|
-
// Reset search when popover closes
|
|
44
|
+
// Reset search when popover closes (debouncedSearch will follow)
|
|
54
45
|
useEffect(() => {
|
|
55
|
-
if (!open)
|
|
46
|
+
if (!open)
|
|
56
47
|
setSearch('');
|
|
57
|
-
setDebouncedSearch('');
|
|
58
|
-
}
|
|
59
48
|
}, [open]);
|
|
60
49
|
// Infinite scroll
|
|
61
50
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebounce.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAE,MAAY,GAAG,CAAC,CAS/D"}
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebounce.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAE,MAAY,GAAG,CAAC,CAS/D"}
|
|
@@ -15,15 +15,10 @@ export type UseDesignationsParams = {
|
|
|
15
15
|
limit?: number;
|
|
16
16
|
batchSize?: number;
|
|
17
17
|
queryObject?: Record<string, unknown>;
|
|
18
|
-
token?: string
|
|
18
|
+
token?: string;
|
|
19
19
|
};
|
|
20
20
|
export declare const useDesignations: ({ limit, batchSize, queryObject, token, }?: UseDesignationsParams) => {
|
|
21
21
|
designations: Designation[];
|
|
22
|
-
pagination: {
|
|
23
|
-
total: number;
|
|
24
|
-
page: number;
|
|
25
|
-
pages: number;
|
|
26
|
-
} | undefined;
|
|
27
22
|
designationsQuery: import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/query-core").InfiniteData<{
|
|
28
23
|
data: Designation[];
|
|
29
24
|
nextPage: number | null;
|
|
@@ -44,8 +39,5 @@ export declare const useDesignations: ({ limit, batchSize, queryObject, token, }
|
|
|
44
39
|
data: DesignationPayload;
|
|
45
40
|
}, unknown>;
|
|
46
41
|
deleteDesignation: import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
|
|
47
|
-
isCreating: boolean;
|
|
48
|
-
isUpdating: boolean;
|
|
49
|
-
isDeleting: boolean;
|
|
50
42
|
};
|
|
51
43
|
//# sourceMappingURL=useDesignations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDesignations.d.ts","sourceRoot":"","sources":["../../src/hooks/useDesignations.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAeF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useDesignations.d.ts","sourceRoot":"","sources":["../../src/hooks/useDesignations.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAeF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,4CAK7B,qBAA0B;;;;;;;;;;;;;;;;;;YAkFgB,MAAM;cAAQ,kBAAkB;;;CA+B5E,CAAC"}
|
|
@@ -11,31 +11,27 @@ export const useDesignations = ({ limit = 50, batchSize = 1, queryObject = {}, t
|
|
|
11
11
|
queryFn: async ({ pageParam = 1 }) => {
|
|
12
12
|
const pagesToFetch = Array.from({ length: batchSize }, (_, i) => pageParam + i);
|
|
13
13
|
const results = await Promise.all(pagesToFetch.map(async (page) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
if (q.search) {
|
|
20
|
-
q.query = q.search;
|
|
21
|
-
delete q.search;
|
|
14
|
+
const params = { ...queryObject, page, limit };
|
|
15
|
+
if (params.search) {
|
|
16
|
+
params.query = params.search;
|
|
17
|
+
delete params.search;
|
|
22
18
|
}
|
|
23
|
-
const searchQuery = generateSearchQuery(
|
|
19
|
+
const searchQuery = generateSearchQuery(params);
|
|
24
20
|
const res = await apiRequest({
|
|
25
21
|
endpoint: `/designations?${searchQuery}`,
|
|
26
22
|
method: 'GET',
|
|
27
|
-
token
|
|
23
|
+
token,
|
|
28
24
|
});
|
|
29
25
|
if (!res.success) {
|
|
30
|
-
const
|
|
31
|
-
throw new Error(
|
|
26
|
+
const errs = res.errors;
|
|
27
|
+
throw new Error(errs?.error?.[0] ?? errs?.general?.[0] ?? 'Failed to fetch designations');
|
|
32
28
|
}
|
|
33
29
|
const payload = res.data;
|
|
34
|
-
const
|
|
35
|
-
const pages =
|
|
36
|
-
const nextPage =
|
|
30
|
+
const p = payload?.pagination;
|
|
31
|
+
const pages = p?.pages ?? 1;
|
|
32
|
+
const nextPage = p?.nextPage ?? (p && page < pages ? page + 1 : null);
|
|
37
33
|
return {
|
|
38
|
-
data: payload
|
|
34
|
+
data: payload?.data ?? [],
|
|
39
35
|
page,
|
|
40
36
|
pages,
|
|
41
37
|
nextPage,
|
|
@@ -52,66 +48,61 @@ export const useDesignations = ({ limit = 50, batchSize = 1, queryObject = {}, t
|
|
|
52
48
|
},
|
|
53
49
|
getNextPageParam: (lastPage) => lastPage.nextPage ?? undefined,
|
|
54
50
|
});
|
|
55
|
-
const createDesignation = useMutation({
|
|
56
|
-
mutationFn: async (data) => {
|
|
57
|
-
const res = await apiRequest({
|
|
58
|
-
endpoint: '/designations',
|
|
59
|
-
method: 'POST',
|
|
60
|
-
data,
|
|
61
|
-
token: token ?? undefined,
|
|
62
|
-
});
|
|
63
|
-
if (!res.success)
|
|
64
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to create designation'));
|
|
65
|
-
return res.data;
|
|
66
|
-
},
|
|
67
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
68
|
-
});
|
|
69
|
-
const updateDesignation = useMutation({
|
|
70
|
-
mutationFn: async ({ id, data }) => {
|
|
71
|
-
const res = await apiRequest({
|
|
72
|
-
endpoint: `/designations/${id}`,
|
|
73
|
-
method: 'PUT',
|
|
74
|
-
data,
|
|
75
|
-
token: token ?? undefined,
|
|
76
|
-
});
|
|
77
|
-
if (!res.success)
|
|
78
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to update designation'));
|
|
79
|
-
return res.data;
|
|
80
|
-
},
|
|
81
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
82
|
-
});
|
|
83
|
-
const deleteDesignation = useMutation({
|
|
84
|
-
mutationFn: async (id) => {
|
|
85
|
-
const res = await apiRequest({
|
|
86
|
-
endpoint: `/designations/${id}`,
|
|
87
|
-
method: 'DELETE',
|
|
88
|
-
token: token ?? undefined,
|
|
89
|
-
});
|
|
90
|
-
if (!res.success)
|
|
91
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to delete designation'));
|
|
92
|
-
return res.data;
|
|
93
|
-
},
|
|
94
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
95
|
-
});
|
|
96
51
|
const designations = designationsQuery.data?.pages?.flatMap((p) => p.data) ?? [];
|
|
97
|
-
const lastPage = designationsQuery.data?.pages?.slice(-1)?.[0];
|
|
98
|
-
const pagination = lastPage
|
|
99
|
-
? { total: designations.length, page: 1, pages: lastPage.totalPages ?? 1 }
|
|
100
|
-
: undefined;
|
|
101
52
|
return {
|
|
102
53
|
designations,
|
|
103
|
-
pagination,
|
|
104
54
|
designationsQuery,
|
|
105
55
|
isLoading: designationsQuery.isLoading,
|
|
106
56
|
isFetching: designationsQuery.isFetching,
|
|
107
57
|
isError: designationsQuery.isError,
|
|
108
58
|
error: designationsQuery.error,
|
|
109
59
|
refetch: designationsQuery.refetch,
|
|
110
|
-
createDesignation
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
60
|
+
createDesignation: useMutation({
|
|
61
|
+
mutationFn: async (data) => {
|
|
62
|
+
const res = await apiRequest({
|
|
63
|
+
endpoint: '/designations',
|
|
64
|
+
method: 'POST',
|
|
65
|
+
data,
|
|
66
|
+
token,
|
|
67
|
+
});
|
|
68
|
+
if (!res.success) {
|
|
69
|
+
const errs = res.errors;
|
|
70
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to create designation');
|
|
71
|
+
}
|
|
72
|
+
return res.data;
|
|
73
|
+
},
|
|
74
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
75
|
+
}),
|
|
76
|
+
updateDesignation: useMutation({
|
|
77
|
+
mutationFn: async ({ id, data }) => {
|
|
78
|
+
const res = await apiRequest({
|
|
79
|
+
endpoint: `/designations/${id}`,
|
|
80
|
+
method: 'PUT',
|
|
81
|
+
data,
|
|
82
|
+
token,
|
|
83
|
+
});
|
|
84
|
+
if (!res.success) {
|
|
85
|
+
const errs = res.errors;
|
|
86
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to update designation');
|
|
87
|
+
}
|
|
88
|
+
return res.data;
|
|
89
|
+
},
|
|
90
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
91
|
+
}),
|
|
92
|
+
deleteDesignation: useMutation({
|
|
93
|
+
mutationFn: async (id) => {
|
|
94
|
+
const res = await apiRequest({
|
|
95
|
+
endpoint: `/designations/${id}`,
|
|
96
|
+
method: 'DELETE',
|
|
97
|
+
token,
|
|
98
|
+
});
|
|
99
|
+
if (!res.success) {
|
|
100
|
+
const errs = res.errors;
|
|
101
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to delete designation');
|
|
102
|
+
}
|
|
103
|
+
return res.data;
|
|
104
|
+
},
|
|
105
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['designations'] }),
|
|
106
|
+
}),
|
|
116
107
|
};
|
|
117
108
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type Industry = {
|
|
2
2
|
id: string;
|
|
3
3
|
title?: string;
|
|
4
|
+
name?: string;
|
|
4
5
|
description?: string;
|
|
5
6
|
category?: string;
|
|
6
7
|
status?: string;
|
|
@@ -15,15 +16,11 @@ export type UseIndustriesParams = {
|
|
|
15
16
|
limit?: number;
|
|
16
17
|
batchSize?: number;
|
|
17
18
|
queryObject?: Record<string, unknown>;
|
|
18
|
-
token
|
|
19
|
+
/** Optional auth token (e.g. from app session) */
|
|
20
|
+
token?: string;
|
|
19
21
|
};
|
|
20
|
-
export declare const useIndustries: (
|
|
22
|
+
export declare const useIndustries: ({ limit, batchSize, queryObject, token, }?: UseIndustriesParams) => {
|
|
21
23
|
industries: Industry[];
|
|
22
|
-
pagination: {
|
|
23
|
-
total: number;
|
|
24
|
-
page: number;
|
|
25
|
-
pages: number;
|
|
26
|
-
} | undefined;
|
|
27
24
|
industriesQuery: import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/query-core").InfiniteData<{
|
|
28
25
|
data: Industry[];
|
|
29
26
|
nextPage: number | null;
|
|
@@ -44,8 +41,5 @@ export declare const useIndustries: (params?: UseIndustriesParams) => {
|
|
|
44
41
|
data: IndustryPayload;
|
|
45
42
|
}, unknown>;
|
|
46
43
|
deleteIndustry: import("@tanstack/react-query").UseMutationResult<unknown, Error, string, unknown>;
|
|
47
|
-
isCreating: boolean;
|
|
48
|
-
isUpdating: boolean;
|
|
49
|
-
isDeleting: boolean;
|
|
50
44
|
};
|
|
51
45
|
//# sourceMappingURL=useIndustries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIndustries.d.ts","sourceRoot":"","sources":["../../src/hooks/useIndustries.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAeF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useIndustries.d.ts","sourceRoot":"","sources":["../../src/hooks/useIndustries.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAeF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,4CAK3B,mBAAwB;;;;;;;;;;;;;;;;;;YA+EkB,MAAM;cAAQ,eAAe;;;CA+BzE,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { apiRequest } from '../utils/api-request';
|
|
4
4
|
import { generateSearchQuery } from '../utils/generateSearchQuery';
|
|
5
|
-
export const useIndustries = (
|
|
6
|
-
const { limit = 50, batchSize = 1, queryObject = {}, token } = params;
|
|
5
|
+
export const useIndustries = ({ limit = 50, batchSize = 1, queryObject = {}, token, } = {}) => {
|
|
7
6
|
const queryClient = useQueryClient();
|
|
8
7
|
const industriesQuery = useInfiniteQuery({
|
|
9
8
|
queryKey: ['industries', limit, batchSize, queryObject],
|
|
@@ -12,31 +11,27 @@ export const useIndustries = (params = {}) => {
|
|
|
12
11
|
queryFn: async ({ pageParam = 1 }) => {
|
|
13
12
|
const pagesToFetch = Array.from({ length: batchSize }, (_, i) => pageParam + i);
|
|
14
13
|
const results = await Promise.all(pagesToFetch.map(async (page) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
if (q.search) {
|
|
21
|
-
q.query = q.search;
|
|
22
|
-
delete q.search;
|
|
14
|
+
const params = { ...queryObject, page, limit };
|
|
15
|
+
if (params.search) {
|
|
16
|
+
params.query = params.search;
|
|
17
|
+
delete params.search;
|
|
23
18
|
}
|
|
24
|
-
const searchQuery = generateSearchQuery(
|
|
19
|
+
const searchQuery = generateSearchQuery(params);
|
|
25
20
|
const res = await apiRequest({
|
|
26
21
|
endpoint: `/industries?${searchQuery}`,
|
|
27
22
|
method: 'GET',
|
|
28
|
-
token
|
|
23
|
+
token,
|
|
29
24
|
});
|
|
30
25
|
if (!res.success) {
|
|
31
|
-
const
|
|
32
|
-
throw new Error(
|
|
26
|
+
const errs = res.errors;
|
|
27
|
+
throw new Error(errs?.error?.[0] ?? errs?.general?.[0] ?? 'Failed to fetch industries');
|
|
33
28
|
}
|
|
34
29
|
const payload = res.data;
|
|
35
|
-
const
|
|
36
|
-
const pages =
|
|
37
|
-
const nextPage =
|
|
30
|
+
const p = payload?.pagination;
|
|
31
|
+
const pages = p?.pages ?? 1;
|
|
32
|
+
const nextPage = p?.nextPage ?? (p && page < pages ? page + 1 : null);
|
|
38
33
|
return {
|
|
39
|
-
data: payload
|
|
34
|
+
data: payload?.data ?? [],
|
|
40
35
|
page,
|
|
41
36
|
pages,
|
|
42
37
|
nextPage,
|
|
@@ -53,66 +48,62 @@ export const useIndustries = (params = {}) => {
|
|
|
53
48
|
},
|
|
54
49
|
getNextPageParam: (lastPage) => lastPage.nextPage ?? undefined,
|
|
55
50
|
});
|
|
56
|
-
const createIndustry = useMutation({
|
|
57
|
-
mutationFn: async (data) => {
|
|
58
|
-
const res = await apiRequest({
|
|
59
|
-
endpoint: '/industries',
|
|
60
|
-
method: 'POST',
|
|
61
|
-
data,
|
|
62
|
-
token: token ?? undefined,
|
|
63
|
-
});
|
|
64
|
-
if (!res.success)
|
|
65
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to create industry'));
|
|
66
|
-
return res.data;
|
|
67
|
-
},
|
|
68
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
69
|
-
});
|
|
70
|
-
const updateIndustry = useMutation({
|
|
71
|
-
mutationFn: async ({ id, data }) => {
|
|
72
|
-
const res = await apiRequest({
|
|
73
|
-
endpoint: `/industries/${id}`,
|
|
74
|
-
method: 'PUT',
|
|
75
|
-
data,
|
|
76
|
-
token: token ?? undefined,
|
|
77
|
-
});
|
|
78
|
-
if (!res.success)
|
|
79
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to update industry'));
|
|
80
|
-
return res.data;
|
|
81
|
-
},
|
|
82
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
83
|
-
});
|
|
84
|
-
const deleteIndustry = useMutation({
|
|
85
|
-
mutationFn: async (id) => {
|
|
86
|
-
const res = await apiRequest({
|
|
87
|
-
endpoint: `/industries/${id}`,
|
|
88
|
-
method: 'DELETE',
|
|
89
|
-
token: token ?? undefined,
|
|
90
|
-
});
|
|
91
|
-
if (!res.success)
|
|
92
|
-
throw new Error(String((res.errors?.general?.[0]) || 'Failed to delete industry'));
|
|
93
|
-
return res.data;
|
|
94
|
-
},
|
|
95
|
-
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
96
|
-
});
|
|
97
51
|
const industries = industriesQuery.data?.pages?.flatMap((p) => p.data) ?? [];
|
|
98
52
|
const lastPage = industriesQuery.data?.pages?.slice(-1)?.[0];
|
|
99
|
-
const pagination = lastPage
|
|
100
|
-
? { total: industries.length, page: 1, pages: lastPage.totalPages ?? 1 }
|
|
101
|
-
: undefined;
|
|
102
53
|
return {
|
|
103
54
|
industries,
|
|
104
|
-
pagination,
|
|
105
55
|
industriesQuery,
|
|
106
56
|
isLoading: industriesQuery.isLoading,
|
|
107
57
|
isFetching: industriesQuery.isFetching,
|
|
108
58
|
isError: industriesQuery.isError,
|
|
109
59
|
error: industriesQuery.error,
|
|
110
60
|
refetch: industriesQuery.refetch,
|
|
111
|
-
createIndustry
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
61
|
+
createIndustry: useMutation({
|
|
62
|
+
mutationFn: async (data) => {
|
|
63
|
+
const res = await apiRequest({
|
|
64
|
+
endpoint: '/industries',
|
|
65
|
+
method: 'POST',
|
|
66
|
+
data,
|
|
67
|
+
token,
|
|
68
|
+
});
|
|
69
|
+
if (!res.success) {
|
|
70
|
+
const errs = res.errors;
|
|
71
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to create industry');
|
|
72
|
+
}
|
|
73
|
+
return res.data;
|
|
74
|
+
},
|
|
75
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
76
|
+
}),
|
|
77
|
+
updateIndustry: useMutation({
|
|
78
|
+
mutationFn: async ({ id, data }) => {
|
|
79
|
+
const res = await apiRequest({
|
|
80
|
+
endpoint: `/industries/${id}`,
|
|
81
|
+
method: 'PUT',
|
|
82
|
+
data,
|
|
83
|
+
token,
|
|
84
|
+
});
|
|
85
|
+
if (!res.success) {
|
|
86
|
+
const errs = res.errors;
|
|
87
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to update industry');
|
|
88
|
+
}
|
|
89
|
+
return res.data;
|
|
90
|
+
},
|
|
91
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
92
|
+
}),
|
|
93
|
+
deleteIndustry: useMutation({
|
|
94
|
+
mutationFn: async (id) => {
|
|
95
|
+
const res = await apiRequest({
|
|
96
|
+
endpoint: `/industries/${id}`,
|
|
97
|
+
method: 'DELETE',
|
|
98
|
+
token,
|
|
99
|
+
});
|
|
100
|
+
if (!res.success) {
|
|
101
|
+
const errs = res.errors;
|
|
102
|
+
throw new Error(errs?.error?.[0] ?? 'Failed to delete industry');
|
|
103
|
+
}
|
|
104
|
+
return res.data;
|
|
105
|
+
},
|
|
106
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['industries'] }),
|
|
107
|
+
}),
|
|
117
108
|
};
|
|
118
109
|
};
|
|
@@ -6,8 +6,7 @@ export type UseSkillsParams = {
|
|
|
6
6
|
limit?: number;
|
|
7
7
|
batchSize?: number;
|
|
8
8
|
queryObject?: Record<string, unknown>;
|
|
9
|
-
|
|
10
|
-
token?: string | null;
|
|
9
|
+
token?: string;
|
|
11
10
|
};
|
|
12
11
|
export declare const useSkills: ({ limit, batchSize, queryObject, token, }?: UseSkillsParams) => {
|
|
13
12
|
skillsQuery: import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/query-core").InfiniteData<{
|