Sign In

@talentprotocol/zustand-wrapper

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talentprotocol/zustand-wrapper - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+5
.turbo/turbo-lint.log
> @talentprotocol/conf@0.0.0 lint /Users/bguedes/Desktop/talent/ecosystem/packages/conf
> eslint *.ts*
 ELIFECYCLE  Command failed.
export * from './store';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
export * from './store';
export * from './store';
export {};
//# sourceMappingURL=store.d.ts.map
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["store.ts"],"names":[],"mappings":""}
import { create } from "zustand";
const _storeMap = {};
const createStore = (name, blueprintCallback) => {
if (!!_storeMap[name])
throw `ERROR: Trying to memoize a store that already exists - ${name}`;
const storeRef = create(blueprintCallback);
_storeMap[name] = () => storeRef;
};
const getExistentStores = () => Object.keys(_storeMap);
module.exports = {
_storeMap,
createStore,
getExistentStores
};
import { create, StateCreator } from "zustand";
const _storeMap:{[key: string]: any} = {};
const createStore = (name: string, blueprintCallback: any) => {
if (!!_storeMap[name])
throw `ERROR: Trying to memoize a store that already exists - ${name}`;
const storeRef = create(blueprintCallback);
_storeMap[name] = () => storeRef;
}
const getExistentStores = () => Object.keys(_storeMap);
module.exports = {
_storeMap,
createStore,
getExistentStores
}
import React from "react";
import create from "zustand";
import { get } from "src/utils/requests";
import { toast } from "react-toastify";
import { talentsService } from "src/api/talents";
import { careerUpdatesService } from "src/api";
import { ToastBody } from "src/components/design_system/toasts";
const messagesStore = create(set => ({
messageCount: 0,
increaseMessageCount: () => set(state => ({ messageCount: state.messageCount + 1 })),
clearMessageCount: () => set({ messageCount: 0 })
}));
const railsContextStore = create(set => ({
railsContext: {},
setRailsContext: newRailsContext => set({ railsContext: newRailsContext })
}));
const urlStore = create(set => ({
url: "",
changeURL: newURL => set({ url: newURL })
}));
const loggedInUserStore = create(set => ({
currentUser: undefined,
loading: false,
fetchCurrentUser: async () => {
const response = await get("/api/v1/sessions/logged_in_user").catch(error => console.error(error));
set({ currentUser: response.user, loading: false });
}
}));
const useProfileOverviewStore = create(set => ({
profileOverview: undefined,
fetchProfileOverview: async profileUsername => {
const { data } = await talentsService.getProfileOverview(profileUsername).catch(err => {
console.error(err);
toast.error(<ToastBody heading={"Profile not found"} />);
setTimeout(() => {
window.location.href = "/home";
}, 500);
});
set({ profileOverview: data.talent });
}
}));
const useCareerUpdatesStore = create(set => ({
// In the future we should put the list of career updates here and not only the one created
careerUpdates: [],
createCareerUpdate: async (message, selectedPills) => {
const { data } = await careerUpdatesService.sendUpdate(message, selectedPills).catch(err => {
console.error(err);
toast.error(<ToastBody heading={"Error"} />, { autoClose: 3000 });
});
if (data.career_update) {
set(state => ({ careerUpdates: [...state.careerUpdates, data.career_update] }));
toast.success(<ToastBody heading="Success!" body={"Your update was sent to your subscribers."} />, {
autoClose: 3000
});
}
}
}));
export {
messagesStore,
railsContextStore,
urlStore,
loggedInUserStore,
useProfileOverviewStore,
useCareerUpdatesStore
};
+3
-3
{
"name": "@talentprotocol/zustand-wrapper",
"version": "0.0.3",
"main": "./index.ts",
"types": "./index.ts",
"version": "0.0.4",
"main": "./src/index.ts",
"types": "./src/index.ts",
"license": "MIT",

@@ -7,0 +7,0 @@ "scripts": {

{
"compilerOptions": {
"jsx": "react-jsx"
},
"compilerOptions": {},
"extends": "tsconfig/react-library.json",

@@ -6,0 +4,0 @@ "include": ["."],

//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":""}
"use strict";
import { EnvironmentConfInterface } from "./types";
export declare const envConf: EnvironmentConfInterface;
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAe,MAAM,SAAS,CAAC;AAEhE,eAAO,MAAM,OAAO,EAAE,wBAOf,CAAC"}
import { ENVIRONMENT } from "./types";
export const envConf = process.env.ENVIRONMENT === ENVIRONMENT.DEV
? {
LEGACY_WEB_DAPP_URL: "https://dev.talentprotocol.com",
}
: {
LEGACY_WEB_DAPP_URL: "https://beta.talentprotocol.com",
};
import { EnvironmentConfInterface, ENVIRONMENT } from "./types";
export const envConf: EnvironmentConfInterface =
process.env.ENVIRONMENT === ENVIRONMENT.DEV
? {
LEGACY_WEB_DAPP_URL: "https://dev.talentprotocol.com",
}
: {
LEGACY_WEB_DAPP_URL: "https://beta.talentprotocol.com",
};
export interface EnvironmentConfInterface {
LEGACY_WEB_DAPP_URL: string;
}
export declare enum ENVIRONMENT {
DEV = "dev",
PROD = "production"
}
//# sourceMappingURL=types.d.ts.map
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,IAAI,eAAe;CACpB"}
export var ENVIRONMENT;
(function (ENVIRONMENT) {
ENVIRONMENT["DEV"] = "dev";
ENVIRONMENT["PROD"] = "production";
})(ENVIRONMENT || (ENVIRONMENT = {}));
export interface EnvironmentConfInterface {
LEGACY_WEB_DAPP_URL: string;
}
export enum ENVIRONMENT {
DEV = "dev",
PROD = "production",
}
import React from "react";
import create from "zustand";
import { get } from "src/utils/requests";
import { toast } from "react-toastify";
import { talentsService } from "src/api/talents";
import { careerUpdatesService } from "src/api";
import { ToastBody } from "src/components/design_system/toasts";
const messagesStore = create(set => ({
messageCount: 0,
increaseMessageCount: () => set(state => ({ messageCount: state.messageCount + 1 })),
clearMessageCount: () => set({ messageCount: 0 })
}));
const railsContextStore = create(set => ({
railsContext: {},
setRailsContext: newRailsContext => set({ railsContext: newRailsContext })
}));
const urlStore = create(set => ({
url: "",
changeURL: newURL => set({ url: newURL })
}));
const loggedInUserStore = create(set => ({
currentUser: undefined,
loading: false,
fetchCurrentUser: async () => {
const response = await get("/api/v1/sessions/logged_in_user").catch(error => console.error(error));
set({ currentUser: response.user, loading: false });
}
}));
const useProfileOverviewStore = create(set => ({
profileOverview: undefined,
fetchProfileOverview: async profileUsername => {
const { data } = await talentsService.getProfileOverview(profileUsername).catch(err => {
console.error(err);
toast.error(<ToastBody heading={"Profile not found"} />);
setTimeout(() => {
window.location.href = "/home";
}, 500);
});
set({ profileOverview: data.talent });
}
}));
const useCareerUpdatesStore = create(set => ({
// In the future we should put the list of career updates here and not only the one created
careerUpdates: [],
createCareerUpdate: async (message, selectedPills) => {
const { data } = await careerUpdatesService.sendUpdate(message, selectedPills).catch(err => {
console.error(err);
toast.error(<ToastBody heading={"Error"} />, { autoClose: 3000 });
});
if (data.career_update) {
set(state => ({ careerUpdates: [...state.careerUpdates, data.career_update] }));
toast.success(<ToastBody heading="Success!" body={"Your update was sent to your subscribers."} />, {
autoClose: 3000
});
}
}
}));
export {
messagesStore,
railsContextStore,
urlStore,
loggedInUserStore,
useProfileOverviewStore,
useCareerUpdatesStore
};
const create = require("zustand");
const _storeMap = {};
const createStore = (name, blueprintCallback) => {
if (!!_storeMap[name])
throw `ERROR: Trying to memoize a store that already exists - ${name}`;
const storeRef = create(blueprintCallback);
_storeMap[name] = () => storeRef;
}
const getExistentStores = () => Object.keys(_storeMap);
module.exports = {
_storeMap,
createStore,
getExistentStores
}