Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #85 from mct-joken/feat/add-laundries-rooms
Browse files Browse the repository at this point in the history
feat: DBにLaundry, Roomを追加
  • Loading branch information
tufusa authored Oct 13, 2023
2 parents 7d2f22d + 574d616 commit c96a617
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ node_modules
wrangler.toml

/public/entry.worker.js
/public/firebase-messaging-sw.js
/public/firebase-messaging-sw.js

# 生SQl文生成用の断片コード
/app/routes/query.tsx
16 changes: 16 additions & 0 deletions app/db/extra.sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
insert into rooms (id, place, createdAt, updatedAt) values
('DVMmJzT76lOOJQTbd5ycp', '3号館1階', CURRENT_TIMESTAMP, null),
('2GfF8a5jlj9a11xfBylxZ', '3号館3階', CURRENT_TIMESTAMP, null),
('gEt38ze6Swbw9emxTYLkp', '4号館2階', CURRENT_TIMESTAMP, null),
('PtL2ZQqhxydp9JuGvIzwf', '4号館3階', CURRENT_TIMESTAMP, null);

insert into laundries (id, roomId, running, createdAt, updatedAt) values
('eyzODasX3LUeMmF1S7vjG', 'DVMmJzT76lOOJQTbd5ycp', '0', CURRENT_TIMESTAMP, null),
('a9jd6cRU00Bn4LLca-kmE', 'DVMmJzT76lOOJQTbd5ycp', '0', CURRENT_TIMESTAMP, null),
('5609v__kQGtLzEL-oOjHF', 'DVMmJzT76lOOJQTbd5ycp', '0', CURRENT_TIMESTAMP, null),
('xwt8BCCAfUe-eQRFGNt55', '2GfF8a5jlj9a11xfBylxZ', '0', CURRENT_TIMESTAMP, null),
('MfHeBSzVvzWvuhi4Qag8K', '2GfF8a5jlj9a11xfBylxZ', '0', CURRENT_TIMESTAMP, null),
('37wCl_bfLsRBXS8WA69C0', 'gEt38ze6Swbw9emxTYLkp', '0', CURRENT_TIMESTAMP, null),
('FWPcvCmN627iUvzHnq9Ba', 'gEt38ze6Swbw9emxTYLkp', '0', CURRENT_TIMESTAMP, null),
('WIgK0WRLp_e2I5--KPAGT', 'PtL2ZQqhxydp9JuGvIzwf', '0', CURRENT_TIMESTAMP, null),
('GdhPBZr8gcemuPcUf3gzW', 'PtL2ZQqhxydp9JuGvIzwf', '0', CURRENT_TIMESTAMP, null);
1 change: 1 addition & 0 deletions app/routes/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useInterval } from "~/hooks/useInterval";
export const loader = async () => {
const rooms = await getClient().query.rooms.findMany({
with: { laundries: true },
orderBy: (room, { asc }) => asc(room.place),
});
return json({ rooms });
};
Expand Down
3 changes: 2 additions & 1 deletion app/routes/wash.complete.$laundryId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export const action = async ({ request, params }: LoaderFunctionArgs) => {

const use = await getClient().query.uses.findFirst({
where: (use, { eq }) => eq(use.laundryId, laundryId),
orderBy: (use, { desc }) => desc(use.createdAt),
with: { account: true },
});
if (use == null) {
if (use?.endAt == null) {
return json({ error: true }, 404);
}
if (use.account?.email !== accountEmail) {
Expand Down

0 comments on commit c96a617

Please sign in to comment.