From 4e6406c6b2ac9beca897ea97b02888012731b8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=EC=A7=80?= Date: Sun, 7 Apr 2024 14:54:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat=20::=20=EB=A9=94=EC=9D=B8=20=EB=B0=B0?= =?UTF-8?q?=EB=84=88=20api=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pnp.cjs | 348 ++++++++++++++++-------------------- .pnp.loader.mjs | 81 +++++---- src/apis/banners/index.ts | 12 ++ src/apis/banners/type.ts | 17 ++ src/apis/bookmarks/index.ts | 2 +- src/components/Carousel.tsx | 103 ++++++----- 6 files changed, 278 insertions(+), 285 deletions(-) create mode 100644 src/apis/banners/index.ts create mode 100644 src/apis/banners/type.ts diff --git a/.pnp.cjs b/.pnp.cjs index e30405d..ea9cf95 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -18211,7 +18211,6 @@ function reportRequiredFilesToWatchMode(files) { } function applyPatch(pnpapi, opts) { - const defaultCache = {}; let enableNativeHooks = true; process.versions.pnp = String(pnpapi.VERSIONS.std); const moduleExports = require$$0__default.default; @@ -18231,62 +18230,13 @@ function applyPatch(pnpapi, opts) { } const originalModuleLoad = require$$0.Module._load; require$$0.Module._load = function(request, parent, isMain) { - if (!enableNativeHooks) - return originalModuleLoad.call(require$$0.Module, request, parent, isMain); - if (isBuiltinModule(request)) { - try { - enableNativeHooks = false; - return originalModuleLoad.call(require$$0.Module, request, parent, isMain); - } finally { - enableNativeHooks = true; - } - } - const parentApiPath = opts.manager.getApiPathFromParent(parent); - const parentApi = parentApiPath !== null ? opts.manager.getApiEntry(parentApiPath, true).instance : null; - if (parentApi === null) - return originalModuleLoad(request, parent, isMain); - if (request === `pnpapi`) - return parentApi; - const modulePath = require$$0.Module._resolveFilename(request, parent, isMain); - const isOwnedByRuntime = parentApi !== null ? parentApi.findPackageLocator(modulePath) !== null : false; - const moduleApiPath = isOwnedByRuntime ? parentApiPath : opts.manager.findApiPathFor(npath.dirname(modulePath)); - const entry = moduleApiPath !== null ? opts.manager.getApiEntry(moduleApiPath) : { instance: null, cache: defaultCache }; - const cacheEntry = entry.cache[modulePath]; - if (cacheEntry) { - if (cacheEntry.loaded === false && cacheEntry.isLoading !== true) { - try { - cacheEntry.isLoading = true; - if (isMain) { - process.mainModule = cacheEntry; - cacheEntry.id = `.`; - } - cacheEntry.load(modulePath); - } finally { - cacheEntry.isLoading = false; - } + if (request === `pnpapi`) { + const parentApiPath = opts.manager.getApiPathFromParent(parent); + if (parentApiPath) { + return opts.manager.getApiEntry(parentApiPath, true).instance; } - return cacheEntry.exports; - } - const module = new require$$0.Module(modulePath, parent != null ? parent : void 0); - module.pnpApiPath = moduleApiPath; - reportRequiredFilesToWatchMode([modulePath]); - entry.cache[modulePath] = module; - if (isMain) { - process.mainModule = module; - module.id = `.`; } - let hasThrown = true; - try { - module.isLoading = true; - module.load(modulePath); - hasThrown = false; - } finally { - module.isLoading = false; - if (hasThrown) { - delete require$$0.Module._cache[modulePath]; - } - } - return module.exports; + return originalModuleLoad.call(require$$0.Module, request, parent, isMain); }; function getIssuerSpecsFromPaths(paths) { return paths.map((path) => ({ @@ -18354,7 +18304,7 @@ function applyPatch(pnpapi, opts) { const parentDirectory = (parent == null ? void 0 : parent.filename) != null ? npath.dirname(parent.filename) : null; const absoluteRequest = npath.isAbsolute(request) ? request : parentDirectory !== null ? npath.resolve(parentDirectory, request) : null; if (absoluteRequest !== null) { - const apiPath = parentDirectory === npath.dirname(absoluteRequest) && (parent == null ? void 0 : parent.pnpApiPath) ? parent.pnpApiPath : opts.manager.findApiPathFor(absoluteRequest); + const apiPath = parent && parentDirectory === npath.dirname(absoluteRequest) ? opts.manager.getApiPathFromParent(parent) : opts.manager.findApiPathFor(absoluteRequest); if (apiPath !== null) { issuerSpecs.unshift({ apiPath, @@ -18513,118 +18463,6 @@ function hydrateRuntimeState(data, { basePath }) { }; } -/** - * @param {object} exports - * @param {Set} keys - */ -function loop(exports, keys) { - if (typeof exports === 'string') { - return exports; - } - - if (exports) { - let idx, tmp; - if (Array.isArray(exports)) { - for (idx=0; idx < exports.length; idx++) { - if (tmp = loop(exports[idx], keys)) return tmp; - } - } else { - for (idx in exports) { - if (keys.has(idx)) { - return loop(exports[idx], keys); - } - } - } - } -} - -/** - * @param {string} name The package name - * @param {string} entry The target entry, eg "." - * @param {number} [condition] Unmatched condition? - */ -function bail(name, entry, condition) { - throw new Error( - condition - ? `No known conditions for "${entry}" entry in "${name}" package` - : `Missing "${entry}" export in "${name}" package` - ); -} - -/** - * @param {string} name the package name - * @param {string} entry the target path/import - */ -function toName(name, entry) { - return entry === name ? '.' - : entry[0] === '.' ? entry - : entry.replace(new RegExp('^' + name + '\/'), './'); -} - -/** - * @param {object} pkg package.json contents - * @param {string} [entry] entry name or import path - * @param {object} [options] - * @param {boolean} [options.browser] - * @param {boolean} [options.require] - * @param {string[]} [options.conditions] - * @param {boolean} [options.unsafe] - */ -function resolve(pkg, entry='.', options={}) { - let { name, exports } = pkg; - - if (exports) { - let { browser, require, unsafe, conditions=[] } = options; - - let target = toName(name, entry); - if (target[0] !== '.') target = './' + target; - - if (typeof exports === 'string') { - return target === '.' ? exports : bail(name, target); - } - - let allows = new Set(['default', ...conditions]); - unsafe || allows.add(require ? 'require' : 'import'); - unsafe || allows.add(browser ? 'browser' : 'node'); - - let key, tmp, isSingle=false; - - for (key in exports) { - isSingle = key[0] !== '.'; - break; - } - - if (isSingle) { - return target === '.' - ? loop(exports, allows) || bail(name, target, 1) - : bail(name, target); - } - - if (tmp = exports[target]) { - return loop(tmp, allows) || bail(name, target, 1); - } - - for (key in exports) { - tmp = key[key.length - 1]; - if (tmp === '/' && target.startsWith(key)) { - return (tmp = loop(exports[key], allows)) - ? (tmp + target.substring(key.length)) - : bail(name, target, 1); - } - if (tmp === '*' && target.startsWith(key.slice(0, -1))) { - // do not trigger if no *content* to inject - if (target.substring(key.length - 1).length > 0) { - return (tmp = loop(exports[key], allows)) - ? tmp.replace('*', target.substring(key.length - 1)) - : bail(name, target, 1); - } - } - } - - return bail(name, target); - } -} - const ArrayIsArray = Array.isArray; const JSONStringify = JSON.stringify; const ObjectGetOwnPropertyNames = Object.getOwnPropertyNames; @@ -18685,6 +18523,15 @@ const ERR_INVALID_PACKAGE_CONFIG = createErrorType( }, Error ); +const ERR_PACKAGE_PATH_NOT_EXPORTED = createErrorType( + "ERR_PACKAGE_PATH_NOT_EXPORTED", + (pkgPath, subpath, base = void 0) => { + if (subpath === ".") + return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`; + return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`; + }, + Error +); function filterOwnProperties(source, keys) { const filtered = /* @__PURE__ */ Object.create(null); @@ -19004,12 +18851,121 @@ function patternKeyCompare(a, b) { return 1; return 0; } -function packageImportsResolve({ - name, +function isConditionalExportsMainSugar(exports, packageJSONUrl, base) { + if (typeof exports === "string" || ArrayIsArray(exports)) + return true; + if (typeof exports !== "object" || exports === null) + return false; + const keys = ObjectGetOwnPropertyNames(exports); + let isConditionalSugar = false; + let i = 0; + for (let j = 0; j < keys.length; j++) { + const key = keys[j]; + const curIsConditionalSugar = key === "" || key[0] !== "."; + if (i++ === 0) { + isConditionalSugar = curIsConditionalSugar; + } else if (isConditionalSugar !== curIsConditionalSugar) { + throw new ERR_INVALID_PACKAGE_CONFIG( + url.fileURLToPath(packageJSONUrl), + base, + `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.` + ); + } + } + return isConditionalSugar; +} +function throwExportsNotFound(subpath, packageJSONUrl, base) { + throw new ERR_PACKAGE_PATH_NOT_EXPORTED( + url.fileURLToPath(new URL(".", packageJSONUrl)), + subpath, + base && url.fileURLToPath(base) + ); +} +const emittedPackageWarnings = /* @__PURE__ */ new Set(); +function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) { + const pjsonPath = url.fileURLToPath(pjsonUrl); + if (emittedPackageWarnings.has(pjsonPath + "|" + match)) + return; + emittedPackageWarnings.add(pjsonPath + "|" + match); + process.emitWarning( + `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${url.fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, + "DeprecationWarning", + "DEP0155" + ); +} +function packageExportsResolve({ + packageJSONUrl, + packageSubpath, + exports, base, - conditions, - readFileSyncFn + conditions }) { + if (isConditionalExportsMainSugar(exports, packageJSONUrl, base)) + exports = { ".": exports }; + if (ObjectPrototypeHasOwnProperty(exports, packageSubpath) && !StringPrototypeIncludes(packageSubpath, "*") && !StringPrototypeEndsWith(packageSubpath, "/")) { + const target = exports[packageSubpath]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + target, + "", + packageSubpath, + base, + false, + false, + conditions + ); + if (resolveResult == null) { + throwExportsNotFound(packageSubpath, packageJSONUrl, base); + } + return resolveResult; + } + let bestMatch = ""; + let bestMatchSubpath; + const keys = ObjectGetOwnPropertyNames(exports); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + const patternIndex = StringPrototypeIndexOf(key, "*"); + if (patternIndex !== -1 && StringPrototypeStartsWith( + packageSubpath, + StringPrototypeSlice(key, 0, patternIndex) + )) { + if (StringPrototypeEndsWith(packageSubpath, "/")) + emitTrailingSlashPatternDeprecation( + packageSubpath, + packageJSONUrl, + base + ); + const patternTrailer = StringPrototypeSlice(key, patternIndex + 1); + if (packageSubpath.length >= key.length && StringPrototypeEndsWith(packageSubpath, patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && StringPrototypeLastIndexOf(key, "*") === patternIndex) { + bestMatch = key; + bestMatchSubpath = StringPrototypeSlice( + packageSubpath, + patternIndex, + packageSubpath.length - patternTrailer.length + ); + } + } + } + if (bestMatch) { + const target = exports[bestMatch]; + const resolveResult = resolvePackageTarget( + packageJSONUrl, + target, + bestMatchSubpath, + bestMatch, + base, + true, + false, + conditions + ); + if (resolveResult == null) { + throwExportsNotFound(packageSubpath, packageJSONUrl, base); + } + return resolveResult; + } + throwExportsNotFound(packageSubpath, packageJSONUrl, base); +} +function packageImportsResolve({ name, base, conditions, readFileSyncFn }) { if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { const reason = "is not a valid internal imports specifier name"; throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, url.fileURLToPath(base)); @@ -19477,12 +19433,11 @@ function makeApi(runtimeState, opts) { return false; } const defaultExportsConditions = /* @__PURE__ */ new Set([ - `default`, `node`, `require`, ...getOptionValue(`--conditions`) ]); - function applyNodeExportsResolution(unqualifiedPath, conditions = defaultExportsConditions) { + function applyNodeExportsResolution(unqualifiedPath, conditions = defaultExportsConditions, issuer) { const locator = findPackageLocator(ppath.join(unqualifiedPath, `internal.js`), { resolveIgnored: true, includeDiscardFromLookup: true @@ -19498,6 +19453,8 @@ function makeApi(runtimeState, opts) { if (!opts.fakeFs.existsSync(manifestPath)) return null; const pkgJson = JSON.parse(opts.fakeFs.readFileSync(manifestPath, `utf8`)); + if (pkgJson.exports == null) + return null; let subpath = ppath.contains(packageLocation, unqualifiedPath); if (subpath === null) { throw makeError( @@ -19505,25 +19462,25 @@ function makeApi(runtimeState, opts) { `unqualifiedPath doesn't contain the packageLocation (this is probably an internal error)` ); } - if (!isRelativeRegexp.test(subpath)) + if (subpath !== `.` && !isRelativeRegexp.test(subpath)) subpath = `./${subpath}`; - let resolvedExport; try { - resolvedExport = resolve(pkgJson, ppath.normalize(subpath), { - conditions, - unsafe: true + const resolvedExport = packageExportsResolve({ + packageJSONUrl: url.pathToFileURL(npath.fromPortablePath(manifestPath)), + packageSubpath: subpath, + exports: pkgJson.exports, + base: issuer ? url.pathToFileURL(npath.fromPortablePath(issuer)) : null, + conditions }); + return npath.toPortablePath(url.fileURLToPath(resolvedExport)); } catch (error) { throw makeError( ErrorCode.EXPORTS_RESOLUTION_FAILED, error.message, { unqualifiedPath: getPathForDisplay(unqualifiedPath), locator, pkgJson, subpath: getPathForDisplay(subpath), conditions }, - `ERR_PACKAGE_PATH_NOT_EXPORTED` + error.code ); } - if (typeof resolvedExport === `string`) - return ppath.join(packageLocation, resolvedExport); - return null; } function applyNodeExtensionResolution(unqualifiedPath, candidates, { extensions }) { let stat; @@ -19900,10 +19857,10 @@ Required by: ${issuerLocator.name}@${issuerLocator.reference} (via ${issuerForDi } return ppath.normalize(unqualifiedPath); } - function resolveUnqualifiedExport(request, unqualifiedPath, conditions = defaultExportsConditions) { + function resolveUnqualifiedExport(request, unqualifiedPath, conditions = defaultExportsConditions, issuer) { if (isStrictRegExp.test(request)) return unqualifiedPath; - const unqualifiedExportPath = applyNodeExportsResolution(unqualifiedPath, conditions); + const unqualifiedExportPath = applyNodeExportsResolution(unqualifiedPath, conditions, issuer); if (unqualifiedExportPath) { return ppath.normalize(unqualifiedExportPath); } else { @@ -19990,7 +19947,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)} if (unqualifiedPath === null) return null; const isIssuerIgnored = () => issuer !== null ? isPathIgnored(issuer) : false; - const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions) : unqualifiedPath; + const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions, issuer) : unqualifiedPath; return resolveUnqualified(remappedPath, { extensions }); } catch (error) { if (Object.prototype.hasOwnProperty.call(error, `pnpCode`)) @@ -20068,7 +20025,6 @@ function makeManager(pnpapi, opts) { const initialApiStats = opts.fakeFs.statSync(npath.toPortablePath(initialApiPath)); const apiMetadata = /* @__PURE__ */ new Map([ [initialApiPath, { - cache: require$$0.Module._cache, instance: pnpapi, stats: initialApiStats, lastRefreshCheck: Date.now() @@ -20100,7 +20056,6 @@ function makeManager(pnpapi, opts) { } } else { apiMetadata.set(pnpApiPath, apiEntry = { - cache: {}, instance: loadApiInstance(pnpApiPath), stats: opts.fakeFs.statSync(pnpApiPath), lastRefreshCheck: Date.now() @@ -20170,19 +20125,16 @@ ${controlSegment} } while (curr !== PortablePath.root); return addToCacheAndReturn(start, curr, null); } + const moduleToApiPathCache = /* @__PURE__ */ new WeakMap(); function getApiPathFromParent(parent) { if (parent == null) return initialApiPath; - if (typeof parent.pnpApiPath === `undefined`) { - if (parent.filename !== null) { - return parent.pnpApiPath = findApiPathFor(parent.filename); - } else { - return initialApiPath; - } - } - if (parent.pnpApiPath !== null) - return parent.pnpApiPath; - return null; + let apiPath = moduleToApiPathCache.get(parent); + if (typeof apiPath !== `undefined`) + return apiPath; + apiPath = parent.filename ? findApiPathFor(parent.filename) : null; + moduleToApiPathCache.set(parent, apiPath); + return apiPath; } return { getApiPathFromParent, diff --git a/.pnp.loader.mjs b/.pnp.loader.mjs index 057766a..7390f92 100644 --- a/.pnp.loader.mjs +++ b/.pnp.loader.mjs @@ -1333,6 +1333,7 @@ const HAS_CONSOLIDATED_HOOKS = major > 16 || major === 16 && minor >= 12; const HAS_UNFLAGGED_JSON_MODULES = major > 17 || major === 17 && minor >= 5 || major === 16 && minor >= 15; const HAS_JSON_IMPORT_ASSERTION_REQUIREMENT = major > 17 || major === 17 && minor >= 1 || major === 16 && minor > 14; const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13; +const HAS_LAZY_LOADED_TRANSLATORS = major > 19 || major === 19 && minor >= 3; const builtinModules = new Set(Module.builtinModules || Object.keys(process.binding(`natives`))); const isBuiltinModule = (request) => request.startsWith(`node:`) || builtinModules.has(request); @@ -1854,12 +1855,7 @@ function patternKeyCompare(a, b) { return 1; return 0; } -function packageImportsResolve({ - name, - base, - conditions, - readFileSyncFn -}) { +function packageImportsResolve({ name, base, conditions, readFileSyncFn }) { if (name === "#" || StringPrototypeStartsWith(name, "#/") || StringPrototypeEndsWith(name, "/")) { const reason = "is not a valid internal imports specifier name"; throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base)); @@ -1955,7 +1951,7 @@ async function resolvePrivateRequest(specifier, issuer, context, nextResolve) { } } async function resolve$1(originalSpecifier, context, nextResolve) { - var _a; + var _a, _b; const { findPnpApi } = moduleExports; if (!findPnpApi || isBuiltinModule(originalSpecifier)) return nextResolve(originalSpecifier, context, nextResolve); @@ -1967,8 +1963,8 @@ async function resolve$1(originalSpecifier, context, nextResolve) { specifier = fileURLToPath(url); } const { parentURL, conditions = [] } = context; - const issuer = parentURL ? fileURLToPath(parentURL) : process.cwd(); - const pnpapi = (_a = findPnpApi(issuer)) != null ? _a : url ? findPnpApi(specifier) : null; + const issuer = parentURL && ((_a = tryParseURL(parentURL)) == null ? void 0 : _a.protocol) === `file:` ? fileURLToPath(parentURL) : process.cwd(); + const pnpapi = (_b = findPnpApi(issuer)) != null ? _b : url ? findPnpApi(specifier) : null; if (!pnpapi) return nextResolve(originalSpecifier, context, nextResolve); if (specifier.startsWith(`#`)) @@ -1988,10 +1984,17 @@ async function resolve$1(originalSpecifier, context, nextResolve) { } } } - const result = pnpapi.resolveRequest(specifier, issuer, { - conditions: new Set(conditions), - extensions: allowLegacyResolve ? void 0 : [] - }); + let result; + try { + result = pnpapi.resolveRequest(specifier, issuer, { + conditions: new Set(conditions), + extensions: allowLegacyResolve ? void 0 : [] + }); + } catch (err) { + if (err instanceof Error && `code` in err && err.code === `MODULE_NOT_FOUND`) + err.code = `ERR_MODULE_NOT_FOUND`; + throw err; + } if (!result) throw new Error(`Resolving '${specifier}' from '${issuer}' failed`); const resultURL = pathToFileURL(result); @@ -2007,32 +2010,34 @@ async function resolve$1(originalSpecifier, context, nextResolve) { }; } -const binding = process.binding(`fs`); -const originalfstat = binding.fstat; -const ZIP_MASK = 4278190080; -const ZIP_MAGIC = 704643072; -binding.fstat = function(...args) { - const [fd, useBigint, req] = args; - if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { - try { - const stats = fs.fstatSync(fd); - return new Float64Array([ - stats.dev, - stats.mode, - stats.nlink, - stats.uid, - stats.gid, - stats.rdev, - stats.blksize, - stats.ino, - stats.size, - stats.blocks - ]); - } catch { +if (!HAS_LAZY_LOADED_TRANSLATORS) { + const binding = process.binding(`fs`); + const originalfstat = binding.fstat; + const ZIP_MASK = 4278190080; + const ZIP_MAGIC = 704643072; + binding.fstat = function(...args) { + const [fd, useBigint, req] = args; + if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) { + try { + const stats = fs.fstatSync(fd); + return new Float64Array([ + stats.dev, + stats.mode, + stats.nlink, + stats.uid, + stats.gid, + stats.rdev, + stats.blksize, + stats.ino, + stats.size, + stats.blocks + ]); + } catch { + } } - } - return originalfstat.apply(this, args); -}; + return originalfstat.apply(this, args); + }; +} const resolve = resolve$1; const getFormat = HAS_CONSOLIDATED_HOOKS ? void 0 : getFormat$1; diff --git a/src/apis/banners/index.ts b/src/apis/banners/index.ts new file mode 100644 index 0000000..b8c0ecf --- /dev/null +++ b/src/apis/banners/index.ts @@ -0,0 +1,12 @@ +import { useQuery } from "@tanstack/react-query"; +import { instance } from "../axios"; +import { BannerResponse } from "./type"; + +const router = "/banners"; + +export const useGetBanners = () => { + return useQuery(["GetBanners"], async () => { + const { data } = await instance.get(`${router}`); + return data; + }); +}; diff --git a/src/apis/banners/type.ts b/src/apis/banners/type.ts new file mode 100644 index 0000000..581fa6f --- /dev/null +++ b/src/apis/banners/type.ts @@ -0,0 +1,17 @@ +export interface BannerResponse { + banners: BannerResponseType[]; +} + +export interface BannerResponseType { + id: number; + banner_url: string; + banner_type: string; +} + +export interface BannerType { + RECRUITMENT: string; + BOOKMARK: string; + NONE: string; + INTERNSHIP: string; + COMPANY: string; +} diff --git a/src/apis/bookmarks/index.ts b/src/apis/bookmarks/index.ts index 086e587..bb1085b 100644 --- a/src/apis/bookmarks/index.ts +++ b/src/apis/bookmarks/index.ts @@ -20,7 +20,7 @@ export const useSetBookmarks = () => { { onSuccess: () => { queryClient.invalidateQueries(["getRecruitmentsList"]); - queryClient.invalidateQueries(["GetBookmarks"]); + queryClient.invalidateQueries(["GetBookmarks"]); }, } ); diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index 6217cce..6a33679 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -3,31 +3,20 @@ import Image from "next/image"; import React, { useEffect, useRef, useState } from "react"; import CircleBtn from "./CircleBtn"; - -//======================================================================================================= -import PopularCompanyBanner from "@public/PopularCompanyBanner.webp"; -import WinterIntrenBanner from "@public/WinterIntrenBanner.webp"; import { useRouter } from "next/navigation"; -const BannerList = [ - { - img: WinterIntrenBanner, - url: "/recruitments/?page=1&winter_intern=true", - }, - { - img: PopularCompanyBanner, - url: "/companies/detail/?id=9", - }, -]; -//======================================================================================================= +import { useGetBanners } from "@/apis/banners"; +import { BannerType } from "../apis/banners/type"; export default function Banner() { + const { data: banners } = useGetBanners(); const [selected, setSelected] = useState(0); const BannerRefs = useRef([]); const navigator = useRouter(); + console.log(banners); const handleChangeNext = () => { setSelected((prev) => { - if (BannerList.length - 1 === prev) { + if (banners && prev === banners.banners.length - 1) { return 0; } return ++prev; @@ -35,8 +24,8 @@ export default function Banner() { }; const handleChangePrev = () => { setSelected((prev) => { - if (prev === 0) { - return BannerList.length - 1; + if (banners && prev === banners.banners.length - 1) { + return 0; } return --prev; }); @@ -50,43 +39,61 @@ export default function Banner() { }); }, [selected]); + const BannerMove = { + RECRUITMENT: "/recruitments/?page=1", + BOOKMARK: "/", + NONE: "", + INTERNSHIP: "/recruitments/?page=1", + COMPANY: "/companies/detail/?id=`${id}`", + }; + return (
- {BannerList.map((item, index) => ( -
(BannerRefs.current[index] = el)} - onClick={() => { - navigator.push(item.url); - }} - > - -
- ))} + {banners && + banners.banners.map((banner, index) => ( +
(BannerRefs.current[index] = el)} + onClick={() => { + navigator.push( + BannerMove[banner.banner_type as keyof BannerType] + ); + }} + > + +
+ ))}
- {BannerList.map((_, index: number) => ( -
{ - setSelected(index); - }} - > + {banners && + banners.banners.map((_, index: number) => (
-
- ))} + className="w-[20px] h-[20px] flex justify-center items-center cursor-pointer" + key={index} + onClick={() => { + setSelected(index); + }} + > +
+
+ ))}
From da5a8f64976597dc8f3f7776ade8065782d287bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=EC=A7=80?= Date: Fri, 19 Apr 2024 11:08:30 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat=20::=20=EB=B0=B0=EB=84=88=20=EC=BD=94?= =?UTF-8?q?=EB=A9=98=ED=8A=B8=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/banners/type.ts | 8 -------- src/components/Carousel.tsx | 17 +++++------------ src/util/object/enum.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/apis/banners/type.ts b/src/apis/banners/type.ts index 581fa6f..334989d 100644 --- a/src/apis/banners/type.ts +++ b/src/apis/banners/type.ts @@ -7,11 +7,3 @@ export interface BannerResponseType { banner_url: string; banner_type: string; } - -export interface BannerType { - RECRUITMENT: string; - BOOKMARK: string; - NONE: string; - INTERNSHIP: string; - COMPANY: string; -} diff --git a/src/components/Carousel.tsx b/src/components/Carousel.tsx index 6a33679..88a017a 100644 --- a/src/components/Carousel.tsx +++ b/src/components/Carousel.tsx @@ -4,15 +4,14 @@ import Image from "next/image"; import React, { useEffect, useRef, useState } from "react"; import CircleBtn from "./CircleBtn"; import { useRouter } from "next/navigation"; -import { useGetBanners } from "@/apis/banners"; -import { BannerType } from "../apis/banners/type"; +import { useGetBanners } from "../apis/banners"; +import { bannerTypeEnum } from "../util/object/enum"; export default function Banner() { const { data: banners } = useGetBanners(); const [selected, setSelected] = useState(0); const BannerRefs = useRef([]); const navigator = useRouter(); - console.log(banners); const handleChangeNext = () => { setSelected((prev) => { @@ -39,14 +38,6 @@ export default function Banner() { }); }, [selected]); - const BannerMove = { - RECRUITMENT: "/recruitments/?page=1", - BOOKMARK: "/", - NONE: "", - INTERNSHIP: "/recruitments/?page=1", - COMPANY: "/companies/detail/?id=`${id}`", - }; - return (
@@ -63,7 +54,9 @@ export default function Banner() { ref={(el: HTMLDivElement) => (BannerRefs.current[index] = el)} onClick={() => { navigator.push( - BannerMove[banner.banner_type as keyof BannerType] + bannerTypeEnum[ + banner.banner_type as keyof typeof bannerTypeEnum + ] ); }} > diff --git a/src/util/object/enum.ts b/src/util/object/enum.ts index 1a3e29c..35e8491 100644 --- a/src/util/object/enum.ts +++ b/src/util/object/enum.ts @@ -38,3 +38,11 @@ export const applicationStatusStyle = { FIELD_TRAIN: { color: "#2ECC71", backgroundColor: "#E5F8EE" }, ACCEPTANCE: { color: "#2ECC71", backgroundColor: "#E5F8EE" }, }; + +export const bannerTypeEnum = { + RECRUITMENT: "/recruitments/?page=1", + BOOKMARK: "/", + NONE: "/", + INTERNSHIP: "/recruitments/?page=1", + COMPANY: "/companies/detail/?id=`${id}`", +};