@navservice/assinatura 1.52.0 → 1.54.0

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.
@@ -1,6 +1,5 @@
1
1
  interface VisualizarCreditosProps {
2
- usuario_id: string;
3
2
  label?: string;
4
3
  }
5
- export declare function VisualizarCreditos({ usuario_id, label }: VisualizarCreditosProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function VisualizarCreditos({ label }: VisualizarCreditosProps): import("react/jsx-runtime").JSX.Element;
6
5
  export {};
package/build/es/index.js CHANGED
@@ -18998,10 +18998,16 @@ var assinatura_TypeControllerAssinatura;
18998
18998
  const cliente = cliente_TypeControllerCliente;
18999
18999
  var cliente_TypeControllerCliente;
19000
19000
  (function(TypeControllerCreditos) {
19001
+ TypeControllerCreditos.TipoEnum = [
19002
+ "entrada",
19003
+ "saida",
19004
+ "bonus"
19005
+ ];
19001
19006
  TypeControllerCreditos.PontosBaseSchema = v4.object({
19002
19007
  _id: v4.string(),
19003
19008
  usuario_id: v4.string(),
19004
19009
  app: v4["enum"](es_types.Controller.Usuario.AppEnum),
19010
+ tipo: v4["enum"](TypeControllerCreditos.TipoEnum),
19005
19011
  quantidade: v4.number(),
19006
19012
  valor: v4.number(),
19007
19013
  data_criacao: v4.number(),
@@ -19017,6 +19023,17 @@ var cliente_TypeControllerCliente;
19017
19023
  })
19018
19024
  });
19019
19025
  })(TypeControllerCreditos.BuscarPeloUsuarioId || (TypeControllerCreditos.BuscarPeloUsuarioId = {}));
