-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
874 additions
and
26 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { post } from "@apis/api"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { ErrorResponse, CodeResponseType } from "@types"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
interface LoginDataType { | ||
username: string; | ||
password: string; | ||
} | ||
|
||
const postAdminLogin = async ( | ||
loginData: LoginDataType | ||
): Promise<CodeResponseType> => { | ||
try { | ||
const response = await post<CodeResponseType>( | ||
`/api/v1/admin/authenticate`, | ||
loginData | ||
); | ||
return response.data; | ||
} catch (error) { | ||
const errorResponse = error as ErrorResponse; | ||
const errorData = errorResponse.response.data; | ||
throw errorData; | ||
} | ||
}; | ||
|
||
export const usePostAdminLogin = () => { | ||
const navigate = useNavigate(); | ||
return useMutation({ | ||
mutationFn: (loginData: LoginDataType) => postAdminLogin(loginData), | ||
onSuccess: (data) => { | ||
if (data.code === "success") { | ||
localStorage.setItem("accessToken", data.code); | ||
navigate("/admin"); | ||
} | ||
}, | ||
}); | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/apis/domains/orderCheck/useFetchOrderInfoWithOrderNumber.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { get } from "@apis/api"; | ||
import { QUERY_KEY } from "@apis/queryKeys/queryKeys"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ApiResponseType, OrderInfoData } from "@types"; | ||
|
||
const getOrderInfo = async ( | ||
orderNumber: number | ||
): Promise<OrderInfoData | null> => { | ||
try { | ||
const response = await get<ApiResponseType<OrderInfoData>>( | ||
`api/v1/order/${orderNumber}` | ||
); | ||
return response.data.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export const useFetchOrderInfoWithOrderNumber = (orderNumber: number) => { | ||
return useQuery({ | ||
queryKey: [QUERY_KEY.ORDER_INFO_WITH_ORDER_NUMBER], | ||
queryFn: () => getOrderInfo(orderNumber), | ||
enabled: false, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { get } from "@apis/api"; | ||
import { QUERY_KEY } from "@apis/queryKeys/queryKeys"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ApiResponseType, RecentOrderType } from "@types"; | ||
|
||
const getRecentOrderNumber = async (): Promise<RecentOrderType[] | null> => { | ||
try { | ||
const response = await get<ApiResponseType<RecentOrderType[]>>( | ||
"api/v1/order/recent" | ||
); | ||
return response.data.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export const useFetchRecentOrderNumber = () => { | ||
return useQuery({ | ||
queryKey: [QUERY_KEY.RECENT_ORDER_NUMBER], | ||
queryFn: () => getRecentOrderNumber(), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { patch } from "@apis/api"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { MutateResponseType } from "@types"; | ||
|
||
const patchPayCancel = async ( | ||
orderNumber: number | ||
): Promise<MutateResponseType | null> => { | ||
try { | ||
const response = await patch<MutateResponseType>( | ||
`api/v1/order/cancel/${orderNumber}` | ||
); | ||
return response.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export const usePatchPayCancel = () => { | ||
return useMutation({ | ||
mutationFn: (orderNumber: number) => patchPayCancel(orderNumber), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { patch } from "@apis/api"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { MutateResponseType } from "@types"; | ||
|
||
const patchPayComplete = async ( | ||
orderNumber: number | ||
): Promise<MutateResponseType | null> => { | ||
try { | ||
const response = await patch<MutateResponseType>( | ||
`api/v1/order/pay/${orderNumber}` | ||
); | ||
return response.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export const usePatchPayComplete = () => { | ||
return useMutation({ | ||
mutationFn: (orderNumber: number) => patchPayComplete(orderNumber), | ||
onSuccess: () => {}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { SVGProps } from "react"; | ||
const SvgIcRefresh = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
viewBox="0 0 32 32" | ||
{...props} | ||
> | ||
<path | ||
fill="#EC6732" | ||
d="M16 32q-6.7 0-11.35-4.65T0 16 4.65 4.65 16 0q3.45 0 6.6 1.425T28 5.5V0h4v14H18v-4h8.4a11.67 11.67 0 0 0-4.375-4.4Q19.25 4 16 4q-5 0-8.5 3.5T4 16t3.5 8.5T16 28q3.85 0 6.95-2.2T27.3 20h4.2q-1.4 5.3-5.7 8.65T16 32" | ||
/> | ||
</svg> | ||
); | ||
export default SvgIcRefresh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Theme } from "@emotion/react"; | ||
import { css } from "@emotion/react"; | ||
import { flexGenerator } from "@styles/generator"; | ||
|
||
export const loginLayout = css` | ||
width: 100%; | ||
height: 100dvh; | ||
${flexGenerator()}; | ||
padding: 0 3rem; | ||
`; | ||
|
||
export const formStyle = css` | ||
width: 100%; | ||
${flexGenerator("column", "flex-start", "flex-start")} | ||
`; | ||
|
||
export const inputWrapper = css` | ||
width: 100%; | ||
${flexGenerator("column", "flex-start", "flex-start")} | ||
gap: 0.8rem; | ||
margin-bottom: 2rem; | ||
`; | ||
|
||
export const labelStyle = (theme: Theme) => css` | ||
${theme.font["head06-b-16"]}; | ||
`; |
Oops, something went wrong.