Skip to content

Commit

Permalink
chore: changing the package name to @paybox/common
Browse files Browse the repository at this point in the history
  • Loading branch information
shawakash committed Mar 8, 2024
1 parent 4185101 commit 62ec2cf
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 64 deletions.
2 changes: 1 addition & 1 deletion packages/recoil/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"license": "MIT",
"dependencies": {
"common": "*",
"@paybox/common": "*",
"next": "^14.1.3",
"react": "^18.2.0",
"recoil": "^0.7.7"
Expand Down
58 changes: 0 additions & 58 deletions packages/recoil/src/selectors/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address>) => {
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);
}
},
);
};
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8704,11 +8704,6 @@ [email protected]:
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"
Expand Down

0 comments on commit 62ec2cf

Please sign in to comment.