19026
+ (function(UsarCreditosDoUsuario) {
19027
+ UsarCreditosDoUsuario.route = "/api/creditos/usuario/usar";
19028
+ UsarCreditosDoUsuario.InputSchema = v4.object({
19029
+ data: v4.object({
19030
+ creditos: v4.object({
19031
+ usuario_id: v4.string(),
19032
+ quantidade: v4.number().int().positive()
19033
+ })
19034
+ })
19035
+ });
19036
+ })(TypeControllerCreditos.UsarCreditosDoUsuario || (TypeControllerCreditos.UsarCreditosDoUsuario = {}));
19020
19037
  (function(CriarCheckoutCreditos) {
19021
19038
  CriarCheckoutCreditos.route = "/api/creditos/checkout";
19022
19039
  CriarCheckoutCreditos.InputSchema = v4.object({
@@ -19711,112 +19728,69 @@ const contexto_creditos = new class {
19711
19728
  });
19712
19729
  };
19713
19730
  };
19714
- function VisualizarCreditos({ usuario_id, label = "Seus créditos" }) {
19731
+ function VisualizarCreditos({ label = "Créditos" }) {
19715
19732
  const { quantidade, loading } = contexto_creditos.get_jsx;
19733
+ const usuario_id = src_utils.session_sorage.usuario_auth?.data?.usuario?._id;
19716
19734
  useEffect(()=>{
19717
19735
  if (!usuario_id) return;
19718
- contexto_creditos.api.buscar_pelo_usuario_id(usuario_id);
19736
+ contexto_creditos.api.buscar_pelo_usuario_id(src_utils.session_sorage.usuario_auth?.data?.usuario?._id);
19719
19737
  }, [
19720
19738
  usuario_id
19721
19739
  ]);
19722
- return /*#__PURE__*/ jsx("div", {
19723
- className: "w-full max-w-sm",
19724
- children: /*#__PURE__*/ jsxs("div", {
19725
- className: " relative bg-white rounded-xl border border-gray-200 p-4 transition-all duration-200 hover:border-blue-300 hover:shadow-md ",
19726
- children: [
19727
- /*#__PURE__*/ jsxs("div", {
19728
- className: "flex items-center justify-between mb-3",
19740
+ return /*#__PURE__*/ jsxs("div", {
19741
+ className: "flex items-center gap-2 bg-gradient-to-r transition-all duration-200",
19742
+ children: [
19743
+ /*#__PURE__*/ jsx("div", {
19744
+ className: "flex items-center justify-center w-6 h-6 rounded-md bg-gradient-to-br from-blue-500 to-cyan-500 shadow-sm",
19745
+ children: /*#__PURE__*/ jsx("svg", {
19746
+ className: "w-3.5 h-3.5 text-white",
19747
+ fill: "none",
19748
+ stroke: "currentColor",
19749
+ viewBox: "0 0 24 24",
19750
+ children: /*#__PURE__*/ jsx("path", {
19751
+ strokeLinecap: "round",
19752
+ strokeLinejoin: "round",
19753
+ strokeWidth: 2.5,
19754
+ d: "M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
19755
+ })
19756
+ })
19757
+ }),
19758
+ /*#__PURE__*/ jsx("div", {
19759
+ className: "flex items-center gap-2",
19760
+ children: loading ? /*#__PURE__*/ jsx("div", {
19761
+ className: "w-12 h-5 bg-blue-200/50 rounded animate-pulse"
19762
+ }) : /*#__PURE__*/ jsxs(Fragment, {
19729
19763
  children: [
19730
19764
  /*#__PURE__*/ jsxs("div", {
19731
- className: "flex items-center gap-2",
19765
+ className: "flex items-baseline gap-1",
19732
19766
  children: [
19733
- /*#__PURE__*/ jsx("div", {
19734
- className: "w-8 h-8 rounded-lg bg-gradient-to-br from-blue-500 to-cyan-500 flex items-center justify-center",
19735
- children: /*#__PURE__*/ jsx("svg", {
19736
- className: "w-4 h-4 text-white",
19737
- fill: "none",
19738
- stroke: "currentColor",
19739
- viewBox: "0 0 24 24",
19740
- children: /*#__PURE__*/ jsx("path", {
19741
- strokeLinecap: "round",
19742
- strokeLinejoin: "round",
19743
- strokeWidth: 2,
19744
- d: "M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
19745
- })
19746
- })
19767
+ /*#__PURE__*/ jsx("span", {
19768
+ className: "text-lg font-bold bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-transparent leading-none",
19769
+ children: quantidade.toLocaleString("pt-BR")
19747
19770
  }),
19748
19771
  /*#__PURE__*/ jsx("span", {
19749
- className: "text-sm font-medium text-gray-700",
19772
+ className: "text-xs text-gray-500 font-medium hidden sm:inline",
19750
19773
  children: label
19751
19774
  })
19752
19775
  ]
19753
19776
  }),
19754
- loading && /*#__PURE__*/ jsx("div", {
19755
- className: "w-4 h-4 rounded-full border-2 border-gray-200 border-t-blue-500 animate-spin"
19777
+ 0 === quantidade && /*#__PURE__*/ jsx("svg", {
19778
+ className: "w-4 h-4 text-amber-500 sm:hidden",
19779
+ fill: "currentColor",
19780
+ viewBox: "0 0 20 20",
19781
+ children: /*#__PURE__*/ jsx("path", {
19782
+ fillRule: "evenodd",
19783
+ d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",
19784
+ clipRule: "evenodd"
19785
+ })
19756
19786
  })
19757
19787
  ]
19758
- }),
19759
- /*#__PURE__*/ jsx("div", {
19760
- className: "flex items-baseline gap-2 mb-2",
19761
- children: loading ? /*#__PURE__*/ jsx("div", {
19762
- className: "h-9 w-20 bg-gray-100 rounded animate-pulse"
19763
- }) : /*#__PURE__*/ jsxs(Fragment, {
19764
- children: [
19765
- /*#__PURE__*/ jsx("span", {
19766
- className: "text-3xl font-bold bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-transparent",
19767
- children: quantidade.toLocaleString("pt-BR")
19768
- }),
19769
- /*#__PURE__*/ jsx("span", {
19770
- className: "text-sm text-gray-500 font-medium",
19771
- children: 1 === quantidade ? "crédito" : "créditos"
19772
- })
19773
- ]
19774
- })
19775
- }),
19776
- !loading && /*#__PURE__*/ jsx(Fragment, {
19777
- children: 0 === quantidade ? /*#__PURE__*/ jsxs("div", {
19778
- className: "flex items-center gap-1.5 text-xs text-gray-500",
19779
- children: [
19780
- /*#__PURE__*/ jsx("svg", {
19781
- className: "w-3.5 h-3.5",
19782
- fill: "none",
19783
- stroke: "currentColor",
19784
- viewBox: "0 0 24 24",
19785
- children: /*#__PURE__*/ jsx("path", {
19786
- strokeLinecap: "round",
19787
- strokeLinejoin: "round",
19788
- strokeWidth: 2,
19789
- d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
19790
- })
19791
- }),
19792
- /*#__PURE__*/ jsx("span", {
19793
- children: "Nenhum cr\xe9dito dispon\xedvel"
19794
- })
19795
- ]
19796
- }) : /*#__PURE__*/ jsxs("div", {
19797
- className: "flex items-center gap-2",
19798
- children: [
19799
- /*#__PURE__*/ jsx("div", {
19800
- className: "flex-1 h-1 bg-gray-100 rounded-full overflow-hidden",
19801
- children: /*#__PURE__*/ jsx("div", {
19802
- className: "h-full bg-gradient-to-r from-blue-500 to-cyan-500 rounded-full transition-all duration-500",
19803
- style: {
19804
- width: Math.min(quantidade / 100 * 100, 100) + "%"
19805
- }
19806
- })
19807
- }),
19808
- quantidade < 100 && /*#__PURE__*/ jsxs("span", {
19809
- className: "text-xs font-medium text-gray-400",
19810
- children: [
19811
- quantidade,
19812
- "%"
19813
- ]
19814
- })
19815
- ]
19816
- })
19817
19788
  })
19818
- ]
19819
- })
19789
+ }),
19790
+ loading && /*#__PURE__*/ jsx("div", {
19791
+ className: "w-3.5 h-3.5 rounded-full border-2 border-blue-200 border-t-blue-600 animate-spin"
19792
+ })
19793
+ ]
19820
19794
  });
19821
19795
  }
19822
19796
  export { CheckoutAssinaturaStripe, CheckoutStripe, shared_types as TypesAssinatura, VisualizarCreditos, contexto_assinatura };
@@ -2,6 +2,7 @@ import { AxiosResponse } from "axios";
2
2
  import z4 from "zod/v4";
3
3
  import t from "../index";
4
4
  declare namespace TypeControllerCreditos {
5
+ const TipoEnum: readonly ["entrada", "saida", "bonus"];
5
6
  const PontosBaseSchema: z4.ZodObject<{
6
7
  _id: z4.ZodString;
7
8
  usuario_id: z4.ZodString;
@@ -11,6 +12,11 @@ declare namespace TypeControllerCreditos {
11
12
  "service-assinatura": "service-assinatura";
12
13
  "service-bucket": "service-bucket";
13
14
  }>;
15
+ tipo: z4.ZodEnum<{
16
+ entrada: "entrada";
17
+ saida: "saida";
18
+ bonus: "bonus";
19
+ }>;
14
20
  quantidade: z4.ZodNumber;
15
21
  valor: z4.ZodNumber;
16
22
  data_criacao: z4.ZodNumber;
@@ -27,6 +33,27 @@ declare namespace TypeControllerCreditos {
27
33
  }, z4.core.$strip>;
28
34
  }, z4.core.$strip>;
29
35
  type Input = z4.infer<typeof InputSchema>;
36
+ type Output = {
37
+ data: {
38
+ creditos: {
39
+ quantidade: number;
40
+ proporcao_credito_para_reais: 100;
41
+ };
42
+ };
43
+ };
44
+ type Response = AxiosResponse<t.Geral.Response.C.Output<Output>>;
45
+ }
46
+ namespace UsarCreditosDoUsuario {
47
+ const route: "/api/creditos/usuario/usar";
48
+ const InputSchema: z4.ZodObject<{
49
+ data: z4.ZodObject<{
50
+ creditos: z4.ZodObject<{
51
+ usuario_id: z4.ZodString;
52
+ quantidade: z4.ZodNumber;
53
+ }, z4.core.$strip>;
54
+ }, z4.core.$strip>;
55
+ }, z4.core.$strip>;
56
+ type Input = z4.infer<typeof InputSchema>;
30
57
  type Output = {
31
58
  data: {
32
59
  creditos: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/assinatura",
3
- "version": "1.52.0",
3
+ "version": "1.54.0",
4
4
  "description": "Service de autenticação de usuários unificado",
5
5
  "type": "module",
6
6
  "main": "./build/lib/index.js",