Skip to content

Commit 7353719

Browse files
authored
Merge pull request #15 from CodeChefVIT/harshit/users
things
2 parents ed62dfb + 0b186c2 commit 7353719

17 files changed

Lines changed: 878 additions & 663 deletions

File tree

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"@radix-ui/react-select": "^2.1.5",
2222
"@radix-ui/react-separator": "^1.1.1",
2323
"@radix-ui/react-slot": "^1.1.1",
24+
"@radix-ui/react-switch": "^1.1.2",
25+
"@radix-ui/react-toggle": "^1.1.1",
2426
"@radix-ui/react-tooltip": "^1.1.7",
2527
"@t3-oss/env-nextjs": "^0.10.1",
2628
"@tanstack/react-query": "^5.65.1",
@@ -31,6 +33,7 @@
3133
"clsx": "^2.1.1",
3234
"cmdk": "1.0.0",
3335
"geist": "^1.3.0",
36+
"headlessui": "^0.0.0",
3437
"lucide-react": "^0.437.0",
3538
"next": "^14.2.4",
3639
"next-themes": "^0.4.4",

pnpm-lock.yaml

Lines changed: 24 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/ban.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import axios from "./axiosConfig";
2+
3+
interface banning{
4+
status:string;
5+
message: string;
6+
data: object;
7+
}
8+
9+
export const banUnban = async ({ ban, email }: { ban: boolean; email: string; })=>{
10+
try {
11+
const url = ban?"/admin/ban":"/admin/unban"
12+
const response = await axios.post(url, {email})
13+
console.log("this is banning")
14+
console.log(response.data)
15+
return response.data as banning;
16+
}catch(err){
17+
18+
throw err;
19+
}
20+
}

src/api/fetchScores.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ const scoresResponseSchema = z.object({
2121
}),
2222
});
2323

24+
const deleteSchema = z.object({
25+
status: z.string(),
26+
data: z.record(z.unknown()),
27+
});
28+
2429

25-
interface ScoreResponse extends z.infer<typeof scoreSchema>{}
30+
type ScoreResponse = z.infer<typeof scoreSchema>
2631
interface CreateScoreRequest extends Omit<z.infer<typeof scoreSchema>, 'id'>{
2732
team_id: string;
2833
}
@@ -46,7 +51,11 @@ export const fetchScores = async (teamId: string) => {
4651
throw err;
4752
}
4853
};
54+
const createResponseSchema = z.object({
4955

56+
message: z.string(),
57+
58+
});
5059

5160
export const createScore = async ({
5261
team_id,
@@ -75,7 +84,8 @@ export const createScore = async ({
7584
withCredentials: true,
7685
}
7786
);
78-
return response.data;
87+
const parsedResponse = createResponseSchema.parse(response.data);
88+
return parsedResponse;
7989
} catch (err) {
8090
console.error(err);
8191
throw err;
@@ -87,13 +97,21 @@ export const deleteScore = async (scoreId: string) => {
8797
const response = await axios.delete(`panel/deletescore/${scoreId}`,{
8898
withCredentials: true,
8999
});
90-
return response.data;
100+
101+
const parsedResponse = deleteSchema.parse(response.data);
102+
return parsedResponse;
91103
} catch (err) {
92104
console.error(err);
93105
throw err;
94106
}
95107
};
96108

109+
const updateResponseSchema = z.object({
110+
111+
message: z.string(),
112+
113+
});
114+
97115
export const updateScore = async ({
98116
scoreId,
99117
design,
@@ -128,7 +146,9 @@ export const updateScore = async ({
128146
withCredentials: true,
129147
}
130148
);
131-
return response.data;
149+
150+
const parsedResponse = updateResponseSchema.parse(response.data);
151+
return parsedResponse;
132152
} catch (err) {
133153
console.error(err);
134154
throw err;

src/api/fetchTeamDetails.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { type MainSearch, MainTeamSearchResponse} from "@/data/schema";
44
import axios from "./axiosConfig";
55

66

7-
export const fetchTeamDetails = async ({ uuid }: { uuid: string}) => {
7+
export const fetchTeamDetails = async ({ uuid }: { uuid: string }) => {
88
try {
99
const response = await axios.get<MainSearch>(
1010
`admin/teams/${uuid}`
1111
);
12-
12+
// console.log(response)
1313
const parsedResponse = MainTeamSearchResponse.parse(response.data)
1414
console.log(parsedResponse)
1515
return parsedResponse.data

src/api/logout.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import axios from "./axiosConfig";
2+
import {data} from "@/store/interfaces"
3+
4+
export const login = async(email: string, password: string) =>{
5+
try {
6+
const response = await axios.post('/auth/logout', {email, password})
7+
return response.data as data;
8+
}catch(err){
9+
10+
throw err;
11+
}
12+
}

src/app/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { LoginForm } from "@/components/login-form"
33
export default function Page() {
44

55
return (
6-
<div className=" flex h-full w-full items-center justify-center p-6 md:p-10">
6+
<div className=" flex h-[100vh] w-full items-center justify-center p-6 md:p-10">
77
<div className=" w-full max-w-sm">
88
<LoginForm />
99
</div>

0 commit comments

Comments
 (0)