Add ettempts in contests
This commit is contained in:
@@ -75,6 +75,7 @@ export interface Attempt {
|
||||
startedAt: string;
|
||||
expiresAt: string;
|
||||
finished: boolean;
|
||||
submissions?: Submission[];
|
||||
results?: any[];
|
||||
}
|
||||
|
||||
@@ -203,12 +204,11 @@ interface ContestsState {
|
||||
};
|
||||
|
||||
fetchParticipating: {
|
||||
contests: Contest[],
|
||||
hasNextPage: boolean,
|
||||
status: Status,
|
||||
error?: string,
|
||||
contests: Contest[];
|
||||
hasNextPage: boolean;
|
||||
status: Status;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const emptyContest: Contest = {
|
||||
@@ -253,12 +253,11 @@ const initialState: ContestsState = {
|
||||
checkRegistration: { registered: false, status: 'idle' },
|
||||
fetchUpcomingEligible: { contests: [], status: 'idle' },
|
||||
fetchParticipating: {
|
||||
contests: [],
|
||||
hasNextPage: false,
|
||||
status: 'idle',
|
||||
error: undefined,
|
||||
},
|
||||
|
||||
contests: [],
|
||||
hasNextPage: false,
|
||||
status: 'idle',
|
||||
error: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
// =====================
|
||||
@@ -277,19 +276,18 @@ export const fetchParticipatingContests = createAsyncThunk(
|
||||
const { page = 0, pageSize = 10 } = params;
|
||||
const response = await axios.get<ContestsResponse>(
|
||||
'/contests/participating',
|
||||
{ params: { page, pageSize } }
|
||||
{ params: { page, pageSize } },
|
||||
);
|
||||
return response.data;
|
||||
} catch (err: any) {
|
||||
return rejectWithValue(
|
||||
err.response?.data?.message || 'Failed to fetch participating contests'
|
||||
err.response?.data?.message ||
|
||||
'Failed to fetch participating contests',
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
export const fetchMySubmissions = createAsyncThunk(
|
||||
'contests/fetchMySubmissions',
|
||||
async (contestId: number, { rejectWithValue }) => {
|
||||
@@ -928,25 +926,27 @@ const contestsSlice = createSlice({
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
builder.addCase(fetchParticipatingContests.pending, (state) => {
|
||||
state.fetchParticipating.status = 'loading';
|
||||
});
|
||||
state.fetchParticipating.status = 'loading';
|
||||
});
|
||||
|
||||
builder.addCase(
|
||||
fetchParticipatingContests.fulfilled,
|
||||
(state, action: PayloadAction<ContestsResponse>) => {
|
||||
state.fetchParticipating.status = 'successful';
|
||||
state.fetchParticipating.contests = action.payload.contests;
|
||||
state.fetchParticipating.hasNextPage = action.payload.hasNextPage;
|
||||
}
|
||||
);
|
||||
|
||||
builder.addCase(fetchParticipatingContests.rejected, (state, action: any) => {
|
||||
state.fetchParticipating.status = 'failed';
|
||||
state.fetchParticipating.error = action.payload;
|
||||
});
|
||||
builder.addCase(
|
||||
fetchParticipatingContests.fulfilled,
|
||||
(state, action: PayloadAction<ContestsResponse>) => {
|
||||
state.fetchParticipating.status = 'successful';
|
||||
state.fetchParticipating.contests = action.payload.contests;
|
||||
state.fetchParticipating.hasNextPage =
|
||||
action.payload.hasNextPage;
|
||||
},
|
||||
);
|
||||
|
||||
builder.addCase(
|
||||
fetchParticipatingContests.rejected,
|
||||
(state, action: any) => {
|
||||
state.fetchParticipating.status = 'failed';
|
||||
state.fetchParticipating.error = action.payload;
|
||||
},
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user