W n8n route
This commit is contained in:
parent
a39be32d6b
commit
ee6c6de452
@ -368,39 +368,47 @@ export async function POST(request: Request) {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join('-');
|
.join('-');
|
||||||
|
|
||||||
const giteaResponse = await fetch(`${process.env.GITEA_API_URL}/user/repos`, {
|
console.log('Creating Git repository with name:', sanitizedName);
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': `token ${process.env.GITEA_API_TOKEN}`
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
name: sanitizedName,
|
|
||||||
private: true,
|
|
||||||
auto_init: true,
|
|
||||||
avatar_url: mission.logo || null
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!giteaResponse.ok) {
|
const giteaResponse = await fetch(`${process.env.GITEA_API_URL}/user/repos`, {
|
||||||
const errorData = await giteaResponse.json();
|
method: 'POST',
|
||||||
console.error('Git repository creation failed:', {
|
headers: {
|
||||||
status: giteaResponse.status,
|
'Content-Type': 'application/json',
|
||||||
statusText: giteaResponse.statusText,
|
'Authorization': `token ${process.env.GITEA_API_TOKEN}`
|
||||||
error: errorData
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
name: sanitizedName,
|
||||||
|
private: true,
|
||||||
|
auto_init: true,
|
||||||
|
avatar_url: mission.logo || null
|
||||||
|
})
|
||||||
});
|
});
|
||||||
throw new Error(`Git repository creation failed: ${errorData.message || giteaResponse.statusText}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const giteaData = await giteaResponse.json();
|
if (!giteaResponse.ok) {
|
||||||
|
const errorData = await giteaResponse.json();
|
||||||
// Update the mission with the Git repository URL
|
console.error('Git repository creation failed:', {
|
||||||
await prisma.mission.update({
|
status: giteaResponse.status,
|
||||||
where: { id: mission.id },
|
statusText: giteaResponse.statusText,
|
||||||
data: {
|
error: errorData,
|
||||||
giteaRepositoryUrl: giteaData.html_url
|
requestBody: {
|
||||||
|
name: sanitizedName,
|
||||||
|
private: true,
|
||||||
|
auto_init: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
throw new Error(`Git repository creation failed: ${errorData.message || giteaResponse.statusText}`);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
const giteaData = await giteaResponse.json();
|
||||||
|
console.log('Git repository created successfully:', giteaData.html_url);
|
||||||
|
|
||||||
|
// Update the mission with the Git repository URL using the correct Prisma field
|
||||||
|
await prisma.mission.update({
|
||||||
|
where: { id: mission.id },
|
||||||
|
data: {
|
||||||
|
giteaRepositoryUrl: giteaData.html_url
|
||||||
|
} as Prisma.MissionUpdateInput
|
||||||
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error creating Git repository:', error);
|
console.error('Error creating Git repository:', error);
|
||||||
|
|||||||
@ -380,6 +380,7 @@ export function MissionsAdminPanel() {
|
|||||||
const handleSubmitMission = async () => {
|
const handleSubmitMission = async () => {
|
||||||
console.log('Starting mission submission...');
|
console.log('Starting mission submission...');
|
||||||
console.log('Current mission data:', JSON.stringify(missionData, null, 2));
|
console.log('Current mission data:', JSON.stringify(missionData, null, 2));
|
||||||
|
console.log('Selected services:', selectedServices);
|
||||||
console.log('Guardians:', {
|
console.log('Guardians:', {
|
||||||
gardienDuTemps,
|
gardienDuTemps,
|
||||||
gardienDeLaParole,
|
gardienDeLaParole,
|
||||||
@ -398,7 +399,7 @@ export function MissionsAdminPanel() {
|
|||||||
const formattedData = {
|
const formattedData = {
|
||||||
...missionData,
|
...missionData,
|
||||||
oddScope: Array.isArray(missionData.oddScope) ? missionData.oddScope : [missionData.oddScope],
|
oddScope: Array.isArray(missionData.oddScope) ? missionData.oddScope : [missionData.oddScope],
|
||||||
services: Array.isArray(missionData.services) ? missionData.services.filter(Boolean) : [],
|
services: selectedServices,
|
||||||
profils: Array.isArray(missionData.profils) ? missionData.profils.filter(Boolean) : [],
|
profils: Array.isArray(missionData.profils) ? missionData.profils.filter(Boolean) : [],
|
||||||
guardians: {
|
guardians: {
|
||||||
'gardien-temps': gardienDuTemps,
|
'gardien-temps': gardienDuTemps,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user