Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutation 리팩토링 #146

Merged
merged 12 commits into from
Dec 13, 2020
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
2 changes: 1 addition & 1 deletion client/src/components/common/TaxiMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TaxiMarker: React.FC<MarkerType> = () => {
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="44" height="44" viewBox="0 0 172 172">
<g
fill="none"
fill-rule="nonzero"
fillRule="nonzero"
stroke="none"
strokeWidth="1"
strokeLinecap="butt"
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/driverSignup/DriverSignupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ const DriverSignupForm = withFormik({
handleSubmit: async (values, { props, setSubmitting }: any) => {
try {
const { id, password, userName: name, phone, licenseNumber, carModel, plateNumber, carColor } = values;
const variables = { id, password, name, phone, licenseNumber, carModel, plateNumber, carColor };
const info = { id, password, name, phone, licenseNumber, carModel, plateNumber, carColor };

setSubmitting(true);
const {
data: {
driverSignup: { success, message },
},
} = await props.addDriver({
variables,
variables: { info },
});
setSubmitting(false);

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/signin/SigninForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const LoginForm: React.FC<LoginFormPropsType> = (props) => {
if (!id.length || !password.length) {
alert('아이디와 비밀번호를 모두 입력하세요');
} else {
const variables = { id, password };
const info = { id, password };
const isUser = props.userType === 'user';
const mutation = isUser ? 'userSignin' : 'driverSignin';
const {
data: {
[mutation]: { success, message },
},
} = await props.signin({ variables });
} = await props.signin({ variables: { info } });

if (success) props.history.push(isUser ? '/user/map' : '/driver/main');
else alert(message);
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/userSignup/InputIdPw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const InputIdPw: React.FC<InputIdPwProps> = (props) => {

const handleSubmit = async () => {
const [phone, name] = [props.phone, props.name];
const variables = { id, password, name, phone };
const info = { id, password, name, phone };
try {
const {
data: {
userSignup: { success, message },
},
} = await addUser({
variables,
variables: { info },
});
if (success) history.push('/user/map');
else showAlert(message);
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/user/UserMatchingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const UserMatchingPage: React.FC = () => {
}, []);

const saveHistory = useCallback(async () => {
const variables = {
const info = {
request: request,
fee: preData.info.fee,
carModel: taxiInfo.carModel,
Expand All @@ -140,7 +140,7 @@ const UserMatchingPage: React.FC = () => {
};
const {
data: { saveUserHistory: result },
} = await saveUserHistory({ variables });
} = await saveUserHistory({ variables: { info } });
return result;
}, [request, preData, taxiInfo, startTime]);

Expand Down
4 changes: 2 additions & 2 deletions client/src/queries/driver/driverSignin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gql } from '@apollo/client';

export const SIGNIN_DRIVER = gql`
mutation DriverSignin($id: String!, $password: String!) {
driverSignin(id: $id, password: $password) {
mutation DriverSignin($info: SigninInfo!) {
driverSignin(info: $info) {
success
message
}
Expand Down
22 changes: 2 additions & 20 deletions client/src/queries/driver/driverSignup.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
import { gql } from '@apollo/client';

export const ADD_DRIVER = gql`
mutation DriverSignup(
$id: String!
$password: String!
$name: String!
$phone: String!
$licenseNumber: String!
$carModel: String!
$plateNumber: String!
$carColor: String!
) {
driverSignup(
id: $id
password: $password
name: $name
phone: $phone
licenseNumber: $licenseNumber
carModel: $carModel
plateNumber: $plateNumber
carColor: $carColor
) {
mutation DriverSignup($info: DriverSignupInfo!) {
driverSignup(info: $info) {
success
message
}
Expand Down
18 changes: 2 additions & 16 deletions client/src/queries/user/userHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,8 @@ export const GET_USER_HISTORY = gql`
`;

export const SAVE_USER_HISTORY = gql`
mutation saveUserHistory(
$request: UserRequestInput!
$fee: Int!
$carModel: String!
$plateNumber: String!
$startTime: String!
$endTime: String!
) {
saveUserHistory(
request: $request
fee: $fee
startTime: $startTime
endTime: $endTime
carModel: $carModel
plateNumber: $plateNumber
) {
mutation saveUserHistory($info: HistoryInfo!) {
saveUserHistory(info: $info) {
success
message
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/queries/user/userSignin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gql } from '@apollo/client';

export const SIGNIN_USER = gql`
mutation UserSignin($id: String!, $password: String!) {
userSignin(id: $id, password: $password) {
mutation UserSignin($info: SigninInfo!) {
userSignin(info: $info) {
success
message
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/queries/user/userSignup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gql } from '@apollo/client';

export const ADD_USER = gql`
mutation UserSignup($id: String!, $password: String!, $name: String!, $phone: String!) {
userSignup(id: $id, password: $password, name: $name, phone: $phone) {
mutation UserSignup($info: UserSignupInfo!) {
userSignup(info: $info) {
success
message
}
Expand Down
Loading