From 62ec2cfcdbfa468c2ae44d51a6004bb6bfc1716a Mon Sep 17 00:00:00 2001 From: Akash Shaw Date: Fri, 8 Mar 2024 19:57:51 +0530 Subject: [PATCH] chore: changing the package name to @paybox/common --- packages/recoil/package.json | 2 +- packages/recoil/src/selectors/client.ts | 58 ------------------------- yarn.lock | 5 --- 3 files changed, 1 insertion(+), 64 deletions(-) diff --git a/packages/recoil/package.json b/packages/recoil/package.json index 1799f303..2f29db9f 100644 --- a/packages/recoil/package.json +++ b/packages/recoil/package.json @@ -9,7 +9,7 @@ }, "license": "MIT", "dependencies": { - "common": "*", + "@paybox/common": "*", "next": "^14.1.3", "react": "^18.2.0", "recoil": "^0.7.7" diff --git a/packages/recoil/src/selectors/client.ts b/packages/recoil/src/selectors/client.ts index 88bd15a5..b868985f 100644 --- a/packages/recoil/src/selectors/client.ts +++ b/packages/recoil/src/selectors/client.ts @@ -8,62 +8,4 @@ import { responseStatus, } from "@paybox/common"; -export const fetchDataSelector = selector({ - key: "fetchDataSelector", - get: async ({ get }) => { - try { - const response = await fetch("your-api-endpoint"); - const data = await response.json(); - return data; - } catch (error) { - console.error("Error fetching data:", error); - throw error; - } - }, -}); -export const createAddress = selector({ - key: "dataSelector", - get: async ({ get }) => { - const payload = get(payloadAtom); - const client = get(clientAtom); - if (client == null) { - console.log("Client is null"); - return; - } - const response = await fetch(`${BACKEND_URL}/address/`, { - method: "POST", - headers: { - "Content-Type": "application/json", - authorization: `${client?.jwt}`, - }, - body: JSON.stringify(payload), - }); - - const data = await response.json(); - return data; - }, -}); - -export const useAddress = () => { - return useRecoilCallback( - ({ snapshot, set }) => - async (payload: Partial
) => { - try { - if (payload == null) { - console.log("Null payload provided"); - return; - } - set(payloadAtom, payload); - const data = await snapshot.getPromise(createAddress); - console.log(data); - if (data.status == responseStatus.Error) { - console.log("Error in creating address"); - } - set(addressAtom, payload); - } catch (error) { - console.error("Error setting payload:", error); - } - }, - ); -}; diff --git a/yarn.lock b/yarn.lock index 6da12a47..a2caf23d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8704,11 +8704,6 @@ common-tags@1.8.2: resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.2.tgz#94ebb3c076d26032745fd54face7f688ef5ac9c6" integrity sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA== -common@*: - version "0.2.5" - resolved "https://registry.yarnpkg.com/common/-/common-0.2.5.tgz#3c7182f678bd1e3681cd5cc348c759fe8dd22394" - integrity sha512-bjuztiY8Wcz2V9dPpa0XdF0unGWqAGsnyKDGV7g6xDcaZfpufRrxV35qhuhjwv1h0jEPeiCHWKAQFLj702jGnA== - compare-func@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-2.0.0.tgz#fb65e75edbddfd2e568554e8b5b05fff7a51fcb3"