Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ export function useOnboardingFunnel() {

if (isFinalStep) {
postSignData(
{ email: userEmail, remindDefault: remindTime, fcmToken },
{
email: userEmail,
remindDefault: remindTime,
fcmToken,
job: selectedJob ?? '',
},
{
onSuccess: () => (window.location.href = '/'),
onError: () => {
Expand Down Expand Up @@ -145,6 +150,7 @@ export function useOnboardingFunnel() {
setStep,
step,
userEmail,
selectedJob,
]);

const prevStep = useCallback(() => {
Expand Down
12 changes: 11 additions & 1 deletion apps/client/src/shared/apis/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ export interface postSignUpRequest {
email: string;
remindDefault: string;
fcmToken: string | null;
job: string;
}

export const postSignUp = async (responsedata: postSignUpRequest) => {
const { data } = await apiRequest.patch('/api/v2/auth/signup', responsedata);
const { data } = await apiRequest.patch('/api/v3/auth/signup', responsedata);
return data;
};

Expand Down Expand Up @@ -86,3 +87,12 @@ export const getJobs = async (): Promise<JobsResponse> => {
const { data } = await apiRequest.get('/api/v3/enums/jobs');
return data.data;
};

export interface patchUserJobRequest {
job: string;
}

export const patchUserJob = async (requestData: patchUserJobRequest) => {
const { data } = await apiRequest.patch('/api/v3/users/job', requestData);
return data;
};
8 changes: 8 additions & 0 deletions apps/client/src/shared/apis/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
getGoogleProfile,
getMyProfile,
getJobs,
patchUserJob,
patchUserJobRequest,
} from '@shared/apis/axios';
import { AxiosError } from 'axios';
import {
Expand Down Expand Up @@ -171,3 +173,9 @@ export const useSuspenseGetJobs = () => {
staleTime: Infinity,
});
};

export const usePatchUserJob = () => {
return useMutation({
mutationFn: (data: patchUserJobRequest) => patchUserJob(data),
});
};
2 changes: 1 addition & 1 deletion apps/client/src/shared/apis/setting/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apiRequest.interceptors.response.use(

const noAuthNeeded = [
'/api/v1/auth/token',
'/api/v2/auth/signup',
'/api/v3/auth/signup',
'/api/v2/auth/google',
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button } from '@pinback/design-system/ui';
import { usePatchUserJob } from '@shared/apis/queries';
import { useFunnel } from '@shared/hooks/useFunnel';
import { useState } from 'react';
import FunnelProgress from './FunnelProgress';
Expand All @@ -24,9 +25,14 @@ export default function JobSelectionFunnel({

const [selectedJob, setSelectedJob] = useState<string | null>(null);
const [jobShareAgree, setJobShareAgree] = useState(false);
const { mutateAsync: patchUserJob, isPending: isPatchUserJobPending } =
usePatchUserJob();

const handleNext = () => {
const handleNext = async () => {
if (isLastStep) {
if (selectedJob) {
await patchUserJob({ job: selectedJob });
}
onComplete?.();
return;
}
Expand Down Expand Up @@ -59,7 +65,10 @@ export default function JobSelectionFunnel({
size="medium"
className="w-[4.8rem]"
onClick={handleNext}
isDisabled={currentStep === 'job' && (!jobShareAgree || !selectedJob)}
isDisabled={
isPatchUserJobPending ||
(currentStep === 'job' && (!jobShareAgree || !selectedJob))
}
>
{isLastStep ? '완료' : '다음'}
</Button>
Expand Down
42 changes: 16 additions & 26 deletions apps/extension/src/apis/axios.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
import apiRequest from "./axiosInstance";
import apiRequest from './axiosInstance';
export interface PostArticleRequest {
url: string;
categoryId: number;
memo?: string | null;
remindTime?: string | null;
remindTime?: string | null;
}

export const postArticle = async (data: PostArticleRequest) => {
const response = await apiRequest.post("/api/v1/articles", data);
return response.data;
};


export interface postSignupRequest {
email: string;
remindDefault: string
fcmToken: string;
}

export const postSignup = async (data: postSignupRequest) => {
const response = await apiRequest.post("/api/v1/auth/signup", data);
const response = await apiRequest.post('/api/v1/articles', data);
return response.data;
};

export const getCategoriesExtension = async () => {
const response = await apiRequest.get("/api/v1/categories/extension");
const response = await apiRequest.get('/api/v1/categories/extension');
return response.data;
};

Expand All @@ -33,27 +21,26 @@ export interface postCategoriesRequest {
}

export const postCategories = async (data: postCategoriesRequest) => {
const response = await apiRequest.post("/api/v1/categories", data);
const response = await apiRequest.post('/api/v1/categories', data);
return response.data;
}
};

export const getRemindTime = async () => {
const now = new Date().toISOString().split(".")[0];
const now = new Date().toISOString().split('.')[0];

const response = await apiRequest.get("/api/v1/users/remind-time", {
const response = await apiRequest.get('/api/v1/users/remind-time', {
params: { now },
});

return response.data;
};


export const getArticleSaved=async (url:string) => {
const response = await apiRequest.get("/api/v1/articles/saved", {
export const getArticleSaved = async (url: string) => {
const response = await apiRequest.get('/api/v1/articles/saved', {
params: { url },
});
return response.data;
}
};

export interface PutArticleRequest {
categoryId: number;
Expand All @@ -62,7 +49,10 @@ export interface PutArticleRequest {
remindTime: string | null;
}

export const putArticle = async (articleId: number, data: PutArticleRequest) => {
export const putArticle = async (
articleId: number,
data: PutArticleRequest
) => {
const response = await apiRequest.put(`/api/v1/articles/${articleId}`, data);
return response.data;
};
};
2 changes: 1 addition & 1 deletion apps/extension/src/apis/axiosInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ apiRequest.interceptors.response.use(

const noAuthNeeded = [
'/api/v1/auth/token',
'/api/v2/auth/signup',
'/api/v3/auth/signup',
'/api/v2/auth/google',
];
const isNoAuth = noAuthNeeded.some((url) =>
Expand Down
16 changes: 4 additions & 12 deletions apps/extension/src/apis/query/queries.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import { useMutation, useQuery, UseQueryOptions } from '@tanstack/react-query';
import {
getArticleSaved,
getCategoriesExtension,
getRemindTime,
postArticle,
PostArticleRequest,
postSignup,
postSignupRequest,
getCategoriesExtension,
postCategories,
postCategoriesRequest,
getRemindTime,
getArticleSaved,
putArticle,
PutArticleRequest,
} from '@apis/axios';
import { useMutation, useQuery, UseQueryOptions } from '@tanstack/react-query';

export const usePostArticle = () => {
return useMutation({
mutationFn: (data: PostArticleRequest) => postArticle(data),
});
};

export const usePostSignup = () => {
return useMutation({
mutationFn: (data: postSignupRequest) => postSignup(data),
});
};

export const usePostCategories = () => {
return useMutation({
mutationFn: (data: postCategoriesRequest) => postCategories(data),
Expand Down
Loading