W n8n route
This commit is contained in:
parent
a39be32d6b
commit
ee6c6de452
@ -368,39 +368,47 @@ export async function POST(request: Request) {
|
||||
.filter(Boolean)
|
||||
.join('-');
|
||||
|
||||
const giteaResponse = await fetch(`${process.env.GITEA_API_URL}/user/repos`, {
|
||||
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
|
||||
})
|
||||
});
|
||||
console.log('Creating Git repository with name:', sanitizedName);
|
||||
|
||||
if (!giteaResponse.ok) {
|
||||
const errorData = await giteaResponse.json();
|
||||
console.error('Git repository creation failed:', {
|
||||
status: giteaResponse.status,
|
||||
statusText: giteaResponse.statusText,
|
||||
error: errorData
|
||||
const giteaResponse = await fetch(`${process.env.GITEA_API_URL}/user/repos`, {
|
||||
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
|
||||
})
|
||||
});
|
||||
throw new Error(`Git repository creation failed: ${errorData.message || giteaResponse.statusText}`);
|
||||
}
|
||||
|
||||
const giteaData = await giteaResponse.json();
|
||||
|
||||
// Update the mission with the Git repository URL
|
||||
await prisma.mission.update({
|
||||
where: { id: mission.id },
|
||||
data: {
|
||||
giteaRepositoryUrl: giteaData.html_url
|
||||
if (!giteaResponse.ok) {
|
||||
const errorData = await giteaResponse.json();
|
||||
console.error('Git repository creation failed:', {
|
||||
status: giteaResponse.status,
|
||||
statusText: giteaResponse.statusText,
|
||||
error: errorData,
|
||||
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) {
|
||||
console.error('Error creating Git repository:', error);
|
||||
|
||||
@ -380,6 +380,7 @@ export function MissionsAdminPanel() {
|
||||
const handleSubmitMission = async () => {
|
||||
console.log('Starting mission submission...');
|
||||
console.log('Current mission data:', JSON.stringify(missionData, null, 2));
|
||||
console.log('Selected services:', selectedServices);
|
||||
console.log('Guardians:', {
|
||||
gardienDuTemps,
|
||||
gardienDeLaParole,
|
||||
@ -398,7 +399,7 @@ export function MissionsAdminPanel() {
|
||||
const formattedData = {
|
||||
...missionData,
|
||||
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) : [],
|
||||
guardians: {
|
||||
'gardien-temps': gardienDuTemps,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user