Skip to content

Commit 7705f0a

Browse files
authored
want to match? (#283)
1 parent 9eab69e commit 7705f0a

16 files changed

Lines changed: 59 additions & 25 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ tsconfig.tsbuildinfo
1919
/.direnv
2020
/.envrc
2121
/shell.nix
22+
23+
server/node_modules/.cache

common/zod/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const BaseUserSchema = z.object({
4949
isForeignStudent: z.boolean().default(false),
5050
grade: GradeSchema,
5151

52+
wantToMatch: z.boolean().default(true),
53+
5254
hobby: HobbySchema,
5355
introduction: IntroductionSchema,
5456
});

server/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ model User {
1717
grade Grade
1818
hobby String
1919
introduction String
20+
wantToMatch Boolean @default(true)
2021
// universityId String
2122
// university University @relation(fields: [universityId], references: [university])
2223
divisionId String

server/routes/community.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ const router = new Hono().get(
1616
exchangeQuery: z.enum(["exchange", "japanese", "all"]).default("all"),
1717
searchQuery: z.string().default(""),
1818
marker: z.union([MarkerSchema, z.literal("notBlocked")]).optional(),
19+
wantsToMatch: z.enum(["true"]).optional(),
1920
}),
2021
),
2122
zValidator("header", z.object({ Authorization: z.string() })),
2223
async (c) => {
2324
const requester = await getUserID(c);
24-
const { except, page, exchangeQuery, searchQuery, marker: markerQuery } = c.req.valid("query");
25+
const { except, page, exchangeQuery, searchQuery, marker: markerQuery, wantsToMatch } = c.req.valid("query");
2526
const take = 15; //TODO: web側で指定できるようにする
2627
const skip = (page - 1) * take;
2728

2829
const whereCondition: Prisma.UserWhereInput = {};
2930

31+
if (wantsToMatch) {
32+
whereCondition.wantToMatch = wantsToMatch === "true";
33+
}
34+
3035
// 言語交換フィルター
3136
if (exchangeQuery === "exchange") {
3237
whereCondition.isForeignStudent = true;
@@ -111,6 +116,7 @@ const router = new Hono().get(
111116
gender: true,
112117
isForeignStudent: true,
113118
imageUrl: true,
119+
wantToMatch: true,
114120
campus: {
115121
select: { university: true, id: true, jaName: true, enName: true },
116122
},

server/routes/users/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const router = new Hono()
3535
imageUrl: true,
3636
isForeignStudent: true,
3737
grade: true,
38+
wantToMatch: true,
3839

3940
hobby: true,
4041
introduction: true,

web/messages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"male": "Male",
7575
"female": "Female",
7676
"other": "Other",
77+
"want-to-match": "Want to match more?",
7778
"photo": "Photo",
7879
"photoUpload": "Upload"
7980
},

web/messages/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"male": "男性",
7575
"female": "女性",
7676
"other": "その他",
77+
"want-to-match": "新規にマッチングしたいですか?",
7778
"photo": "写真",
7879
"photoUpload": "アップロード"
7980
},

web/src/app/[locale]/(auth)/community/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default function Page() {
101101
exchangeQuery: query.exchange,
102102
searchQuery: query.search,
103103
marker: query.marker === "favorite" ? "favorite" : "notBlocked",
104+
wantsToMatch: "true",
104105
},
105106
header: { Authorization },
106107
},

web/src/app/[locale]/(auth)/settings/basic/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export default function Page() {
3636
<option value="other"> {t("basic.other")}</option>
3737
</select>
3838
</label>
39+
<label className={styles.label}>
40+
<span className={styles.labelSpan}>{t("basic.want-to-match")}</span>
41+
<input
42+
type="checkbox"
43+
name="wanttomatch"
44+
className={styles.inputToggle}
45+
value={ctx.formData.name}
46+
onChange={ctx.handleChange}
47+
/>
48+
</label>
3949
<div className={styles.label}>
4050
<input
4151
type="file"

web/src/app/[locale]/(auth)/settings/components/SubmitButton.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,31 @@ import { useTranslations } from "next-intl";
44
import { styles } from "../shared-class.ts";
55

66
export function SubmitButton({ status }: { status: Status }) {
7-
const t = useTranslations("settings");
87
return (
98
<div className={styles.submitButtonWrapperDiv}>
10-
<button
11-
type="submit"
12-
className={clsx(styles.submitButton, {
13-
"btn-primary": status === "ready",
14-
"btn-error": status === "error",
15-
"btn-success": status === "success",
16-
})}
17-
disabled={status !== "ready"}
18-
>
19-
{status === "ready"
20-
? t("register")
21-
: status === "processing"
22-
? t("isRegister")
23-
: status === "success"
24-
? t("success")
25-
: t("failed")}
26-
</button>
9+
<SubmitButtonItem status={status} />
2710
</div>
2811
);
2912
}
13+
export function SubmitButtonItem({ status }: { status: Status }) {
14+
const t = useTranslations("settings");
15+
return (
16+
<button
17+
type="submit"
18+
className={clsx(styles.submitButton, {
19+
"btn-primary": status === "ready",
20+
"btn-error": status === "error",
21+
"btn-success": status === "success",
22+
})}
23+
disabled={status !== "ready"}
24+
>
25+
{status === "ready"
26+
? t("register")
27+
: status === "processing"
28+
? t("isRegister")
29+
: status === "success"
30+
? t("success")
31+
: t("failed")}
32+
</button>
33+
);
34+
}

0 commit comments

Comments
 (0)