Skip to content

Commit

Permalink
[ADD] Restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
ThunderNaka committed Sep 27, 2024
1 parent 1afa186 commit 64980be
Show file tree
Hide file tree
Showing 23 changed files with 15 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useAuthStore } from "~/stores";
import type { ServiceResponse } from "../api.types";
import { api } from "../axios";

const { setUser, setToken } = useAuthStore.getState();
const { setToken } = useAuthStore.getState();

export interface UserToken {
refresh_token: string;
Expand All @@ -24,14 +24,12 @@ const refreshToken = async () => {
);
const { data: userToken } = response.data;
if (!userToken.refresh_token) {
setUser(null);
setToken(null);
} else {
refreshWasSuccessful = true;
setToken(userToken.refresh_token);
}
} catch (error) {
setUser(null);
setToken(null);
}
return refreshWasSuccessful;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/config/constants/index.ts → src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { env } from "~/env";

export const isLocal = env.VITE_APP_ENV === "local";

export * from "./common.types";
export * from "./storybook.types";
export * from "./common";
export * from "./storybook";
3 changes: 0 additions & 3 deletions src/config/providers/index.ts

This file was deleted.

File renamed without changes.
7 changes: 3 additions & 4 deletions src/domains/guest/api/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { api } from "~/config/api";
import type { ServiceResponse } from "~/config/api";
import { api } from "~/api";
import type { ServiceResponse } from "~/api";
import { useAuthStore } from "~/stores";

export type UserToken = {
Expand Down Expand Up @@ -27,8 +27,7 @@ export const googleLogin = async ({
};

export const logout = () => {
const { setUser, setToken } = useAuthStore.getState();
const { setToken } = useAuthStore.getState();

setUser(null);
setToken(null);
};
4 changes: 2 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "~/config/scripts/sentry";
import "~/config/providers/scripts/sentry";

import React, { StrictMode } from "react";
import { createRoot } from "react-dom/client";

import "./index.css";

import { Providers } from "./config/providers";
import { Providers } from "./providers";
import { Router } from "./router";

const root = document.getElementById("root");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PropsWithChildren } from "react";
import React from "react";

import { ReactQueryProvider } from "./ReactQueryProvider";
import { SentryProvider } from "./SentryProvider";
import { SentryProvider } from "./sentry/SentryProvider";

export const Providers = ({ children }: PropsWithChildren) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { z } from "zod";

import { isLocal } from "~/constants";
import { isLocal } from "~/config";

const errorSchema = z.object({ message: z.string() });

Expand Down
1 change: 1 addition & 0 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Providers";
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Sentry from "@sentry/react";

import { isLocal } from "~/constants";
import { isLocal } from "~/config";
import { env } from "~/env";

if (!isLocal) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/icons/CloseIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";

import type { SVGProps } from "~/config/constants";
import type { SVGProps } from "~/config";

export const CloseIcon = ({ className, ...props }: SVGProps) => (
<svg
Expand Down
4 changes: 2 additions & 2 deletions templates/domains/api/example.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
import { z } from "zod";

import type { ServiceResponse } from "~/config/api";
import { api } from "~/config/api";
import type { ServiceResponse } from "~/api";
import { api } from "~/api";
import { create{{camelCase name}}Schema, {{camelCase name}}Schema } from "./schemas";

export type {{pascalCase name}} = z.infer<typeof {{camelCase name}}Schema>;
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"paths": {
"~/assets": ["./shared/assets"],
"~/components": ["./shared/components/ui"],
"~/constants": ["./config/constants"],
"~/hooks": ["./shared/hooks"],
"~/icons": ["./shared/components/icons"],
"~/sections": ["./shared/sections"],
Expand Down
4 changes: 0 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ const config = ({ mode }: ConfigEnv): UserConfigExport => {
find: "~/components",
replacement: path.resolve(__dirname, "./src/shared/components/ui"),
},
{
find: "~/constants",
replacement: path.resolve(__dirname, "./src/config/constants"),
},
{
find: "~/hooks",
replacement: path.resolve(__dirname, "./src/shared/hooks"),
Expand Down

0 comments on commit 64980be

Please sign in to comment.