-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/fix chakra progress theme error #115
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Progress } from "@chakra-ui/react"; | ||
|
||
interface IProgressBar { | ||
value: number; | ||
colorScheme?: "mintTheme"; | ||
hasStripe?: boolean; | ||
} | ||
|
||
export default function ProgressBar({ | ||
value, | ||
colorScheme = "mintTheme", | ||
hasStripe = false, | ||
}: IProgressBar) { | ||
return <Progress value={value} colorScheme={colorScheme} hasStripe={hasStripe} />; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import mongoose, { Model, Schema } from "mongoose"; | ||
|
||
import { IStoreApplicant } from "../types/models/store"; | ||
|
||
const giftSchema: Schema = new Schema( | ||
{ | ||
uid: { type: String, ref: "User" }, | ||
name: { type: String, ref: "User" }, | ||
cnt: { type: Number, default: 0 }, | ||
giftId: { type: Number }, | ||
}, | ||
{ | ||
toJSON: { | ||
transform(_doc, ret) { | ||
delete ret.createdAt; | ||
delete ret.upadtedAt; | ||
delete ret.__v; | ||
return ret; | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
export const GiftModel = | ||
(mongoose.models.GiftModel as Model<IStoreApplicant, {}, {}, {}>) || | ||
mongoose.model<IStoreApplicant>("GiftModel", giftSchema); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Badge, Progress } from "@chakra-ui/react"; | ||
import { Badge } from "@chakra-ui/react"; | ||
import { faQuestionCircle } from "@fortawesome/pro-light-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { useSession } from "next-auth/react"; | ||
import { useEffect, useState } from "react"; | ||
import styled from "styled-components"; | ||
import ProgressBar from "../../../components/atoms/ProgressBar"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 당장 적용할 수는 없겠지만 tsconfig에 절대 경로 설정을 하게 되면 import 경로가 조금 더 간결해질 수도 있을 것 같습니다 :) |
||
import { | ||
BADGE_COLOR_MAPPINGS, | ||
|
@@ -80,11 +81,10 @@ function PointScoreBar({ myScore, hasQuestion = true }: IPointScoreBar) { | |
</div> | ||
)} | ||
</Grade> | ||
<Progress | ||
<ProgressBar | ||
value={(1 - (nextBadgePoint - myScore) / badgeGap) * 100} | ||
height="12px" | ||
colorScheme="mintTheme" | ||
hasStripe | ||
hasStripe={true} | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 convention으로 정할 수도 있을 것 같은 부분인 것 같습니다 :) 혹시 변수로 정해지는 boolean prop이 아닐 때도 true/false를 명시하는 걸 선호하실까요? :) |
||
</Layout> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import { BadRequestError } from "../../../libs/backend/custom-error"; | ||
import dbConnect from "../../../libs/backend/dbConnect"; | ||
import { GiftModel } from "../../../models/gift"; | ||
|
||
export default async function getGift(req: NextApiRequest, res: NextApiResponse) { | ||
await dbConnect(); | ||
|
||
if (req.method === "GET") { | ||
const { id } = req.query; | ||
|
||
const giftUsers = await GiftModel.find({ giftId: id }).select( | ||
"-_id -createdAt -updatedAt -__v", | ||
); | ||
if (!giftUsers) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 별 건 아니지만 여기 if 문 위에 개행이 들어가면 조금 더 깔끔할 수도 있을 것 같습니다 :)
|
||
throw new BadRequestError("정보에 해당하는 유저가 존재하지 않습니다."); | ||
} | ||
|
||
res.status(200).json({ users: giftUsers }); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import { BadRequestError } from "../../../libs/backend/custom-error"; | ||
import dbConnect from "../../../libs/backend/dbConnect"; | ||
import { GiftModel } from "../../../models/gift"; | ||
|
||
export default async function giftController(req: NextApiRequest, res: NextApiResponse) { | ||
await dbConnect(); | ||
|
||
if (req.method === "POST") { | ||
const { name, uid, cnt, giftId } = req.body; | ||
|
||
const existingUser = await GiftModel.findOne({ uid, giftId }); | ||
|
||
if (existingUser) { | ||
const user = await GiftModel.findOneAndUpdate( | ||
{ uid }, | ||
{ name, uid, cnt: existingUser.cnt + cnt, giftId }, | ||
{ new: true, runValidators: true }, | ||
); | ||
if (!user) { | ||
throw new BadRequestError("정보에 해당하는 유저가 존재하지 않습니다."); | ||
} | ||
|
||
const resUser = { | ||
name: user.name, | ||
uid: user.uid, | ||
cnt: user.cnt, | ||
giftId: user.giftId, | ||
}; | ||
|
||
return res.status(200).json({ user: resUser }); | ||
} | ||
const newUser = await GiftModel.create({ name, uid, cnt, giftId }); | ||
const user = { | ||
name: newUser.name, | ||
uid: newUser.uid, | ||
cnt: newUser.cnt, | ||
giftId: newUser.giftId, | ||
}; | ||
res.status(200).json({ user }); | ||
} | ||
if (req.method === "GET") { | ||
const giftUsers = await GiftModel.find({}) | ||
.sort("createdAt") | ||
.select("-_id -createdAt -updatedAt -__v"); | ||
|
||
res.status(200).json({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사소한 부분입니다 :)
|
||
users: giftUsers, | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { useAdminStudyRecordQuery } from "../hooks/admin/quries"; | |
import { useImageUploadMutation } from "../hooks/image/mutations"; | ||
import { studyDateStatusState } from "../recoils/studyRecoils"; | ||
function Test() { | ||
const { data } = useAdminStudyRecordQuery(dayjs("2024-04-01"), dayjs("2024-04-07"), null, "인천"); | ||
const { data } = useAdminStudyRecordQuery(dayjs("2024-04-16"), dayjs("2024-04-30"), null, "인천"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 단순 궁금증입니다 :)
|
||
console.log(data); | ||
|
||
const a = useRecoilValue(studyDateStatusState); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 prop은 당장은 상수여서 엄청 필요한 prop은 아닌 것 같습니다 :)
혹시 어떤 의도로 prop을 만드셨는지 궁금합니다 :)