Skip to content

Commit

Permalink
use path alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jitunayak committed Jun 3, 2024
1 parent d29ba23 commit c87fd30
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 51 deletions.
8 changes: 4 additions & 4 deletions src/components/HomeResultItem.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { LeftArrowIcon, RightArrowIcon } from '@/assets';
import { useApi } from '@/hooks';
import { IRoom } from '@/types';
import { useKindeAuth } from '@kinde-oss/kinde-auth-react';
import { styled } from '@stitches/react';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useNavigate } from '@tanstack/react-router';
import { HeartIcon, StarIcon } from 'lucide-react';
import React, { useState } from 'react';

import { HeartIcon, LeftArrowIcon, RightArrowIcon, StarIcon } from '../assets';
import useApi from '../hooks/useApi';
import { IRoom } from '../types';

interface IProps {
isWishListed: boolean;
item: IRoom;
Expand Down
4 changes: 2 additions & 2 deletions src/components/HomeResults.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useApi } from '@/hooks';
import { IRoom } from '@/types';
import { useKindeAuth } from '@kinde-oss/kinde-auth-react';
import { styled } from '@stitches/react';
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
import { useCallback, useEffect } from 'react';

import useApi from '../hooks/useApi';
import { IRoom } from '../types';
import HomeResultItem from './HomeResultItem';

const placeholderData = {
Expand Down
4 changes: 1 addition & 3 deletions src/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface IProps {
validator: z.ZodString;
}

const TextInput: React.FC<IProps> = ({
export const TextInput: React.FC<IProps> = ({
form,
label,
name,
Expand Down Expand Up @@ -73,8 +73,6 @@ const TextInput: React.FC<IProps> = ({
);
};

export default TextInput;

const InputWrapper = styled('div', {
borderRadius: '6px',
paddingBottom: '.6rem',
Expand Down
3 changes: 3 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './Common';
export * from './Divider';
export * from './TextInput';
4 changes: 2 additions & 2 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./useOutsideClick";
export * from "./useApi";
export * from './useApi';
export * from './useOutsideClick';
8 changes: 3 additions & 5 deletions src/hooks/useApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import useRoomsApi from "./useRoomsApi";
import { default as useWishlistApi } from "./useWishlistApi";
import useRoomsApi from './useRoomsApi';
import { default as useWishlistApi } from './useWishlistApi';

const useApi = () => {
export const useApi = () => {
const wishlistApi = useWishlistApi();
const roomsApi = useRoomsApi();

Expand All @@ -10,5 +10,3 @@ const useApi = () => {
wishlistApi,
};
};

export default useApi;
7 changes: 3 additions & 4 deletions src/pages/Hosting/NewListing/Steps/Step1.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Column, Row, TextInput } from '@/components';
import { useApi } from '@/hooks';
import { styled } from '@stitches/react';
import { useForm } from '@tanstack/react-form';
import { useMutation } from '@tanstack/react-query';
import { useNavigate } from '@tanstack/react-router';
import { zodValidator } from '@tanstack/zod-form-adapter';
import { z } from 'zod';

import { Column, Row } from '../../../../components/Common';
import TextInput from '../../../../components/TextInput';
import useApi from '../../../../hooks/useApi';
import { styled } from '../../../../stitches.config';
import Amenities from '../Amenities';

const OnboardingFormStep1: React.FC = () => {
Expand Down
7 changes: 3 additions & 4 deletions src/pages/Room/Reserve.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Divider, Row } from '@/components';
import { useApi } from '@/hooks';
import { IRoom } from '@/types';
import { useKindeAuth } from '@kinde-oss/kinde-auth-react';
import { useMutation } from '@tanstack/react-query';
import { useLocation } from '@tanstack/react-router';
import { ChevronDown, ChevronUp } from 'lucide-react';
import moment from 'moment';
import React, { useState } from 'react';

import { Row } from '../../components/Common';
import { Divider } from '../../components/Divider';
import useApi from '../../hooks/useApi';
import { styled } from '../../stitches.config';
import { IRoom } from '../../types';

type IProps = {
room: IRoom;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Room/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Column, Row } from '@/components';
import { useApi } from '@/hooks';
import { useQuery } from '@tanstack/react-query';
import { useParams } from '@tanstack/react-router';

import { Column, Row } from '../../components/Common';
import Header from '../../components/Header';
import useApi from '../../hooks/useApi';
import { styled } from '../../stitches.config';
import Header from '../Hosting/Header';
import Reserve from './Reserve';

function RoomPage() {
Expand Down
42 changes: 21 additions & 21 deletions src/pages/Wishlists.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { useKindeAuth } from "@kinde-oss/kinde-auth-react";
import { styled } from "@stitches/react";
import { useQuery } from "@tanstack/react-query";
import { useApi } from '@/hooks';
import { useKindeAuth } from '@kinde-oss/kinde-auth-react';
import { styled } from '@stitches/react';
import { useQuery } from '@tanstack/react-query';

import HomeResultItem from "../components/HomeResultItem";
import useApi from "../hooks/useApi";
import HomeResultItem from '../components/HomeResultItem';

function Wishlists() {
const { wishlistApi } = useApi();
const { user } = useKindeAuth();
const { data, isError, isLoading, isSuccess } = useQuery({
queryFn: () => wishlistApi.getWishLists(user?.id || ""),
queryKey: ["wishlists"],
queryFn: () => wishlistApi.getWishLists(user?.id || ''),
queryKey: ['wishlists'],
});

return (
<Container>
<div style={{ fontSize: "50px" }}>Wishlists</div>
{isLoading && <div style={{ margin: "4rem" }}>loading...</div>}
{isError && <div style={{ margin: "4rem" }}> unable to fetch</div>}
<div style={{ fontSize: '50px' }}>Wishlists</div>
{isLoading && <div style={{ margin: '4rem' }}>loading...</div>}
{isError && <div style={{ margin: '4rem' }}> unable to fetch</div>}
{!isLoading && (
<ResultContainer>
{isSuccess &&
Expand All @@ -34,19 +34,19 @@ function Wishlists() {

export default Wishlists;

const Container = styled("div", {
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
margin: "4rem",
const Container = styled('div', {
display: 'flex',
flexDirection: 'column',
justifyContent: 'flex-start',
margin: '4rem',
});

const ResultContainer = styled("div", {
alignContent: "space-around",
display: "flex",
flexWrap: "wrap",
gap: "1rem",
justifyContent: "space-around",
const ResultContainer = styled('div', {
alignContent: 'space-around',
display: 'flex',
flexWrap: 'wrap',
gap: '1rem',
justifyContent: 'space-around',
// zIndex: "1",
// top: "1rem",
// position: "absolute",
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

"types": ["node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
8 changes: 6 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
server: {
port: 3000,
},
Expand Down

0 comments on commit c87fd30

Please sign in to comment.