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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ tsconfig.tsbuildinfo
/.direnv
/.envrc
/shell.nix

server/node_modules/.cache
2 changes: 2 additions & 0 deletions common/zod/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const BaseUserSchema = z.object({
isForeignStudent: z.boolean().default(false),
grade: GradeSchema,

wantToMatch: z.boolean().default(true),

hobby: HobbySchema,
introduction: IntroductionSchema,
});
Expand Down
1 change: 1 addition & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ model User {
grade Grade
hobby String
introduction String
wantToMatch Boolean @default(true)
// universityId String
// university University @relation(fields: [universityId], references: [university])
divisionId String
Expand Down
8 changes: 7 additions & 1 deletion server/routes/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ const router = new Hono().get(
exchangeQuery: z.enum(["exchange", "japanese", "all"]).default("all"),
searchQuery: z.string().default(""),
marker: z.union([MarkerSchema, z.literal("notBlocked")]).optional(),
wantsToMatch: z.enum(["true"]).optional(),
}),
),
zValidator("header", z.object({ Authorization: z.string() })),
async (c) => {
const requester = await getUserID(c);
const { except, page, exchangeQuery, searchQuery, marker: markerQuery } = c.req.valid("query");
const { except, page, exchangeQuery, searchQuery, marker: markerQuery, wantsToMatch } = c.req.valid("query");
const take = 15; //TODO: web側で指定できるようにする
const skip = (page - 1) * take;

const whereCondition: Prisma.UserWhereInput = {};

if (wantsToMatch) {
whereCondition.wantToMatch = wantsToMatch === "true";
}

// 言語交換フィルター
if (exchangeQuery === "exchange") {
whereCondition.isForeignStudent = true;
Expand Down Expand Up @@ -111,6 +116,7 @@ const router = new Hono().get(
gender: true,
isForeignStudent: true,
imageUrl: true,
wantToMatch: true,
campus: {
select: { university: true, id: true, jaName: true, enName: true },
},
Expand Down
1 change: 1 addition & 0 deletions server/routes/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const router = new Hono()
imageUrl: true,
isForeignStudent: true,
grade: true,
wantToMatch: true,

hobby: true,
introduction: true,
Expand Down
1 change: 1 addition & 0 deletions web/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"male": "Male",
"female": "Female",
"other": "Other",
"want-to-match": "Want to match more?",
"photo": "Photo",
"photoUpload": "Upload"
},
Expand Down
1 change: 1 addition & 0 deletions web/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"male": "男性",
"female": "女性",
"other": "その他",
"want-to-match": "新規にマッチングしたいですか?",
"photo": "写真",
"photoUpload": "アップロード"
},
Expand Down
1 change: 1 addition & 0 deletions web/src/app/[locale]/(auth)/community/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default function Page() {
exchangeQuery: query.exchange,
searchQuery: query.search,
marker: query.marker === "favorite" ? "favorite" : "notBlocked",
wantsToMatch: "true",
},
header: { Authorization },
},
Expand Down
10 changes: 10 additions & 0 deletions web/src/app/[locale]/(auth)/settings/basic/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export default function Page() {
<option value="other"> {t("basic.other")}</option>
</select>
</label>
<label className={styles.label}>
<span className={styles.labelSpan}>{t("basic.want-to-match")}</span>
<input
type="checkbox"
name="wanttomatch"
className={styles.inputToggle}
value={ctx.formData.name}
onChange={ctx.handleChange}
/>
</label>
<div className={styles.label}>
<input
type="file"
Expand Down
41 changes: 23 additions & 18 deletions web/src/app/[locale]/(auth)/settings/components/SubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@ import { useTranslations } from "next-intl";
import { styles } from "../shared-class.ts";

export function SubmitButton({ status }: { status: Status }) {
const t = useTranslations("settings");
return (
<div className={styles.submitButtonWrapperDiv}>
<button
type="submit"
className={clsx(styles.submitButton, {
"btn-primary": status === "ready",
"btn-error": status === "error",
"btn-success": status === "success",
})}
disabled={status !== "ready"}
>
{status === "ready"
? t("register")
: status === "processing"
? t("isRegister")
: status === "success"
? t("success")
: t("failed")}
</button>
<SubmitButtonItem status={status} />
</div>
);
}
export function SubmitButtonItem({ status }: { status: Status }) {
const t = useTranslations("settings");
return (
<button
type="submit"
className={clsx(styles.submitButton, {
"btn-primary": status === "ready",
"btn-error": status === "error",
"btn-success": status === "success",
})}
disabled={status !== "ready"}
>
{status === "ready"
? t("register")
: status === "processing"
? t("isRegister")
: status === "success"
? t("success")
: t("failed")}
</button>
);
}
1 change: 1 addition & 0 deletions web/src/app/[locale]/(auth)/settings/shared-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const styles = {
inputText: "input my-4 min-w-1/3 w-50",
inputSelect: "select my-4 min-w-1/3 max-w-40 md:max-w-none",
inputCheckbox: "checkbox checkbox-lg mx-4 bg-white",
inputToggle: "toggle toggle-primary",
inputTextarea: "my-4 w-auto textarea rounded-xl border border-gray-200 bg-white p-2 sm:w-1/2",
imageUploadButton: "btn btn-primary btn-outline mt-5 h-10 justify-center px-4 py-2 sm:mt-0",
submitButtonWrapperDiv: "flex justify-end",
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/[locale]/registration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default function Page() {
tabIndex={0}
onKeyDown={(e) => {
console.log(e.key);
if (e.key === "Enter") {
if (e.key === "Enter" || e.key === "Space") {
document.getElementById("image-upload")?.click();
}
}}
Expand Down
8 changes: 4 additions & 4 deletions web/src/app/[locale]/registration/step2/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CreateUserSchema, HOBBY_MAX_LENGTH, INTRO_MAX_LENGTH } from "common/zod
import { useTranslations } from "next-intl";
import { useLocale } from "next-intl";
import { useEffect, useState } from "react";
import { SubmitButton } from "../../(auth)/settings/components/SubmitButton.tsx";
import { SubmitButtonItem } from "../../(auth)/settings/components/SubmitButton.tsx";

export default function Page() {
const t = useTranslations();
Expand Down Expand Up @@ -205,12 +205,12 @@ export default function Page() {
/>
</label>
</div>
<div className="flex justify-between px-15">
<Link href="/registration" className="btn h-10 w-25 rounded-lg border border-tBlue p-2 text-tBlue">
<div className="flex flex-row justify-between px-15 ">
<Link href="/registration" className="btn mt-15 h-10 w-25 rounded-lg border border-tBlue p-2 text-tBlue">
{t("community.previousButton")}
</Link>
<SubmitButtonItem status={formStatus} />
</div>
<SubmitButton status={formStatus} />
{errors && <div className="alert alert-error">{errors}</div>}
</div>
</form>
Expand Down
2 changes: 2 additions & 0 deletions web/src/features/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function formatUser(user: StructuredUser, locale: string): FlatUser {
hobby: user.hobby,
introduction: user.introduction,
isForeignStudent: user.isForeignStudent,
wantToMatch: user.wantToMatch,

university: getName(user.campus.university),
division: getName(user.division),
Expand All @@ -35,6 +36,7 @@ export function formatCardUser(user: StructuredCardUser, locale: string): FlatCa
imageUrl: user.imageUrl ?? undefined,
grade: user.grade,
isForeignStudent: user.isForeignStudent,
wantToMatch: user.wantToMatch,

campus: getName(user.campus),

Expand Down
1 change: 1 addition & 0 deletions web/src/features/settings/UserFormController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ export const UserFormProvider = ({
query: {
except: me.id,
marker: "favorite",
wantsToMatch: "ignore",
},
});

Expand Down
2 changes: 1 addition & 1 deletion web/src/hooks/useNormalizedPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PATHNAME_LANG_PREFIX_PATTERN } from "@/consts";
import { PATHNAME_LANG_PREFIX_PATTERN } from "@/consts.ts";
import { usePathname } from "next/navigation";

/**
Expand Down